Open CASCADE Technology 7.8.2.dev
|
Class represents packed image plane. More...
#include <Image_PixMap.hxx>
Public Member Functions | |
Image_Format | Format () const |
Return pixel format. | |
void | SetFormat (const Image_Format thePixelFormat) |
Override pixel format specified by InitXXX() methods. Will throw exception if pixel size of new format is not equal to currently initialized format. Intended to switch formats indicating different interpretation of the same data (e.g. ImgGray and ImgAlpha). | |
Standard_Size | Width () const |
Return image width in pixels. | |
Standard_Size | Height () const |
Return image height in pixels. | |
Standard_Size | Depth () const |
Return image depth in pixels. | |
Standard_Size | SizeX () const |
Return image width in pixels. | |
Standard_Size | SizeY () const |
Return image height in pixels. | |
Standard_Size | SizeZ () const |
Return image depth in pixels. | |
NCollection_Vec3< Standard_Size > | SizeXYZ () const |
Return image width x height x depth in pixels. | |
Standard_Real | Ratio () const |
Return width / height. | |
bool | IsEmpty () const |
Return true if data is NULL. | |
Image_PixMap () | |
Empty constructor. Initialize the NULL image plane. | |
virtual | ~Image_PixMap () |
Destructor. | |
Quantity_ColorRGBA | PixelColor (Standard_Integer theX, Standard_Integer theY, Standard_Boolean theToLinearize=false) const |
Returns the pixel color. This function is relatively slow. Beware that this method takes coordinates in opposite order in contrast to Value() and ChangeValue(). | |
void | SetPixelColor (const Standard_Integer theX, const Standard_Integer theY, const Quantity_Color &theColor, const Standard_Boolean theToDeLinearize=false) |
Sets the pixel color. This function is relatively slow. Beware that this method takes coordinates in opposite order in contrast to Value() and ChangeValue(). | |
void | SetPixelColor (const Standard_Integer theX, const Standard_Integer theY, const Quantity_ColorRGBA &theColor, const Standard_Boolean theToDeLinearize=false) |
Sets the pixel color. This function is relatively slow. Beware that this method takes coordinates in opposite order in contrast to Value() and ChangeValue(). | |
virtual bool | InitWrapper (Image_Format thePixelFormat, Standard_Byte *theDataPtr, const Standard_Size theSizeX, const Standard_Size theSizeY, const Standard_Size theSizeRowBytes=0) |
Initialize image plane as wrapper over alien data. Data will not be copied! Notice that caller should ensure that data pointer will not be released during this wrapper lifetime. You may call InitCopy() to perform data copying. | |
virtual bool | InitTrash (Image_Format thePixelFormat, const Standard_Size theSizeX, const Standard_Size theSizeY, const Standard_Size theSizeRowBytes=0) |
Initialize image plane with required dimensions. Memory will be left uninitialized (performance trick). | |
virtual bool | InitCopy (const Image_PixMap &theCopy) |
Initialize by copying data. If you want to copy alien data you should create wrapper using InitWrapper() before. | |
bool | InitZero (Image_Format thePixelFormat, const Standard_Size theSizeX, const Standard_Size theSizeY, const Standard_Size theSizeRowBytes=0, const Standard_Byte theValue=0) |
Initialize image plane with required dimensions. Buffer will be zeroed (black color for most formats). | |
virtual void | Clear () |
Method correctly deallocate internal buffer. | |
virtual bool | InitWrapper3D (Image_Format thePixelFormat, Standard_Byte *theDataPtr, const NCollection_Vec3< Standard_Size > &theSizeXYZ, const Standard_Size theSizeRowBytes=0) |
Initialize 2D/3D image as wrapper over alien data. Data will not be copied! Notice that caller should ensure that data pointer will not be released during this wrapper lifetime. You may call InitCopy() to perform data copying. | |
virtual bool | InitTrash3D (Image_Format thePixelFormat, const NCollection_Vec3< Standard_Size > &theSizeXYZ, const Standard_Size theSizeRowBytes=0) |
Initialize 2D/3D image with required dimensions. Memory will be left uninitialized (performance trick). | |
bool | InitZero3D (Image_Format thePixelFormat, const NCollection_Vec3< Standard_Size > &theSizeXYZ, const Standard_Size theSizeRowBytes=0, const Standard_Byte theValue=0) |
Initialize 2D/3D image with required dimensions. Buffer will be zeroed (black color for most formats). | |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. | |
virtual | ~Standard_Transient () |
Destructor must be virtual. | |
virtual const opencascade::handle< Standard_Type > & | DynamicType () const |
Returns a type descriptor about this object. | |
Standard_Boolean | IsInstance (const opencascade::handle< Standard_Type > &theType) const |
Returns a true value if this is an instance of Type. | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. | |
Standard_Boolean | IsKind (const opencascade::handle< Standard_Type > &theType) const |
Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. | |
Standard_Boolean | IsKind (const Standard_CString theTypeName) const |
Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. | |
Standard_Transient * | This () const |
Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. | |
Standard_Integer | GetRefCount () const noexcept |
Get the reference counter of this object. | |
void | IncrementRefCounter () noexcept |
Increments the reference counter of this object. | |
Standard_Integer | DecrementRefCounter () noexcept |
Decrements the reference counter of this object; returns the decremented value. | |
virtual void | Delete () const |
Memory deallocator for transient classes. | |
Static Public Member Functions | |
static bool | IsBigEndianHost () |
Determine Big-Endian at runtime. | |
static Standard_Size | SizePixelBytes (const Image_Format thePixelFormat) |
Return bytes reserved for one pixel (may include extra bytes for alignment). | |
static bool | SwapRgbaBgra (Image_PixMap &theImage) |
Auxiliary method for swapping bytes between RGB and BGR formats. This method modifies the image data but does not change pixel format! Method will fail if pixel format is not one of the following: | |
static void | ToBlackWhite (Image_PixMap &theImage) |
Convert image to Black/White. | |
static bool | FlipY (Image_PixMap &theImage) |
Reverse line order as it draws it from bottom to top. | |
static const Handle< NCollection_BaseAllocator > & | DefaultAllocator () |
Return default image data allocator. | |
static Standard_CString | ImageFormatToString (Image_Format theFormat) |
Return string representation of pixel format. | |
static Standard_CString | ImageFormatToString (Image_CompressedFormat theFormat) |
Return string representation of compressed pixel format. | |
static Quantity_ColorRGBA | ColorFromRawPixel (const Standard_Byte *theRawValue, const Image_Format theFormat, const Standard_Boolean theToLinearize=false) |
Convert raw pixel value into Quantity_ColorRGBA. This function is relatively slow. | |
static void | ColorToRawPixel (Standard_Byte *theRawValue, const Image_Format theFormat, const Quantity_ColorRGBA &theColor, const Standard_Boolean theToDeLinearize=false) |
Set raw pixel value from Quantity_ColorRGBA. This function is relatively slow. | |
Static Public Member Functions inherited from Standard_Transient | |
static constexpr const char * | get_type_name () |
Returns a type descriptor about this object. | |
static const opencascade::handle< Standard_Type > & | get_type_descriptor () |
Returns type descriptor of Standard_Transient class. | |
low-level API for batch-processing (pixels reading / comparison / modification) | |
Image_PixMapData | myData |
data buffer | |
Image_Format | myImgFormat |
pixel format | |
static float | ConvertFromHalfFloat (const uint16_t theHalf) |
Convert 16-bit half-float value into 32-bit float (simple conversion). | |
static uint16_t | ConvertToHalfFloat (const float theFloat) |
Convert 32-bit float value into IEEE-754 16-bit floating-point format without infinity: 1-5-10, exp-15, +-131008.0, +-6.1035156E-5, +-5.9604645E-8, 3.311 digits. | |
bool | IsTopDown () const |
Returns TRUE if image data is stored from Top to the Down. By default Bottom Up order is used instead (topmost scanlines starts from the bottom in memory). which is most image frameworks naturally support. | |
void | SetTopDown (const bool theIsTopDown) |
Setup scanlines order in memory - top-down or bottom-up. Drawers should explicitly specify this value if current state IsTopDown() was ignored! | |
Standard_Size | TopDownInc () const |
Returns +1 if scanlines ordered in Top->Down order in memory and -1 otherwise. | |
const Standard_Byte * | Data () const |
Return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.). | |
Standard_Byte * | ChangeData () |
Return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.). | |
const Standard_Byte * | Row (Standard_Size theRow) const |
Return data pointer to requested row (first column). Indexation starts from 0. | |
Standard_Byte * | ChangeRow (Standard_Size theRow) |
Return data pointer to requested row (first column). Indexation starts from 0. | |
const Standard_Byte * | Slice (Standard_Size theSlice) const |
Return data pointer to requested 2D slice. Indexation starts from 0. | |
Standard_Byte * | ChangeSlice (Standard_Size theSlice) |
Return data pointer to requested 2D slice. Indexation starts from 0. | |
const Standard_Byte * | SliceRow (Standard_Size theSlice, Standard_Size theRow) const |
Return data pointer to requested row (first column). Indexation starts from 0. | |
Standard_Byte * | ChangeSliceRow (Standard_Size theSlice, Standard_Size theRow) |
Return data pointer to requested row (first column). Indexation starts from 0. | |
Standard_Size | SizePixelBytes () const |
Return bytes reserved for one pixel (may include extra bytes for alignment). | |
Standard_Size | SizeRowBytes () const |
Return bytes reserved per row. Could be larger than needed to store packed row (extra bytes for alignment etc.). | |
Standard_Size | RowExtraBytes () const |
Return the extra bytes in the row. | |
Standard_Size | MaxRowAligmentBytes () const |
Compute the maximal row alignment for current row size. | |
Standard_Size | SizeSliceBytes () const |
Return number of bytes per 2D slice. | |
Standard_Size | SizeBytes () const |
Return buffer size. | |
template<typename ColorType_t > | |
const ColorType_t & | Value (Standard_Size theRow, Standard_Size theCol) const |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next. | |
template<typename ColorType_t > | |
ColorType_t & | ChangeValue (Standard_Size theRow, Standard_Size theCol) |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next. | |
const Standard_Byte * | RawValue (Standard_Size theRow, Standard_Size theCol) const |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next. | |
Standard_Byte * | ChangeRawValue (Standard_Size theRow, Standard_Size theCol) |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next. | |
template<typename ColorType_t > | |
const ColorType_t & | ValueXY (Standard_Size theX, Standard_Size theY) const |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y order. | |
template<typename ColorType_t > | |
ColorType_t & | ChangeValueXY (Standard_Size theX, Standard_Size theY) |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y order. | |
const Standard_Byte * | RawValueXY (Standard_Size theX, Standard_Size theY) const |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y order. | |
Standard_Byte * | ChangeRawValueXY (Standard_Size theX, Standard_Size theY) |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y order. | |
template<typename ColorType_t > | |
const ColorType_t & | ValueXYZ (Standard_Size theX, Standard_Size theY, Standard_Size theZ) const |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y, Z order. | |
template<typename ColorType_t > | |
ColorType_t & | ChangeValueXYZ (Standard_Size theX, Standard_Size theY, Standard_Size theZ) |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y, Z order. | |
const Standard_Byte * | RawValueXYZ (Standard_Size theX, Standard_Size theY, Standard_Size theZ) const |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y, Z order. | |
Standard_Byte * | ChangeRawValueXYZ (Standard_Size theX, Standard_Size theY, Standard_Size theZ) |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y, Z order. | |
Additional Inherited Members | |
Public Types inherited from Standard_Transient | |
typedef void | base_type |
Returns a type descriptor about this object. | |
Class represents packed image plane.
Image_PixMap::Image_PixMap | ( | ) |
Empty constructor. Initialize the NULL image plane.
|
virtual |
Destructor.
|
inline |
Return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).
|
inline |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next.
|
inline |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y order.
|
inline |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y, Z order.
|
inline |
Return data pointer to requested row (first column). Indexation starts from 0.
|
inline |
Return data pointer to requested 2D slice. Indexation starts from 0.
|
inline |
Return data pointer to requested row (first column). Indexation starts from 0.
|
inline |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next.
|
inline |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y order.
|
inline |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y, Z order.
|
virtual |
Method correctly deallocate internal buffer.
Reimplemented in Image_AlienPixMap.
|
static |
Convert raw pixel value into Quantity_ColorRGBA. This function is relatively slow.
[in] | theRawValue | pointer to pixel definition |
[in] | theFormat | pixel format |
[in] | theToLinearize | when TRUE, the color stored in non-linear color space (e.g. Image_Format_RGB) will be linearized |
|
static |
Set raw pixel value from Quantity_ColorRGBA. This function is relatively slow.
[out] | theRawValue | pointer to pixel definition to modify |
[in] | theFormat | pixel format |
[in] | theColor | color value to convert from |
[in] | theToDeLinearize | when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB) |
|
inlinestatic |
Convert 16-bit half-float value into 32-bit float (simple conversion).
|
inlinestatic |
Convert 32-bit float value into IEEE-754 16-bit floating-point format without infinity: 1-5-10, exp-15, +-131008.0, +-6.1035156E-5, +-5.9604645E-8, 3.311 digits.
|
inline |
Return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).
|
static |
Return default image data allocator.
|
inline |
Return image depth in pixels.
|
static |
Reverse line order as it draws it from bottom to top.
|
inline |
Return pixel format.
|
inline |
Return image height in pixels.
|
static |
Return string representation of compressed pixel format.
|
static |
Return string representation of pixel format.
|
virtual |
Initialize by copying data. If you want to copy alien data you should create wrapper using InitWrapper() before.
Reimplemented in Image_AlienPixMap.
|
virtual |
Initialize image plane with required dimensions. Memory will be left uninitialized (performance trick).
Reimplemented in Image_AlienPixMap.
|
virtual |
Initialize 2D/3D image with required dimensions. Memory will be left uninitialized (performance trick).
|
virtual |
Initialize image plane as wrapper over alien data. Data will not be copied! Notice that caller should ensure that data pointer will not be released during this wrapper lifetime. You may call InitCopy() to perform data copying.
|
virtual |
Initialize 2D/3D image as wrapper over alien data. Data will not be copied! Notice that caller should ensure that data pointer will not be released during this wrapper lifetime. You may call InitCopy() to perform data copying.
|
inline |
Initialize image plane with required dimensions. Buffer will be zeroed (black color for most formats).
bool Image_PixMap::InitZero3D | ( | Image_Format | thePixelFormat, |
const NCollection_Vec3< Standard_Size > & | theSizeXYZ, | ||
const Standard_Size | theSizeRowBytes = 0, | ||
const Standard_Byte | theValue = 0 ) |
Initialize 2D/3D image with required dimensions. Buffer will be zeroed (black color for most formats).
|
inlinestatic |
Determine Big-Endian at runtime.
|
inline |
Return true if data is NULL.
|
inline |
Returns TRUE if image data is stored from Top to the Down. By default Bottom Up order is used instead (topmost scanlines starts from the bottom in memory). which is most image frameworks naturally support.
Notice that access methods within this class automatically convert input row-index to apply this flag! You should use this flag only if interconnect with alien APIs and buffers.
|
inline |
Compute the maximal row alignment for current row size.
|
inline |
Returns the pixel color. This function is relatively slow. Beware that this method takes coordinates in opposite order in contrast to Value() and ChangeValue().
[in] | theX | column index from left, starting from 0 |
[in] | theY | row index from top, starting from 0 |
[in] | theToLinearize | when TRUE, the color stored in non-linear color space (e.g. Image_Format_RGB) will be linearized |
|
inline |
Return width / height.
|
inline |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next.
|
inline |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y order.
|
inline |
Access image pixel as raw data pointer. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y, Z order.
|
inline |
Return data pointer to requested row (first column). Indexation starts from 0.
|
inline |
Return the extra bytes in the row.
void Image_PixMap::SetFormat | ( | const Image_Format | thePixelFormat | ) |
Override pixel format specified by InitXXX() methods. Will throw exception if pixel size of new format is not equal to currently initialized format. Intended to switch formats indicating different interpretation of the same data (e.g. ImgGray and ImgAlpha).
|
inline |
Sets the pixel color. This function is relatively slow. Beware that this method takes coordinates in opposite order in contrast to Value() and ChangeValue().
[in] | theX | column index from left |
[in] | theY | row index from top |
[in] | theColor | color to store |
[in] | theToDeLinearize | when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB) |
|
inline |
Sets the pixel color. This function is relatively slow. Beware that this method takes coordinates in opposite order in contrast to Value() and ChangeValue().
[in] | theX | column index from left |
[in] | theY | row index from top |
[in] | theColor | color to store |
[in] | theToDeLinearize | when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB) |
|
inline |
Setup scanlines order in memory - top-down or bottom-up. Drawers should explicitly specify this value if current state IsTopDown() was ignored!
theIsTopDown | top-down flag |
|
inline |
Return buffer size.
|
inline |
Return bytes reserved for one pixel (may include extra bytes for alignment).
|
static |
Return bytes reserved for one pixel (may include extra bytes for alignment).
|
inline |
Return bytes reserved per row. Could be larger than needed to store packed row (extra bytes for alignment etc.).
|
inline |
Return number of bytes per 2D slice.
|
inline |
Return image width in pixels.
|
inline |
Return image width x height x depth in pixels.
|
inline |
Return image height in pixels.
|
inline |
Return image depth in pixels.
|
inline |
Return data pointer to requested 2D slice. Indexation starts from 0.
|
inline |
Return data pointer to requested row (first column). Indexation starts from 0.
|
static |
Auxiliary method for swapping bytes between RGB and BGR formats. This method modifies the image data but does not change pixel format! Method will fail if pixel format is not one of the following:
|
static |
Convert image to Black/White.
|
inline |
Returns +1 if scanlines ordered in Top->Down order in memory and -1 otherwise.
|
inline |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in the decreasing majority following memory layout - e.g. row first, column next.
|
inline |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y order.
|
inline |
Access image pixel with specified color type. Indexation starts from 0. This method does not perform any type checks - use on own risk (check Format() before)! WARNING: Input parameters are defined in traditional X, Y, Z order.
|
inline |
Return image width in pixels.
|
protected |
data buffer
|
protected |
pixel format