please help about fileSize() function

"alessandro bonvicini" <[email protected]> Thu, 3 Mar 2005 22:00:43 +0100
Newsgroups gmane.comp.video.graphicsmagick.core,gmane.comp.video.graphicsmagick.help,gmane.comp.video.graphicsmagick.cvs
Message-ID <002701c52034$10838490$0203a8c0@sally>
HI all,
first of all I would like to thanks all of you for the really wonderfull 
work done in graphics magicks.
I am new to the library but I am very impressed from the features.

I need your help because I don't understnd the behavior of the fileSize() 
function.
The following is the code that I am trying to work with.

//load image file ppm in buffer
FILE * fp=fopen("prova.ppm","rb");
imgBuff=(char *)malloc(921660*sizeof(char));
fread(imgBuff,921660,1,fp);

//create a blob
Blob blob(imgBuff,921660);

//create image instance
Image image;
image.size("640x480");
image.magick("PNG");
image.read(blob);

printf("Blob LEN:%d\n",blob.length);  <-------correct 921660

 // Write the image to a file doing some transformation
 image.quantizeColors( 8 );
 image.quantize();

//now I would like to know the size of the resulting image but?
 int len = image.fileSize();
 printf("LEN before write:%ld\n",len);        <-------now the size is still 
921660, why ?????????

 //the write the image on file
 image.write( "xxx.png" );

//retry to read fileSize and
len = image.fileSize();
printf("LEN after file write :%ld\n",len);    <-------now the size is 49512 
, wrong the real file size on disk is
60986 bytes.

In my program I need to know the dimension of the file in which the image 
will be written BEFORE the call to
image.write, for streaming purpose.
How can  I do this? Is it possibile?
And why the fileSize() returned in the end is different from what it is 
written on disk?

Thank you very much for help.
Thank in advance.
Alex



 



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click