Writing image to blob PNG vs TIFF

"Robert H. Olsen" <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
I am having some problems writing gm Image data to a blob that I do not 
understand.

The images are acquired from an AVT GigE camera.  I am using Graphics 
Magick to convert the images to different formats based on user 
requests, and those images are transferred over the network to various 
clients who display/store/analyze the data.  I am currently focused on 
using PNG and TIFF formatted data.   PNG works well (although it is 
relatively slow for the color images I've been working with)  TIFF seems 
to only work for the first image of a given size.

Here is some code which runs in a loop, executing each time a new aravis 
image is triggered:

    Blob blob(pRawImage, (arv_width * arv_height * nbytes));
    Image gmimage;

    if((arv_format == ARV_PIXEL_FORMAT_MONO_8) ||
       (arv_format == ARV_PIXEL_FORMAT_MONO_12) ||
       (arv_format == ARV_PIXEL_FORMAT_MONO_16)) {
      // grayscale image
      gmimage.depth(bpp);
      gmimage.endian(LSBEndian);
      gmimage.read(blob,Geometry(arv_width, arv_height),"GRAY");
      gmimage.normalize();
    }
    else {
      // assume color image
      gmimage.depth(8);
      gmimage.endian(LSBEndian);
      gmimage.read(blob,Geometry(arv_width, arv_height),"RGB");
    }

    // potentially reduce the size of the image
    for(int i = 1; i < GetSizeFactor(); i++) {
      gmimage.minify();
    }

    // Create a formatted gm blob
    Blob * pBlob = GetPBlob();   // points to space allocated elsewhere
    gmimage.write(pBlob, GetGMType());  // GetGMType() returns either 
"PNG" or "TIFF"
//   gmimage.write(pBlob, "TIFF");
//   gmimage.write(pBlob, "PNG");

This works well for "PNG" but if the type is "TIFF" then the image at 
pBlob is correct only the first time through after starting up or 
changing from PNG mode, or if I change the number of times minify() is 
run on the image, otherwise the image data is not changed though it 
should have been updated when the new trigger was received. If I switch 
back to PNG everything is fine again.  Do TIFF and PNG deal with 
previously allocated space differently, or something like that?

Any suggestions?

Thanks!



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.