[osg-users] [3rdparty] osg::image / Create a 3d Image Rectangular !
Hi, I have try to create some 3d image using osg::image, and it seems that when you create an image with width=height=depth the volume created is good, but when I try to create an image with width!=hieght!= depth , when I fill the image with unsigned char* data, the pixel is not at the right place ! Is there a trick to crate a rectangular image 3d or is it impossible ? I try to rescale the image3d but it does nothing either... Thank you! Cheers, Thomas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21747#21747 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [3rdparty] osg::image / Create a 3d Image Rectangular !
(w != h != d) should be no problem. If they are all powers of two, it should definitely work fine. If they are not powers of two, then of course you need to have support for the NPOT extension (or OpenGL version = 2.0). -Paul Thomas Canipel wrote: Hi, I have try to create some 3d image using osg::image, and it seems that when you create an image with width=height=depth the volume created is good, but when I try to create an image with width!=hieght!= depth , when I fill the image with unsigned char* data, the pixel is not at the right place ! Is there a trick to crate a rectangular image 3d or is it impossible ? I try to rescale the image3d but it does nothing either... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [3rdparty] osg::image / Create a 3d image
Hi Thomas, On 16/12/09 3:23 AM, Thomas Canipel wrote: //creation of the data int height=100; int width=100; int length=100; const long size = width*height*length; For RGB this needs to be (w*h*l)*3, ie. number-of-pixels * channels-per-pixel. unsigned short* data = (unsigned short*)calloc(size, sizeof(unsigned short)); for(long i=0; i size ; i+= 3) { data[i]=255;//red data[i+1]=0;//green data[i+2]=0;//blue } For unsigned short the maximum is 2^16-1 ie. 65535, not 255. // declaration and allocation of the 3d image (size : 100,100,100) osg::ref_ptrosg::Image image = new osg::Image; image-allocateImage(width, height, length, GL_RGB, GL_UNSIGNED_SHORT); image-setOrigin(osg::Image::BOTTOM_LEFT); image-setImage(width, height, length,GL_RGB,GL_RGB,GL_UNSIGNED_SHORT, (unsigned char*)data,osg::Image::NO_DELETE); I don't believe the 'allocateImage' call is necessary, 'setImage' will overwrite that. HTH, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [3rdparty] osg::image / Create a 3d image
yes the allocate Image is not necessary it is override by the setImage(), I was missing the size of the channel ;) Thank you! Cheers, Thomas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21588#21588 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [3rdparty] osg::image / Create a 3d image
In order to use a limit of 255, I needed to use GL_UNSIGNED_BYTE (char) Code: int height=100; int width=100; int length=100; const long size = width*height*length*3; unsigned char* data = (unsigned char*)calloc(size,sizeof(unsigned char)); for(long i=0; i size ; i+= 3) { data[i] = 255;//red data[i+1] = 0;//green data[i+2] = 0;//blue } osg::ref_ptrosg::Image image = new osg::Image; image-allocateImage(width, height, length, GL_RGB, GL_UNSIGNED_BYTE); image-setOrigin(osg::Image::BOTTOM_LEFT);//start countingpixels on the Bottom left of the picture image-setImage(width, height, length , GL_RGB, GL_RGB, GL_UNSIGNED_BYTE,data, osg::Image::NO_DELETE); osgDB::writeImageFile(*image, test.jpg); -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21589#21589 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [3rdparty] osg::image / Create a 3d image
Hi, With osg::image normally you can setup a 3d image , but there is a problem for the length someone know what is wrong with these declaration : I want to create an image of 100x100x100 Code: //creation of the data int height=100; int width=100; int length=100; const long size = width*height*length; unsigned short* data = (unsigned short*)calloc(size, sizeof(unsigned short)); for(long i=0; i size ; i+= 3) { data[i]=255;//red data[i+1]=0;//green data[i+2]=0;//blue } // declaration and allocation of the 3d image (size : 100,100,100) osg::ref_ptrosg::Image image = new osg::Image; image-allocateImage(width, height, length, GL_RGB, GL_UNSIGNED_SHORT); image-setOrigin(osg::Image::BOTTOM_LEFT); image-setImage(width, height, length,GL_RGB,GL_RGB,GL_UNSIGNED_SHORT, (unsigned char*)data,osg::Image::NO_DELETE); Thank you! Cheers, Thomas[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21547#21547 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org