Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps. More...
#include <Image.hpp>
Public Member Functions | |
| Image () | |
| Image (const String &path) | |
| Image (int x, int y, int z, int bytealign, EImageFormat format, EImageType type) | |
| Note that the image is not allocated. | |
| virtual const char * | className () |
| Returns the name of the class. | |
| virtual | ~Image () |
| Image & | operator= (const Image &other) |
| bool | isCubemap () const |
| bool | isValid () const |
| Returns true if the image has valid width/height/depth, pitch and byte alignment, type/format combination. | |
| EImageDimension | dimension () const |
| void | allocate () |
| void | allocate1D (int x, EImageFormat format, EImageType type) |
| void | allocate2D (int x, int y, int bytealign, EImageFormat format, EImageType type) |
| void | allocate3D (int x, int y, int z, int bytealign, EImageFormat format, EImageType type) |
| void | allocateCubemap (int x, int y, int bytealign, EImageFormat format, EImageType type) |
| void | reset (int x, int y, int z, int bytealign, EImageFormat format, EImageType type, bool is_cubemap) |
| void | clear () |
| int | byteAlignment () const |
| Returns the byte-alignment of the row of the image. | |
| void | setByteAlignment (int bytealign) |
| Modifies the byte-alignment of the rows of the image, thus changing its pitch. | |
| int | bitsPerPixel () const |
| int | requiredMemory () const |
| Returns the number of bytes requested to store the image. | |
| String | print () const |
| String | printType () const |
| String | printFormat () const |
| void | setWidth (int x) |
| void | setHeight (int y) |
| void | setDepth (int z) |
| void | setFormat (EImageFormat format) |
| void | setType (EImageType type) |
| KeyValues * | tags () const |
| A set of key/value couples that can be used to attach extra information to an image like DICOM information etc. | |
| void | setTags (KeyValues *tags) |
| A set of key/value couples that can be used to attach extra information to an image like DICOM information etc. | |
| void | setImageBuffer (Buffer *buffer) |
| The buffer used to store the image pixels. | |
| Buffer * | imageBuffer () |
| The buffer used to store the image pixels. | |
| const Buffer * | imageBuffer () const |
| The buffer used to store the image pixels. | |
| const unsigned char * | pixels () const |
| unsigned char * | pixels () |
| bool | empty () |
| unsigned char * | pixelsZSlice (int slice) |
| Returns the pixels of the specified Z slice of a 3D image. | |
| unsigned char * | pixelsXP () |
| unsigned char * | pixelsXN () |
| unsigned char * | pixelsYP () |
| unsigned char * | pixelsYN () |
| unsigned char * | pixelsZP () |
| unsigned char * | pixelsZN () |
| void | setMipmaps (const std::vector< ref< Image > > &mipmaps) |
| const std::vector< ref< Image > > & | mipmaps () const |
| void | clearMipmaps () |
| int | width () const |
| int | height () const |
| int | depth () const |
| int | pitch () const |
| EImageFormat | format () const |
| EImageType | type () const |
| int | alphaBits () const |
| Useful to know if the image format supports alpha or not. | |
| int | isCompressedFormat (EImageFormat fmt) |
| void | flipVertically () |
| ref< Image > | convertType (EImageType new_type) const |
Converts the type() of an image. | |
| ref< Image > | convertFormat (EImageFormat new_format) const |
Converts the format() of an image. | |
| bool | equalize () |
| Equalizes the image. Returns false if the image format() or type() is not supported. This function supports both 3D images and cubemaps. | |
| bool | contrast (float black, float white) |
| Adjusts the contrast of an image. Returns false if the image format() or type() is not supported. This function supports both 3D images and cubemaps. | |
| bool | contrastHounsfieldAuto () |
| Adjusts the contrast of an image using the window-center/window-with method used for CT images. Returns false if the image format() or type() is not supported. This function supports both 3D images and cubemaps. | |
| bool | contrastHounsfield (float center, float width, float intercept, float range) |
| Adjusts the contrast of an image using the window-center/window-with method used for CT images. Returns false if the image format() or type() is not supported. This function supports both 3D images and cubemaps. | |
| fvec4 | sampleLinear (double x) const |
| Performs a sampling on a 1d image using linear filtering. | |
| fvec4 | sampleLinear (double x, double y) const |
| Performs a sampling on a 2d image using bilinear filtering. | |
| fvec4 | sampleLinear (double x, double y, double z) const |
| Performs a sampling on a 3d image using trilinear filtering. | |
| fvec4 | sample (int x, int y=0, int z=0) const |
| Returns the color associated to the specified pixel. | |
| ref< Image > | subImage (int xstart, int ystart, int width, int height) |
| Creates a new image containing the specified rectangular pixel area taken from the source image. | |
| void | copySubImage (Image *img_src, RectI src, ivec2 dst) |
Copies the rectangular area specified by src of img_src into an Image at position dst. | |
| void | substituteColorRGB_RGBA (unsigned int before, unsigned int after) |
| Substitutes the color 'before' with the new color 'after'. | |
| void | substituteColorRGB_RGB (unsigned int before, unsigned int after) |
| Substitutes the color 'before' with the new color 'after'. | |
| void | substituteColorGreenKey (unsigned int col0, unsigned int col1) |
Static Public Member Functions | |
| static int | bitsPerPixel (EImageType type, EImageFormat format) |
| Returns the number of bits used to represents one pixel. | |
| static int | requiredMemory (int x, int y, int z, int bytealign, EImageFormat format, EImageType type, bool is_cubemap) |
| static int | requiredMemory1D (int x, EImageFormat format, EImageType type) |
| static int | requiredMemory2D (int x, int y, int bytealign, EImageFormat format, EImageType type) |
| static int | requiredMemory3D (int x, int y, int z, int bytealign, EImageFormat format, EImageType type) |
| static int | requiredMemoryCubemap (int x, int y, int bytealign, EImageFormat format, EImageType type) |
Protected Member Functions | |
| void | updatePitch () |
Protected Attributes | |
| ref< Buffer > | mPixels |
| ref< KeyValues > | mTags |
| std::vector< ref< Image > > | mMipmaps |
| int | mWidth |
| int | mHeight |
| int | mDepth |
| int | mPitch |
| int | mByteAlign |
| EImageFormat | mFormat |
| EImageType | mType |
| bool | mIsCubemap |
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps.
Definition at line 54 of file Image.hpp.
| Image::Image | ( | ) |
Definition at line 56 of file Image.cpp.
References clear(), mPixels, and VL_DEBUG_SET_OBJECT_NAME.
Referenced by operator=(), and subImage().
| Image::Image | ( | const String & | path ) |
Definition at line 63 of file Image.cpp.
References clear(), vl::loadImage(), mByteAlign, mDepth, mFormat, mHeight, mIsCubemap, mMipmaps, mPitch, mPixels, mType, mWidth, vl::Object::setObjectName(), vl::ref< T >::swap(), vl::String::toStdString(), and VL_DEBUG_SET_OBJECT_NAME.
| Image::Image | ( | int | x, |
| int | y, | ||
| int | z, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type | ||
| ) |
Note that the image is not allocated.
Definition at line 86 of file Image.cpp.
References allocate1D(), allocate2D(), allocate3D(), mPixels, setByteAlignment(), and VL_DEBUG_SET_OBJECT_NAME.
| virtual const char* vl::Image::className | ( | ) | [inline, virtual] |
Definition at line 665 of file Image.cpp.
References Image(), mByteAlign, mDepth, mFormat, mHeight, mIsCubemap, mMipmaps, mPitch, mPixels, mType, mWidth, vl::Object::objectName(), and vl::Object::setObjectName().
| bool vl::Image::isCubemap | ( | ) | const [inline] |
Definition at line 64 of file Image.hpp.
Referenced by contrast(), equalize(), requiredMemory(), vl::saveJPG(), vl::savePNG(), vl::saveTGA(), and vl::saveTIFF().
| bool Image::isValid | ( | ) | const |
Returns true if the image has valid width/height/depth, pitch and byte alignment, type/format combination.
Definition at line 112 of file Image.cpp.
References vl::Log::debug(), format(), vl::IF_BGR, vl::IF_BGRA, vl::IF_COMPRESSED_RGB_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT3, vl::IF_COMPRESSED_RGBA_S3TC_DXT5, vl::IF_DEPTH_STENCIL, vl::IF_RGB, vl::IF_RGBA, vl::IT_BYTE, vl::IT_FLOAT, vl::IT_FLOAT_32_UNSIGNED_INT_24_8_REV, vl::IT_IMPLICIT_TYPE, vl::IT_INT, vl::IT_SHORT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_BYTE_2_3_3_REV, vl::IT_UNSIGNED_BYTE_3_3_2, vl::IT_UNSIGNED_INT, vl::IT_UNSIGNED_INT_10_10_10_2, vl::IT_UNSIGNED_INT_10F_11F_11F_REV, vl::IT_UNSIGNED_INT_24_8, vl::IT_UNSIGNED_INT_2_10_10_10_REV, vl::IT_UNSIGNED_INT_5_9_9_9_REV, vl::IT_UNSIGNED_INT_8_8_8_8, vl::IT_UNSIGNED_INT_8_8_8_8_REV, vl::IT_UNSIGNED_SHORT, vl::IT_UNSIGNED_SHORT_1_5_5_5_REV, vl::IT_UNSIGNED_SHORT_4_4_4_4, vl::IT_UNSIGNED_SHORT_4_4_4_4_REV, vl::IT_UNSIGNED_SHORT_5_5_5_1, vl::IT_UNSIGNED_SHORT_5_6_5, vl::IT_UNSIGNED_SHORT_5_6_5_REV, mByteAlign, mDepth, mHeight, mWidth, pitch(), print(), and type().
Referenced by vl::DrawPixels::render_Implementation(), requiredMemory(), and vl::Texture::Texture().
| EImageDimension Image::dimension | ( | ) | const |
Definition at line 349 of file Image.cpp.
References vl::ID_1D, vl::ID_2D, vl::ID_3D, vl::ID_Cubemap, vl::ID_Error, mDepth, mHeight, mIsCubemap, and mWidth.
Referenced by flipVertically(), pixelsXN(), pixelsXP(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), vl::readPixels(), vl::saveDICOM(), vl::Texture::setMipLevel(), and vl::Texture::Texture().
| void Image::allocate | ( | ) |
Definition at line 576 of file Image.cpp.
References mMipmaps, mPixels, and requiredMemory().
| void Image::allocate1D | ( | int | x, |
| EImageFormat | format, | ||
| EImageType | type | ||
| ) |
Definition at line 582 of file Image.cpp.
References clear(), mIsCubemap, mPixels, requiredMemory(), setByteAlignment(), setDepth(), setFormat(), setHeight(), setType(), setWidth(), and VL_CHECK.
Referenced by Image().
| void Image::allocate2D | ( | int | x, |
| int | y, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type | ||
| ) |
Definition at line 598 of file Image.cpp.
References vl::Log::bug(), clear(), mIsCubemap, mPixels, requiredMemory(), setByteAlignment(), setDepth(), setFormat(), setHeight(), setType(), setWidth(), and VL_CHECK.
Referenced by Image(), and vl::readPixels().
| void Image::allocate3D | ( | int | x, |
| int | y, | ||
| int | z, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type | ||
| ) |
Definition at line 619 of file Image.cpp.
References clear(), mIsCubemap, mPixels, requiredMemory(), setByteAlignment(), setDepth(), setFormat(), setHeight(), setType(), setWidth(), and VL_CHECK.
Referenced by Image().
| void Image::allocateCubemap | ( | int | x, |
| int | y, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type | ||
| ) |
Definition at line 560 of file Image.cpp.
References clear(), mIsCubemap, mPixels, requiredMemory(), setByteAlignment(), setDepth(), setFormat(), setHeight(), setType(), and setWidth().
| void Image::reset | ( | int | x, |
| int | y, | ||
| int | z, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type, | ||
| bool | is_cubemap | ||
| ) |
Definition at line 637 of file Image.cpp.
References clear(), mIsCubemap, setByteAlignment(), setDepth(), setFormat(), setHeight(), setType(), and setWidth().
Referenced by vl::readPixels().
| void Image::clear | ( | ) |
Definition at line 650 of file Image.cpp.
References vl::IF_RGBA, vl::IT_UNSIGNED_BYTE, mByteAlign, mDepth, mFormat, mHeight, mIsCubemap, mMipmaps, vl::Object::mObjectName, mPitch, mPixels, mType, and mWidth.
Referenced by allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), Image(), reset(), and ~Image().
| int Image::byteAlignment | ( | ) | const |
Returns the byte-alignment of the row of the image.
Possible return values are 1, 2, 4 and 8.
Definition at line 516 of file Image.cpp.
References mByteAlign.
Referenced by pixelsXN(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), print(), vl::DrawPixels::render_Implementation(), requiredMemory(), and vl::Texture::setMipLevel().
| void Image::setByteAlignment | ( | int | bytealign ) |
Modifies the byte-alignment of the rows of the image, thus changing its pitch.
Only values like 0, 1, 2, 4 and 8 are allowed. If 0 is passed the byte-alignment takes the value returned by "sizeof(unsigned char*)".
Definition at line 526 of file Image.cpp.
References mByteAlign, mPixels, updatePitch(), VL_CHECK, and VL_TRAP.
Referenced by allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), Image(), and reset().
| int Image::bitsPerPixel | ( | EImageType | type, |
| EImageFormat | format | ||
| ) | [static] |
Returns the number of bits used to represents one pixel.
Definition at line 359 of file Image.cpp.
References vl::IF_ALPHA, vl::IF_BGR, vl::IF_BGRA, vl::IF_BLUE, vl::IF_COMPRESSED_RGB_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT3, vl::IF_COMPRESSED_RGBA_S3TC_DXT5, vl::IF_DEPTH_COMPONENT, vl::IF_DEPTH_STENCIL, vl::IF_GREEN, vl::IF_LUMINANCE, vl::IF_LUMINANCE_ALPHA, vl::IF_RED, vl::IF_RGB, vl::IF_RGBA, vl::IF_STENCIL_INDEX, vl::IT_BYTE, vl::IT_FLOAT, vl::IT_FLOAT_32_UNSIGNED_INT_24_8_REV, vl::IT_INT, vl::IT_SHORT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_BYTE_2_3_3_REV, vl::IT_UNSIGNED_BYTE_3_3_2, vl::IT_UNSIGNED_INT, vl::IT_UNSIGNED_INT_10_10_10_2, vl::IT_UNSIGNED_INT_10F_11F_11F_REV, vl::IT_UNSIGNED_INT_24_8, vl::IT_UNSIGNED_INT_2_10_10_10_REV, vl::IT_UNSIGNED_INT_5_9_9_9_REV, vl::IT_UNSIGNED_INT_8_8_8_8, vl::IT_UNSIGNED_INT_8_8_8_8_REV, vl::IT_UNSIGNED_SHORT, vl::IT_UNSIGNED_SHORT_1_5_5_5_REV, vl::IT_UNSIGNED_SHORT_4_4_4_4, vl::IT_UNSIGNED_SHORT_4_4_4_4_REV, vl::IT_UNSIGNED_SHORT_5_5_5_1, vl::IT_UNSIGNED_SHORT_5_6_5, vl::IT_UNSIGNED_SHORT_5_6_5_REV, and VL_TRAP.
Referenced by vl::saveTIFF().
| int vl::Image::bitsPerPixel | ( | ) | const [inline] |
Definition at line 78 of file Image.hpp.
References bitsPerPixel().
Referenced by bitsPerPixel(), copySubImage(), requiredMemory(), subImage(), and updatePitch().
| int Image::requiredMemory | ( | ) | const |
Returns the number of bytes requested to store the image.
Doesn't take into consideration mipmaps.
Definition at line 508 of file Image.cpp.
References byteAlignment(), depth(), format(), height(), isCubemap(), isValid(), type(), VL_CHECK, and width().
Referenced by allocate(), allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), vl::createCubemap(), vl::loadDDS(), vl::saveTGA(), vl::saveTIFF(), and vl::Texture::setMipLevel().
| int Image::requiredMemory | ( | int | x, |
| int | y, | ||
| int | z, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type, | ||
| bool | is_cubemap | ||
| ) | [static] |
Definition at line 912 of file Image.cpp.
References bitsPerPixel(), depth(), vl::IF_COMPRESSED_RGB_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT3, vl::IF_COMPRESSED_RGBA_S3TC_DXT5, and pitch().
| static int vl::Image::requiredMemory1D | ( | int | x, |
| EImageFormat | format, | ||
| EImageType | type | ||
| ) | [inline, static] |
| static int vl::Image::requiredMemory2D | ( | int | x, |
| int | y, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type | ||
| ) | [inline, static] |
Definition at line 82 of file Image.hpp.
Referenced by pixelsXN(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), and vl::readPixels().
| static int vl::Image::requiredMemory3D | ( | int | x, |
| int | y, | ||
| int | z, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type | ||
| ) | [inline, static] |
| static int vl::Image::requiredMemoryCubemap | ( | int | x, |
| int | y, | ||
| int | bytealign, | ||
| EImageFormat | format, | ||
| EImageType | type | ||
| ) | [inline, static] |
| String Image::print | ( | ) | const |
Definition at line 327 of file Image.cpp.
References byteAlignment(), depth(), height(), vl::Object::objectName(), pitch(), printFormat(), printType(), and width().
Referenced by isValid().
| String Image::printType | ( | ) | const |
Definition at line 266 of file Image.cpp.
References vl::IT_BYTE, vl::IT_FLOAT, vl::IT_FLOAT_32_UNSIGNED_INT_24_8_REV, vl::IT_IMPLICIT_TYPE, vl::IT_INT, vl::IT_SHORT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_BYTE_2_3_3_REV, vl::IT_UNSIGNED_BYTE_3_3_2, vl::IT_UNSIGNED_INT, vl::IT_UNSIGNED_INT_10_10_10_2, vl::IT_UNSIGNED_INT_10F_11F_11F_REV, vl::IT_UNSIGNED_INT_24_8, vl::IT_UNSIGNED_INT_2_10_10_10_REV, vl::IT_UNSIGNED_INT_5_9_9_9_REV, vl::IT_UNSIGNED_INT_8_8_8_8, vl::IT_UNSIGNED_INT_8_8_8_8_REV, vl::IT_UNSIGNED_SHORT, vl::IT_UNSIGNED_SHORT_1_5_5_5_REV, vl::IT_UNSIGNED_SHORT_4_4_4_4, vl::IT_UNSIGNED_SHORT_4_4_4_4_REV, vl::IT_UNSIGNED_SHORT_5_5_5_1, vl::IT_UNSIGNED_SHORT_5_6_5, vl::IT_UNSIGNED_SHORT_5_6_5_REV, type(), and VL_CHECK.
Referenced by print().
| String Image::printFormat | ( | ) | const |
Definition at line 300 of file Image.cpp.
References format(), vl::IF_ALPHA, vl::IF_BGR, vl::IF_BGRA, vl::IF_BLUE, vl::IF_COMPRESSED_RGB_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT3, vl::IF_COMPRESSED_RGBA_S3TC_DXT5, vl::IF_DEPTH_COMPONENT, vl::IF_DEPTH_STENCIL, vl::IF_GREEN, vl::IF_LUMINANCE, vl::IF_LUMINANCE_ALPHA, vl::IF_RED, vl::IF_RGB, vl::IF_RGBA, vl::IF_STENCIL_INDEX, and VL_CHECK.
Referenced by print().
| void vl::Image::setWidth | ( | int | x ) | [inline] |
Definition at line 89 of file Image.hpp.
Referenced by allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), and reset().
| void vl::Image::setHeight | ( | int | y ) | [inline] |
Definition at line 90 of file Image.hpp.
Referenced by allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), and reset().
| void vl::Image::setDepth | ( | int | z ) | [inline] |
Definition at line 91 of file Image.hpp.
Referenced by allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), and reset().
| void vl::Image::setFormat | ( | EImageFormat | format ) | [inline] |
Definition at line 92 of file Image.hpp.
Referenced by allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), and reset().
| void vl::Image::setType | ( | EImageType | type ) | [inline] |
Definition at line 93 of file Image.hpp.
Referenced by allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), and reset().
| KeyValues* vl::Image::tags | ( | ) | const [inline] |
A set of key/value couples that can be used to attach extra information to an image like DICOM information etc.
Returns NULL by default.
Definition at line 97 of file Image.hpp.
Referenced by contrastHounsfieldAuto().
| void vl::Image::setTags | ( | KeyValues * | tags ) | [inline] |
| void vl::Image::setImageBuffer | ( | Buffer * | buffer ) | [inline] |
| Buffer* vl::Image::imageBuffer | ( | ) | [inline] |
The buffer used to store the image pixels.
Definition at line 106 of file Image.hpp.
Referenced by vl::readPixels().
| const Buffer* vl::Image::imageBuffer | ( | ) | const [inline] |
| const unsigned char* vl::Image::pixels | ( | ) | const [inline] |
Definition at line 111 of file Image.hpp.
Referenced by contrast(), copySubImage(), vl::createCubemap(), equalize(), flipVertically(), pixelsXN(), pixelsXP(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), pixelsZSlice(), vl::readPixels(), vl::DrawPixels::render_Implementation(), sample(), vl::saveJPG(), vl::savePNG(), vl::saveTGA(), vl::saveTIFF(), vl::Texture::setMipLevel(), subImage(), substituteColorGreenKey(), substituteColorRGB_RGB(), and substituteColorRGB_RGBA().
| unsigned char * Image::pixelsZSlice | ( | int | slice ) |
Returns the pixels of the specified Z slice of a 3D image.
Definition at line 771 of file Image.cpp.
References depth(), height(), mIsCubemap, pitch(), pixels(), and VL_CHECK.
Referenced by flipVertically().
| unsigned char * Image::pixelsXP | ( | ) |
Definition at line 692 of file Image.cpp.
References dimension(), pixels(), and VL_TRAP.
Referenced by flipVertically(), and vl::Texture::setMipLevel().
| unsigned char * Image::pixelsXN | ( | ) |
Definition at line 705 of file Image.cpp.
References byteAlignment(), dimension(), format(), height(), pixels(), requiredMemory2D(), type(), VL_TRAP, and width().
Referenced by flipVertically(), and vl::Texture::setMipLevel().
| unsigned char * Image::pixelsYP | ( | ) |
Definition at line 718 of file Image.cpp.
References byteAlignment(), dimension(), format(), height(), pixels(), requiredMemory2D(), type(), VL_TRAP, and width().
Referenced by flipVertically(), and vl::Texture::setMipLevel().
| unsigned char * Image::pixelsYN | ( | ) |
Definition at line 731 of file Image.cpp.
References byteAlignment(), dimension(), format(), height(), pixels(), requiredMemory2D(), type(), VL_TRAP, and width().
Referenced by flipVertically(), and vl::Texture::setMipLevel().
| unsigned char * Image::pixelsZP | ( | ) |
Definition at line 744 of file Image.cpp.
References byteAlignment(), dimension(), format(), height(), pixels(), requiredMemory2D(), type(), VL_TRAP, and width().
Referenced by flipVertically(), and vl::Texture::setMipLevel().
| unsigned char * Image::pixelsZN | ( | ) |
Definition at line 757 of file Image.cpp.
References byteAlignment(), dimension(), format(), height(), pixels(), requiredMemory2D(), type(), VL_TRAP, and width().
Referenced by flipVertically(), and vl::Texture::setMipLevel().
| int vl::Image::width | ( | ) | const [inline] |
Definition at line 124 of file Image.hpp.
Referenced by contrast(), copySubImage(), equalize(), vl::genGradientNormals(), vl::DrawPixels::Pixels::Pixels(), pixelsXN(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), print(), vl::readPixels(), vl::DrawPixels::render_Implementation(), requiredMemory(), sample(), sampleLinear(), vl::saveJPG(), vl::savePNG(), vl::saveTGA(), vl::saveTIFF(), vl::Texture::setMipLevel(), vl::VectorGraphics::setPoint(), subImage(), substituteColorGreenKey(), substituteColorRGB_RGB(), and substituteColorRGB_RGBA().
| int vl::Image::height | ( | ) | const [inline] |
Definition at line 125 of file Image.hpp.
Referenced by contrast(), copySubImage(), equalize(), flipVertically(), vl::genGradientNormals(), vl::DrawPixels::Pixels::Pixels(), pixelsXN(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), pixelsZSlice(), print(), vl::readPixels(), requiredMemory(), sample(), sampleLinear(), vl::saveJPG(), vl::savePNG(), vl::saveTGA(), vl::saveTIFF(), vl::Texture::setMipLevel(), subImage(), substituteColorGreenKey(), substituteColorRGB_RGB(), and substituteColorRGB_RGBA().
| int vl::Image::depth | ( | ) | const [inline] |
Definition at line 126 of file Image.hpp.
Referenced by contrast(), equalize(), flipVertically(), vl::genGradientNormals(), pixelsZSlice(), print(), requiredMemory(), sample(), sampleLinear(), vl::saveJPG(), vl::savePNG(), vl::saveTGA(), vl::saveTIFF(), vl::Texture::setMipLevel(), substituteColorGreenKey(), substituteColorRGB_RGB(), and substituteColorRGB_RGBA().
| int vl::Image::pitch | ( | ) | const [inline] |
Definition at line 127 of file Image.hpp.
Referenced by contrast(), copySubImage(), equalize(), flipVertically(), isValid(), pixelsZSlice(), print(), requiredMemory(), sample(), vl::savePNG(), vl::saveTIFF(), subImage(), substituteColorGreenKey(), substituteColorRGB_RGB(), and substituteColorRGB_RGBA().
| EImageFormat vl::Image::format | ( | ) | const [inline] |
Definition at line 128 of file Image.hpp.
Referenced by alphaBits(), contrast(), copySubImage(), equalize(), isValid(), pixelsXN(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), printFormat(), vl::readPixels(), vl::DrawPixels::render_Implementation(), requiredMemory(), sample(), vl::saveJPG(), vl::savePNG(), vl::saveTGA(), vl::saveTIFF(), vl::Texture::setMipLevel(), subImage(), substituteColorGreenKey(), substituteColorRGB_RGB(), and substituteColorRGB_RGBA().
| EImageType vl::Image::type | ( | ) | const [inline] |
Definition at line 129 of file Image.hpp.
Referenced by alphaBits(), contrast(), copySubImage(), equalize(), vl::genRGBAVolume(), isValid(), pixelsXN(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), printType(), vl::readPixels(), vl::DrawPixels::render_Implementation(), requiredMemory(), sample(), vl::saveJPG(), vl::savePNG(), vl::saveTGA(), vl::saveTIFF(), vl::Texture::setMipLevel(), subImage(), substituteColorGreenKey(), substituteColorRGB_RGB(), and substituteColorRGB_RGBA().
| int Image::alphaBits | ( | ) | const |
Useful to know if the image format supports alpha or not.
Definition at line 425 of file Image.cpp.
References format(), vl::IF_ALPHA, vl::IF_BGR, vl::IF_BGRA, vl::IF_BLUE, vl::IF_COMPRESSED_RGB_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT3, vl::IF_COMPRESSED_RGBA_S3TC_DXT5, vl::IF_DEPTH_COMPONENT, vl::IF_DEPTH_STENCIL, vl::IF_GREEN, vl::IF_LUMINANCE, vl::IF_LUMINANCE_ALPHA, vl::IF_RED, vl::IF_RGB, vl::IF_RGBA, vl::IF_STENCIL_INDEX, vl::IT_BYTE, vl::IT_FLOAT, vl::IT_FLOAT_32_UNSIGNED_INT_24_8_REV, vl::IT_INT, vl::IT_SHORT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_BYTE_2_3_3_REV, vl::IT_UNSIGNED_BYTE_3_3_2, vl::IT_UNSIGNED_INT, vl::IT_UNSIGNED_INT_10_10_10_2, vl::IT_UNSIGNED_INT_10F_11F_11F_REV, vl::IT_UNSIGNED_INT_24_8, vl::IT_UNSIGNED_INT_2_10_10_10_REV, vl::IT_UNSIGNED_INT_5_9_9_9_REV, vl::IT_UNSIGNED_INT_8_8_8_8, vl::IT_UNSIGNED_INT_8_8_8_8_REV, vl::IT_UNSIGNED_SHORT, vl::IT_UNSIGNED_SHORT_1_5_5_5_REV, vl::IT_UNSIGNED_SHORT_4_4_4_4, vl::IT_UNSIGNED_SHORT_4_4_4_4_REV, vl::IT_UNSIGNED_SHORT_5_5_5_1, vl::IT_UNSIGNED_SHORT_5_6_5, vl::IT_UNSIGNED_SHORT_5_6_5_REV, type(), and VL_TRAP.
| int Image::isCompressedFormat | ( | EImageFormat | fmt ) |
Definition at line 491 of file Image.cpp.
References vl::IF_COMPRESSED_RGB_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT1, vl::IF_COMPRESSED_RGBA_S3TC_DXT3, and vl::IF_COMPRESSED_RGBA_S3TC_DXT5.
| void Image::flipVertically | ( | ) |
Definition at line 867 of file Image.cpp.
References depth(), dimension(), height(), vl::ID_1D, vl::ID_2D, vl::ID_3D, vl::ID_Cubemap, pitch(), pixels(), pixelsXN(), pixelsXP(), pixelsYN(), pixelsYP(), pixelsZN(), pixelsZP(), pixelsZSlice(), and VL_CHECK.
| ref< Image > vl::Image::convertType | ( | EImageType | new_type ) | const |
Converts the type() of an image.
The source image type and the new type must be one of the following:
The source image format must be one of the following:
Definition at line 1219 of file Image.cpp.
References vl::Log::error(), vl::IF_ALPHA, vl::IF_BGR, vl::IF_BGRA, vl::IF_BLUE, vl::IF_DEPTH_COMPONENT, vl::IF_GREEN, vl::IF_LUMINANCE, vl::IF_LUMINANCE_ALPHA, vl::IF_RED, vl::IF_RGB, vl::IF_RGBA, vl::IT_BYTE, vl::IT_FLOAT, vl::IT_INT, vl::IT_SHORT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_INT, and vl::IT_UNSIGNED_SHORT.
Referenced by vl::saveJPG(), vl::savePNG(), vl::saveTGA(), and vl::saveTIFF().
| ref< Image > vl::Image::convertFormat | ( | EImageFormat | new_format ) | const |
Converts the format() of an image.
The source image type must be one of the following:
The source image format and the new format must be one of the following:
Definition at line 1633 of file Image.cpp.
References vl::Log::error(), vl::IF_ALPHA, vl::IF_BGR, vl::IF_BGRA, vl::IF_BLUE, vl::IF_DEPTH_COMPONENT, vl::IF_GREEN, vl::IF_LUMINANCE, vl::IF_LUMINANCE_ALPHA, vl::IF_RED, vl::IF_RGB, vl::IF_RGBA, vl::IT_BYTE, vl::IT_FLOAT, vl::IT_INT, vl::IT_SHORT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_INT, and vl::IT_UNSIGNED_SHORT.
Referenced by vl::saveJPG(), vl::savePNG(), vl::saveTGA(), and vl::saveTIFF().
| bool Image::equalize | ( | ) |
Equalizes the image. Returns false if the image format() or type() is not supported. This function supports both 3D images and cubemaps.
This function is mainly useful for images whose type() is IF_LUMINANCE, IF_RED, IF_GREEN, IF_BLUE, IF_ALPHA or IF_DEPTH_COMPONENT.
IF_RGB, IF_RGBA, IF_BGR, IF_BGRA and IF_LUMINANCE_ALPHA types are not optimally handled yet.
Definition at line 1409 of file Image.cpp.
References depth(), vl::Log::error(), format(), height(), vl::IF_ALPHA, vl::IF_BGR, vl::IF_BGRA, vl::IF_BLUE, vl::IF_DEPTH_COMPONENT, vl::IF_GREEN, vl::IF_LUMINANCE, vl::IF_LUMINANCE_ALPHA, vl::IF_RED, vl::IF_RGB, vl::IF_RGBA, isCubemap(), vl::IT_FLOAT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_INT, vl::IT_UNSIGNED_SHORT, pitch(), pixels(), type(), and width().
| bool Image::contrast | ( | float | black, |
| float | white | ||
| ) |
Adjusts the contrast of an image. Returns false if the image format() or type() is not supported. This function supports both 3D images and cubemaps.
This function supports only images whose type() is IF_LUMINANCE, IF_RED, IF_GREEN, IF_BLUE, IF_ALPHA or IF_DEPTH_COMPONENT.
The parameters black and white are in normalized units (0=black, 1=white) but are not required to be in the range between 0 and 1.
Definition at line 1528 of file Image.cpp.
References depth(), vl::Log::error(), format(), height(), vl::IF_ALPHA, vl::IF_BLUE, vl::IF_DEPTH_COMPONENT, vl::IF_GREEN, vl::IF_LUMINANCE, vl::IF_RED, isCubemap(), vl::IT_FLOAT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_INT, vl::IT_UNSIGNED_SHORT, pitch(), pixels(), type(), and width().
Referenced by contrastHounsfield(), and contrastHounsfieldAuto().
| bool Image::contrastHounsfieldAuto | ( | ) |
Adjusts the contrast of an image using the window-center/window-with method used for CT images. Returns false if the image format() or type() is not supported. This function supports both 3D images and cubemaps.
The center and width parameters are in Hounsfield units.
Calls contrastHounsfield(float center, float width, float intercept, float range) with center, with, range and intercept parameters extracted from the image tags() "WindowCenter", "WindowWidth", "BitsStored" and "RescaleIntercept". This function is equivalent to the code below.
if ( !tags()->has("WindowCenter") || !tags()->has("WindowWidth") || !tags()->has("BitsStored") || !tags()->has("RescaleIntercept")) return false; float center = tags()->value("WindowCenter").toFloat(); float width = tags()->value("WindowWidth").toFloat(); float range = (1<<tags()->value("BitsStored").toInt()) - 1.0f; float intercept = tags()->value("RescaleIntercept").toFloat(); // Hounsfield units: -1000 = air, +1000 = solid bone // Transform from Hounsfield units to normalized 0..1 units center = (center-intercept) / range; width = width / range; return contrast( center-width/2.0f, center+width/2.0f );
Definition at line 1471 of file Image.cpp.
References contrast(), tags(), vl::String::toFloat(), vl::String::toInt(), and vl::KeyValues::value().
| bool Image::contrastHounsfield | ( | float | center, |
| float | width, | ||
| float | intercept, | ||
| float | range | ||
| ) |
Adjusts the contrast of an image using the window-center/window-with method used for CT images. Returns false if the image format() or type() is not supported. This function supports both 3D images and cubemaps.
The center and width parameters are in Hounsfield units.
This function is equivalent to the code below:
// Hounsfield units: -1000 = air, +1000 = solid bone // Transform from Hounsfield units to normalized 0..1 units center = (center-intercept) / range; width = width / range; return contrast( center-width/2.0f, center+width/2.0f );
Definition at line 1499 of file Image.cpp.
References contrast().
| fvec4 Image::sampleLinear | ( | double | x ) | const |
| fvec4 Image::sampleLinear | ( | double | x, |
| double | y | ||
| ) | const |
| fvec4 Image::sampleLinear | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) | const |
| fvec4 Image::sample | ( | int | x, |
| int | y = 0, |
||
| int | z = 0 |
||
| ) | const |
Returns the color associated to the specified pixel.
The rgb values are mapped to 0..1 for all image types but IT_FLOAT. The value returned for images of type IT_FLOAT is returned exactly as is stored in the image.
The image type() must be one of the following:
The image format() must be one of the following:
Definition at line 1910 of file Image.cpp.
References vl::Vector4< T_Scalar >::b(), depth(), format(), height(), vl::IF_ALPHA, vl::IF_BGR, vl::IF_BGRA, vl::IF_BLUE, vl::IF_DEPTH_COMPONENT, vl::IF_GREEN, vl::IF_LUMINANCE, vl::IF_LUMINANCE_ALPHA, vl::IF_RED, vl::IF_RGB, vl::IF_RGBA, vl::IT_BYTE, vl::IT_FLOAT, vl::IT_INT, vl::IT_SHORT, vl::IT_UNSIGNED_BYTE, vl::IT_UNSIGNED_INT, vl::IT_UNSIGNED_SHORT, pitch(), pixels(), vl::Vector4< T_Scalar >::r(), type(), VL_CHECK, and width().
Referenced by vl::genGradientNormals(), and sampleLinear().
Creates a new image containing the specified rectangular pixel area taken from the source image.
The returned image is of the same type() and format() of the original one.
Definition at line 1998 of file Image.cpp.
References bitsPerPixel(), format(), height(), Image(), pitch(), pixels(), type(), VL_CHECK, and width().
Copies the rectangular area specified by src of img_src into an Image at position dst.
The source and destination image should be of the same type() and format() for maximum performances.
Definition at line 2015 of file Image.cpp.
References bitsPerPixel(), format(), height(), vl::Rect< T >::height(), pitch(), pixels(), vl::RectI::right(), vl::RectI::top(), type(), VL_CHECK, width(), vl::Rect< T >::width(), vl::Rect< T >::x(), vl::Vector2< T_Scalar >::x(), vl::Rect< T >::y(), and vl::Vector2< T_Scalar >::y().
| void Image::substituteColorRGB_RGBA | ( | unsigned int | before, |
| unsigned int | after | ||
| ) |
Substitutes the color 'before' with the new color 'after'.
| before | is an hexadecimal representation of an RGB triplet given in the form 0xRRGGBB. |
| after | is an hexadecimal representation of an RGBA quadruplet given in the form 0xRRGGBBAA. For example 0xFF0000FF is opaque red, 0x00FF0088 is half transparent green. This function can be very useful when you want to modify a specified color of an image or when you want to perform color-key transparency, i.e. when you want to set the transparency of the pixels that have a particular color. |
Definition at line 2041 of file Image.cpp.
References depth(), vl::Log::error(), format(), height(), vl::IF_RGB, vl::IF_RGBA, vl::IT_UNSIGNED_BYTE, pitch(), pixels(), type(), and width().
| void Image::substituteColorRGB_RGB | ( | unsigned int | before, |
| unsigned int | after | ||
| ) |
Substitutes the color 'before' with the new color 'after'.
| before | is an hexadecimal representation of an RGB triplet given in the form 0xRRGGBB. |
| after | is an hexadecimal representation of an RGB tripet given in the form 0xRRGGBB. For example 0xFF0000 is opaque red, 0x00FF00 is green. This function can be very useful when you want to modify a specified color of an image but you want to keep the alpha channel intact. |
Definition at line 2083 of file Image.cpp.
References depth(), vl::Log::error(), format(), height(), vl::IF_RGB, vl::IF_RGBA, vl::IT_UNSIGNED_BYTE, pitch(), pixels(), type(), and width().
| void Image::substituteColorGreenKey | ( | unsigned int | col0, |
| unsigned int | col1 | ||
| ) |
Definition at line 2122 of file Image.cpp.
References depth(), vl::Log::error(), format(), height(), vl::IF_RGB, vl::IF_RGBA, vl::IT_UNSIGNED_BYTE, pitch(), pixels(), type(), and width().
| void Image::updatePitch | ( | ) | [protected] |
Definition at line 553 of file Image.cpp.
References bitsPerPixel(), mByteAlign, mPitch, and mWidth.
Referenced by setByteAlignment().
ref<Buffer> vl::Image::mPixels [protected] |
Definition at line 287 of file Image.hpp.
Referenced by allocate(), allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), clear(), Image(), operator=(), and setByteAlignment().
ref<KeyValues> vl::Image::mTags [protected] |
std::vector< ref<Image> > vl::Image::mMipmaps [protected] |
Definition at line 290 of file Image.hpp.
Referenced by allocate(), clear(), Image(), and operator=().
int vl::Image::mWidth [protected] |
Definition at line 291 of file Image.hpp.
Referenced by clear(), dimension(), Image(), isValid(), operator=(), and updatePitch().
int vl::Image::mHeight [protected] |
Definition at line 292 of file Image.hpp.
Referenced by clear(), dimension(), Image(), isValid(), and operator=().
int vl::Image::mDepth [protected] |
Definition at line 293 of file Image.hpp.
Referenced by clear(), dimension(), Image(), isValid(), and operator=().
int vl::Image::mPitch [protected] |
Definition at line 294 of file Image.hpp.
Referenced by clear(), Image(), operator=(), and updatePitch().
int vl::Image::mByteAlign [protected] |
Definition at line 295 of file Image.hpp.
Referenced by byteAlignment(), clear(), Image(), isValid(), operator=(), setByteAlignment(), and updatePitch().
EImageFormat vl::Image::mFormat [protected] |
Definition at line 296 of file Image.hpp.
Referenced by clear(), Image(), and operator=().
EImageType vl::Image::mType [protected] |
Definition at line 297 of file Image.hpp.
Referenced by clear(), Image(), and operator=().
bool vl::Image::mIsCubemap [protected] |
Definition at line 298 of file Image.hpp.
Referenced by allocate1D(), allocate2D(), allocate3D(), allocateCubemap(), clear(), dimension(), Image(), operator=(), pixelsZSlice(), and reset().