![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/GlImage.h>
OpenGL texture image. More...
Inheritance diagram for GlImage:OpenGL texture image.
Public Member Functions | |
| GlImage (const ImageDescriptor &desc, int internalFormat=0, const void *data=nullptr) | |
| Creates a new OpenGL image. | |
| GlImage (PixelType type, int width, int height, int slices=1, int channels=1, int internalFormat=0, const void *data=nullptr) | |
| Creates a new OpenGL texture. | |
| GlImage (Image::Type type, int width, int height, int slices=1, int channels=1, int internalFormat=0, const void *data=nullptr) | |
| Creates a new OpenGL texture. | |
| GlImage (std::unique_ptr< GL::Texture > texture) | |
| Creates a GlImage object from an existing OpenGL texture. | |
| GlImage (const MemImage &image) | |
| Creates an OpenGL texture from another image in memory, uploading the image data to the generated texture. | |
| GlImage (const GlImage &image) | |
| Creates a deep copy of the GlImage, with a whole new texture containing the same image data as the original. | |
| GlImage & | operator= (const GlImage &other) |
| The assignment operator will copy all aspects of the other image. | |
| GlImage (GlImage &&other) noexcept | |
| GlImage & | operator= (GlImage &&other) noexcept |
| ~GlImage () override | |
| Releases the OpenGL image resource. | |
| operator GL::Texture & () | |
| operator const GL::Texture & () const | |
| void | bind (int unit=0) const |
| Binds the image to a texture unit. | |
| void | unbind () const |
| Unbinds the image. | |
| bool | resize (int width, int height, int slices) |
| Resize image but keep format and target. | |
| bool | update (const MemImage &image) |
| Updates the image content from memory. | |
| template<typename T> | |
| bool | update (const std::vector< T > &data) |
| Updates the image content from a non-image buffer. Passed buffer has to be at least as large as this image. | |
| template<typename T> | |
| bool | update (const T *data) |
| More generic, less secure version of the buffer update method above. | |
| bool | update (const GlImage &image, GL::Framebuffer *fbo=0) |
| Updates the image content from another GlImage. | |
| bool | update (const GL::Texture &tex, GL::Framebuffer *fbo=0) |
| Updates the image content from another texture. | |
| bool | swapTexID (GlImage &other) |
| Swap the texture ID with another image that has the exact same properties, e.g. | |
| GL::Texture & | texture () |
| const GL::Texture & | texture () const |
| unsigned int | texID () const |
| Access to the OpenGL texture ID. | |
| unsigned int | target () const |
| Returns the OpenGL texture target. | |
| int | format () const |
| Returns the pixel format. | |
| int | internalFormat () const |
| Returns the internal OpenGL texture format. | |
| MemImage * | download (unsigned int type=0) const |
| Downloads the image into memory. | |
| void | download (MemImage &img) const |
| Downloads the image into memory. | |
| Location | location () const override |
| Specifies that the image is an OpenGL texture object. | |
| bool | makeCompatible (GlImage **other, unsigned int type=0, bool use2D=false, int channels=-1) const |
| Creates or updates another image instance to be compatible to this one. | |
| bool | makeCompatible (SharedImage **other, unsigned int type=0, bool use2D=false) const |
| Same as above for a shared image instance. | |
Public Member Functions inherited from Image | |
| Image (const ImageDescriptor &desc) | |
| Create a new Image with the given descriptor. | |
| Image (const Image &other)=default | |
| Image & | operator= (const Image &other)=default |
| Image (Image &&other) noexcept=default | |
| Image & | operator= (Image &&other) noexcept=default |
| const ImageDescriptor & | descriptor () const |
| Return the image descriptor. | |
| void | configure (const Properties *p) override |
| Configure the image descriptor from properties. | |
| void | configuration (Properties *p) const override |
| Store image descriptor into properties. | |
| void | setShift (double val) |
| Sets the intensity shift value. | |
| void | setScale (double val) |
| Sets the intensity scale value. | |
| void | setSpacing (double sx, double sy, double sz=1.0) |
| Specify pixel/voxel spacing with two or three scalar values. | |
| void | setSpacing (double sx, double sy, double sz, bool isMetric) |
| Convenience function for specifying spacing and metric flag at the same time. | |
| void | setSpacing (const vec3 &s) |
| Specify pixel/voxel spacing using a 3-vector. | |
| void | setSpacing (const vec3 &s, bool metric) |
| Convenience function for specifying spacing and metric flag at the same time. | |
| void | setMetric (bool val) |
| Set data to be metric. | |
| double | storageToOriginal (double value) const |
| Applies the image's shift and scale in order to convert value from storage pixel value domain to original pixel value domain. | |
| double | originalToStorage (double value) const |
| Applies the image's shift and scale in order to convert value from original pixel value domain to storage pixel value domain. | |
| PixelType | pixelType () const |
| Returns the data type of the image. | |
| Type | type () const |
| Returns the data type of the image. | |
| int | width () const |
| Returns the width of the image. | |
| int | height () const |
| Returns the height of the image. | |
| int | slices () const |
| Returns the number of 3D slices of the image. | |
| int | channels () const |
| Returns the number of channels of the image. | |
| double | shift () const |
| Returns the intensity shift. | |
| double | scale () const |
| Returns the intensity scale. | |
| vec3 | spacing () const |
| Returns pointer to the pixel/voxel spacing values. | |
| bool | isMetric () const |
| Returns true if data is metric. | |
| vec3 | extent () const |
| Returns the physical size of the image as a vector. | |
| vec3i | dimensions () const |
| Returns the dimensions of the image in pixels as a vector. | |
| vec3 | pixelToImage (const vec3 &pixel) const |
| Convert a 3D pixel/voxel position to image coordinates. | |
| vec3 | imageToPixel (const vec3 &world) const |
| Convert 3D image coordinates to pixel/voxel position. | |
| mat4 | pixelToImageMatrix () const |
| Returns a 4x4 matrix to transform from image pixel space to image space. | |
| mat4 | imageToPixelMatrix () const |
| Returns a 4x4 matrix to transform from image space to image pixel space. | |
| size_t | index (int x, int y, int z=0, int c=0) const |
| Returns a linear memory index for a pixel or voxel. | |
| bool | hasIndex (int x, int y, int z=0, int c=0) const |
| Returns true if the pixel at (x,y,z) exists, false otherwise. | |
| vec4i | coord (size_t index) const |
| Returns the pixel/voxel coordinate (x,y,z,c) for a given index. | |
| size_t | size () const |
| Returns the size (number of elements) of the image. | |
| int | typeSize () const |
| Return the nominal size in bytes of standard data types, zero if unknown. | |
| bool | isInteger () const |
| Returns whether the image is of an integer data type. | |
| bool | isSigned () const |
| Returns whether the image type supports negative values. | |
| size_t | byteSize () const |
| Returns the size of the image in bytes. | |
| int | alignment () const |
| Returns the byte alignment of an image line (up to 8) | |
| int | dimension () const |
| Returns the spatial dimension of the image. | |
| bool | compatible (const Image &other, bool ignoreType=false, bool ignore3D=false, bool ignoreChannels=false) const |
| Tells if this image is compatible to another one. | |
Public Member Functions inherited from Configurable | |
| virtual void | configureDefaults () |
| Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
| void | registerParameter (ParameterBase *param) |
| Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
| void | unregisterParameter (const ParameterBase *param) |
| Remove the given Parameter or SubProperty from the list of registered parameters. | |
| Configurable (const Configurable &rhs) | |
| Configurable (Configurable &&rhs) noexcept | |
| Configurable & | operator= (const Configurable &) |
| Configurable & | operator= (Configurable &&) noexcept |
Protected Member Functions | |
| void | init (int internalFormat, const void *data) |
| Internal initialization of OpenGL texture. | |
| bool | update (const void *data, size_t N, int format, int type) |
| Internal function to upload pixel data to the texture. | |
Protected Member Functions inherited from Image | |
| template<typename T> | |
| bool | typeCompatible () const |
Protected Attributes | |
| std::unique_ptr< GL::Texture > | m_texture |
| int | m_unit = 0 |
| Remembers the texture unit between bind and unbind. | |
| int | m_format = 0 |
| Original ImFusion image format (might be != OpenGL texture format) | |
Protected Attributes inherited from Image | |
| ImageDescriptor | m_descriptor |
Protected Attributes inherited from Configurable | |
| std::vector< Param > | m_params |
| List of all registered Parameter and SubProperty instances. | |
Additional Inherited Members | |
Public Types inherited from Image | |
| enum | Type { BYTE = static_cast<int>(PixelType::Byte) , UBYTE = static_cast<int>(PixelType::UByte) , SHORT = static_cast<int>(PixelType::Short) , USHORT = static_cast<int>(PixelType::UShort) , INT = static_cast<int>(PixelType::Int) , UINT = static_cast<int>(PixelType::UInt) , FLOAT = static_cast<int>(PixelType::Float) , DOUBLE = static_cast<int>(PixelType::Double) , HFLOAT = static_cast<int>(PixelType::HFloat) } |
| Pixel/voxel data type, equivalent to OpenGL defines. More... | |
| enum | Location { NONE = 0 , MEMORY = 1 , OPENGL = 2 , OPENCL = 3 , CUSTOM = 6 } |
| Location where the data resides. More... | |
Public Attributes inherited from Configurable | |
| Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
|
explicit |
Creates a new OpenGL image.
| desc | Image descriptor, number of channels must be in range [1..4] |
| internalFormat | |
| internalFormat | Internal OpenGL texture format, may be 0 to automatically select a suitable format. |
| data | Optional pointer to texture data for initialization, data must match the format in desc. |
| GlImage | ( | PixelType | type, |
| int | width, | ||
| int | height, | ||
| int | slices = 1, | ||
| int | channels = 1, | ||
| int | internalFormat = 0, | ||
| const void * | data = nullptr ) |
Creates a new OpenGL texture.
| type | ImFusion image type (not necessarily the internal OpenGL texture format) |
| width | width in pixels |
| height | height in pixels |
| slices | number of slices |
| channels | number of channels, must be in [1..4] |
| internalFormat | Internal OpenGL texture format, may be 0 to automatically select a suitable format. |
| data | Optional pointer to texture data for initialization, data must match the format in type. |
| GlImage | ( | Image::Type | type, |
| int | width, | ||
| int | height, | ||
| int | slices = 1, | ||
| int | channels = 1, | ||
| int | internalFormat = 0, | ||
| const void * | data = nullptr ) |
Creates a new OpenGL texture.
| type | ImFusion image type (not necessarily the internal OpenGL texture format) |
| width | width in pixels |
| height | height in pixels |
| slices | number of slices |
| channels | number of channels, must be in [1..4] |
| internalFormat | Internal OpenGL texture format, may be 0 to automatically select a suitable format. |
| data | Optional pointer to texture data for initialization, data must match the format in type. |
Creates a deep copy of the GlImage, with a whole new texture containing the same image data as the original.
Note that the copy constructor is explicit, so you cannot call it implicitly. For example, GlImage original{...}; GlImage copy1 = original // does not compile GlImage copy2 = GlImage{original}; // compiles GlImage copy3{original}; // compiles
The assignment operator will copy all aspects of the other image.
However, the internal OpenGl texture ID will be different as this is a handle to a different resource.
| bool update | ( | const MemImage & | image | ) |
Updates the image content from memory.
If the new image is not compatible with the current one the texture is reinitialized with the new image.
| bool update | ( | const GlImage & | image, |
| GL::Framebuffer * | fbo = 0 ) |
Updates the image content from another GlImage.
An optional FBO may be supplied for fast repeated execution.
| bool update | ( | const GL::Texture & | tex, |
| GL::Framebuffer * | fbo = 0 ) |
Updates the image content from another texture.
An optional FBO may be supplied for fast repeated execution.
| bool swapTexID | ( | GlImage & | other | ) |
Swap the texture ID with another image that has the exact same properties, e.g.
for ping-pong operations Returns true if the images are compatible and the texture IDs have been swapped.
|
inlineoverridevirtual |
Specifies that the image is an OpenGL texture object.
Reimplemented from Image.
| bool makeCompatible | ( | GlImage ** | other, |
| unsigned int | type = 0, | ||
| bool | use2D = false, | ||
| int | channels = -1 ) const |
Creates or updates another image instance to be compatible to this one.
| [in,out] | other | Pointer location where the compatible image should be created or updated. |
| type | If specified, the other image will be created with that type. The type is accordingly not compared to the current image's type. | |
| use2D | If set to true only a slice image will be created. | |
| channels | If the value is bigger or equal zero the resulting image will be created with this number of channels instead of the one of the current image. The number of channels is accordingly not compared to the current image's number of channels. |