Re: [osg-users] Win32 Bitmap to osg Image
Hi all, Just a few word to conclude this issue : I had to swap the BGR to RGB colors by myselt, the following code was not enougth to make it : I would naively expect that either _image-setImage(width, height, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE); or _image-setImage(width, height, 1, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE); Regards, Vincent. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Win32 Bitmap to osg Image
Hi Vincent, On 14 February 2012 08:25, Vincent Bourdier vincent.bourd...@gmail.com wrote: Just a few word to conclude this issue : I had to swap the BGR to RGB colors by myselt, the following code was not enougth to make it : This suggest you are doing something wrong with your setup of your image. The internal texture format should be GL_RGB, and the pixel format should be GL_BGR, this is pretty straight foward and common usage of the OSG. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Win32 Bitmap to osg Image
Hi Urich, Le 03/02/2012 05:41, Ulrich Hertlein a écrit : what errors/issues/non-results are you seeing? Black? Reversed colors? Crashes? The BGR become RGB without conversion, so the image is almost good, unless the color component that are swapped between red and blue. (As I understand it you want to use the Bitmap directly as an image (not save it and read it back) so I'm not sure where the plugin fits into the picture.) It was just to see how OSG manage this issue. First of all you don't need to do 'allocateImage' *AND* 'setImage'. 'allocateImage' allocates memory internally to osg::Image that can then be filled but I assume you already have a buffer that it should use, so 'setImage' would be enough. Yes, I'll remove the allocateImage call if it is not necessary, it was working well so I didn't change this piece of code... osg::Image::setImage is designed to allow the user to specify a buffer that osg::Image then uses (and manages, depending on the AllocationMode). When you're passing a buffer allocated by somebody else you may want to use AllocationMode::NO_DELETE, so that osg::Image does not delete/free it. Yes, thanks to this precision but I prefer the image to delete the content of the buffer in my implementation. Regarding the RGB vs BGR you only want to change the 'pixelFormat' parameter, not the 'internalTextureFormat'. I would naively expect that either _image-setImage(width, height, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE); or _image-setImage(width, height, 1, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE); would do the trick. I'll try this but I don't think it would be so easy... even if it would be very interesting ! Thanks a lot for your help, I'll continue to analyze this. Regards, Vincent. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Win32 Bitmap to osg Image
Hi all, I'm currently trying to convert a bitmap image file to an osg::Image. I get my Bitmap from the win32 api making a screenshot, but as specified in the plugin bmp the internal format of the Bitmap is not RGB but BGR. Is there any way to directly use the BGR data buffer in a new osg::Image or do I need to swap from BGR to RGB ? I use this : /_texGrad-allocateImage(width, height, 1, GL_RGB, GL_UNSIGNED_BYTE); _texGrad-setImage(width, height, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, data, osg::Image::USE_NEW_DELETE); / I tried to change the GL_RGB into GL_BGR without results... Any suggestion will be very useful. Thanks a lot. Regards, Vincent. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Win32 Bitmap to osg Image
Hi Vincent, what errors/issues/non-results are you seeing? Black? Reversed colors? Crashes? On 2/02/12 21:52 , Vincent Bourdier wrote: I'm currently trying to convert a bitmap image file to an osg::Image. I get my Bitmap from the win32 api making a screenshot, but as specified in the plugin bmp the internal format of the Bitmap is not RGB but BGR. Is there any way to directly use the BGR data buffer in a new osg::Image or do I need to swap from BGR to RGB ? I use this : /_texGrad-allocateImage(width, height, 1, GL_RGB, GL_UNSIGNED_BYTE); _texGrad-setImage(width, height, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, data, osg::Image::USE_NEW_DELETE); / I tried to change the GL_RGB into GL_BGR without results... Any suggestion will be very useful. (As I understand it you want to use the Bitmap directly as an image (not save it and read it back) so I'm not sure where the plugin fits into the picture.) First of all you don't need to do 'allocateImage' *AND* 'setImage'. 'allocateImage' allocates memory internally to osg::Image that can then be filled but I assume you already have a buffer that it should use, so 'setImage' would be enough. osg::Image::setImage is designed to allow the user to specify a buffer that osg::Image then uses (and manages, depending on the AllocationMode). When you're passing a buffer allocated by somebody else you may want to use AllocationMode::NO_DELETE, so that osg::Image does not delete/free it. Regarding the RGB vs BGR you only want to change the 'pixelFormat' parameter, not the 'internalTextureFormat'. I would naively expect that either _image-setImage(width, height, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE); or _image-setImage(width, height, 1, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE); would do the trick. Hope this helps, Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org