Hi Otto,

On Mon, Sep 28, 2009 at 9:34 AM, Otto Cologne <[email protected]> wrote:
> Any idea why
>
> Code:
>
> osg::ref_ptr<osg::Image> ima = new osg::Image;
> ima->allocateImage(160, 200, 160, GL_LUMINANCE, GL_UNSIGNED_BYTE);
> std::cout << ima->getImageSizeInBytes() << std::endl;
>
> returns 32000 instead of the expected 5120000?

The osg::Image class has a series of methods for getting the size of the image:

        /** Return the number of bits required for each pixel. */
        inline unsigned int getPixelSizeInBits() const { return
computePixelSizeInBits(_pixelFormat,_dataType); }

        /** Return the number of bytes each row of pixels occupies
once it has been packed. */
        inline unsigned int getRowSizeInBytes() const { return
computeRowWidthInBytes(_s,_pixelFormat,_dataType,_packing); }

        /** Return the number of bytes each image (_s*_t) of pixels occupies. */
        inline unsigned int getImageSizeInBytes() const { return
getRowSizeInBytes()*_t; }

        /** Return the number of bytes the whole row/image/volume of
pixels occupies. */
        inline unsigned int getTotalSizeInBytes() const { return
getImageSizeInBytes()*_r; }


Each of these in term computes the next dimension up, from a single
pixel to a row, to whole 2d image, to a while 3d image.  In hindsight
the naming could have been chosen better.  For 3D images you'll want
to use getTotalSizeInBytes().

Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to