<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi all,</FONT></DIV>
<DIV><FONT face=Arial size=2>Im trying to read the scanned data using sane form
UMAX 2000p but when i set a custom resolution the read is causing some problem.
This is my code.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>int print_data(SANE_Handle
devHnd)<BR>{</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> SANE_Int MAX_LEN = 4048;<BR> char
filepnm[INIT_SIZE];<BR> int size = INIT_SIZE, ret = 0;<BR> int
first_frame =1;<BR> SANE_Parameters parm;<BR> SANE_Int len = 0;
<BR> FILE* fp = NULL;<BR> char *name = malloc(INIT_SIZE);<BR>
char *value = malloc(INIT_SIZE);<BR> SANE_Byte* buffer =
(SANE_Byte*)malloc(sizeof(SANE_Byte) *
MAX_LEN);<BR> <BR> <BR>
strcpy(filepnm,"images//out.pnm");<BR> fp =
fopen(filepnm,"wb+");<BR> <BR> <BR>
strcpy(name,"State");<BR> <BR> if(fp == NULL)<BR>
{<BR> status =
SANE_STATUS_IO_ERROR;<BR>
set_error(act);<BR>
free(buffer);<BR>
free(name);<BR>
free(value);<BR> ret = 1;<BR>
printf("File null...\n");<BR>
return ret;<BR> }<BR> do<BR>
{<BR> if((status = sane_get_parameters (devHnd, &parm)) !=
SANE_STATUS_GOOD)<BR> {<BR> <BR>
set_error(act);<BR> printf("get parameters
failed...\n");<BR> free(buffer);<BR>
free(name);<BR> free(value);<BR>
fclose(fp);<BR> ret = 1;<BR> return
ret;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
if(first_frame)<BR> {</FONT></DIV>
<DIV><FONT face=Arial size=2> printf("Printing scanned
data...\n\n");<BR> write_pnm_header (parm.format,fp,
parm.pixels_per_line,<BR>
parm.lines, parm.depth);<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> }<BR> <BR> do<BR>
{<BR> <BR> status = read_data(devHnd,
buffer, MAX_LEN, &len);<BR> if(status == SANE_STATUS_GOOD
)<BR> {<BR> <BR>
fwrite(buffer,len,sizeof(SANE_Byte),fp);<BR>
}<BR> else if(status != SANE_STATUS_EOF)<BR>
{<BR> <BR> set_error(act);
<BR> printf("Reading scanned data
failed...\n");<BR> }<BR>
free(buffer);<BR> buffer =
(SANE_Byte*)malloc(sizeof(SANE_Byte) * MAX_LEN);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> }while( status == SANE_STATUS_GOOD
&& len != 0);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> if( status == SANE_STATUS_EOF)<BR>
{<BR>
pthread_cond_signal(&pollevent);<BR> printf("Reading
complete...\n"); <BR> }<BR> else <BR> {<BR>
pthread_cond_signal(&pollevent);<BR> ret =
1;<BR> set_error(act); <BR>
printf("Reason: %s",(char*)sane_strstatus(status)); <BR>
}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> first_frame = 0;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> }while(!parm.last_frame);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> free(buffer);<BR>
free(name);<BR> free(value);<BR> fclose(fp);</FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV>
<DIV> return ret;<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>any help is appreciated</FONT></DIV>
<DIV><FONT face=Arial size=2>Aneesh</FONT></DIV></BODY></HTML>