Hi, I am facing a problem with OSG Image and would like to seek some advice from the community.
I have a model exported in IVE format. This model is just a quad with a texture mapped onto it. I want to retrieve the original image from osg::Image object and convert it to JPG/PNG or any other format. Seems simple, but I am not sure what is causing the problem. The image when loaded using osgviewer looks perfectly fine. But when I debug and look at the contents of the osg::Image object I find that both the InternalTextureFormat and the PixelFormat are invalid. _internalTextureFormat 33776 int _pixelFormat 33776 unsigned int The pixel size is 4 bits per pixel. I tried using osg::writeImageFile with extension as JPG, TGA and PNG. Nothing works. With extension as RGB the image is saved but is incorrect. I think it is because of the fact that the image is 4 bits per pixel. So, what I did is to use ImageMagick to convert the image data buffer to a common format (JPG, PNG or TGA). However I am unable to do the conversion from the 4 bit per pixel to a 24 bit per pixel. Any help here would be greatly appreciated. My mechanism for conversion from a 4 BPP to a 24 BPP is as follows: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> unsigned int total_size_in_bytes = image->getTotalSizeInBytes(); unsigned int row_size_in_bytes = image->getRowSizeInBytes(); unsigned int image_size_in_bytes = image->getImageSizeInBytes(); unsigned char* ptr = image->data(); unsigned int size = w*h; unsigned char* writePtr = new unsigned char[size]; memset(writePtr, 0, size); // i convert to byte array (not sure if this is the correct way to do) for(unsigned int i = 0; i < size; i+=2) { writePtr[i] = (ptr[i/2] >> 4); writePtr[i+1] = (ptr[i/2] & 0x0F); } // now i have the byte array and i set to imagemagick for (unsigned int y = 0; y < h; y++) { for (unsigned int x = 0; x < w; x++) { unsigned char c = writePtr[x+y*w]; Magick::PixelPacket* curMagickPix = 0; curMagickPix = magickPixels + (y*w + x); curMagickPix->red = c; curMagickPix->green = c; curMagickPix->blue = c; } } delete [] writePtr; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I tried to attach the IVE file but the email bounced. So I am putting it up for download. The URL is: http://68.168.137.66/osguser/Ceiling_1LightingMap.ive Regards, Shamim
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org