Open CASCADE Technology  7.5.0
Public Member Functions | Static Public Member Functions

Image_PixMap Class Reference

Class represents packed image plane. More...

#include <Image_PixMap.hxx>

Inheritance diagram for Image_PixMap:
Inheritance graph
[legend]

Public Member Functions

Image_Format Format () const
 
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). More...
 
Standard_Size Width () const
 
Standard_Size Height () const
 
Standard_Size SizeX () const
 
Standard_Size SizeY () const
 
Standard_Real Ratio () const
 
bool IsEmpty () const
 
 Image_PixMap ()
 Empty constructor. Initialize the NULL image plane. More...
 
virtual ~Image_PixMap ()
 Destructor. More...
 
Quantity_ColorRGBA PixelColor (const Standard_Integer theX, const Standard_Integer theY, const Standard_Boolean theToLinearize=Standard_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(). More...
 
void SetPixelColor (const Standard_Integer theX, const Standard_Integer theY, const Quantity_Color &theColor, const Standard_Boolean theToDeLinearize=Standard_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(). More...
 
void SetPixelColor (const Standard_Integer theX, const Standard_Integer theY, const Quantity_ColorRGBA &theColor, const Standard_Boolean theToDeLinearize=Standard_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(). More...
 
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. More...
 
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). More...
 
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. More...
 
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). More...
 
virtual void Clear ()
 Method correctly deallocate internal buffer. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object. More...
 
Standard_Boolean IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
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. More...
 
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. More...
 
Standard_TransientThis () 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. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 
void IncrementRefCounter () const
 Increments the reference counter of this object. More...
 
Standard_Integer DecrementRefCounter () const
 Decrements the reference counter of this object; returns the decremented value. More...
 

Static Public Member Functions

static bool IsBigEndianHost ()
 Determine Big-Endian at runtime. More...
 
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: More...
 
static void ToBlackWhite (Image_PixMap &theImage)
 Convert image to Black/White. More...
 
static const Handle< NCollection_BaseAllocator > & DefaultAllocator ()
 Return default image data allocator. More...
 
- Static Public Member Functions inherited from Standard_Transient
static const char * get_type_name ()
 Returns a type descriptor about this object. More...
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class. More...
 

low-level API for batch-processing (pixels reading / comparison / modification)

typedef Image_Format ImgFormat
 
static const Image_Format ImgUNKNOWN = Image_Format_UNKNOWN
 
static const Image_Format ImgGray = Image_Format_Gray
 
static const Image_Format ImgAlpha = Image_Format_Alpha
 
static const Image_Format ImgRGB = Image_Format_RGB
 
static const Image_Format ImgBGR = Image_Format_BGR
 
static const Image_Format ImgRGB32 = Image_Format_RGB32
 
static const Image_Format ImgBGR32 = Image_Format_BGR32
 
static const Image_Format ImgRGBA = Image_Format_RGBA
 
static const Image_Format ImgBGRA = Image_Format_BGRA
 
static const Image_Format ImgGrayF = Image_Format_GrayF
 
static const Image_Format ImgAlphaF = Image_Format_AlphaF
 
static const Image_Format ImgRGBF = Image_Format_RGBF
 
static const Image_Format ImgBGRF = Image_Format_BGRF
 
static const Image_Format ImgRGBAF = Image_Format_RGBAF
 
static const Image_Format ImgBGRAF = Image_Format_BGRAF
 
Image_PixMapData myData
 data buffer More...
 
Image_Format myImgFormat
 pixel format More...
 
static Standard_Size SizePixelBytes (const Image_Format thePixelFormat)
 
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. More...
 
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! More...
 
Standard_Size TopDownInc () const
 Returns +1 if scanlines ordered in Top->Down order in memory and -1 otherwise. More...
 
const Standard_ByteData () const
 
Standard_ByteChangeData ()
 
const Standard_ByteRow (const Standard_Size theRow) const
 
Standard_ByteChangeRow (const Standard_Size theRow)
 
Standard_Size SizePixelBytes () const
 
Standard_Size SizeRowBytes () const
 
Standard_Size RowExtraBytes () const
 
Standard_Size MaxRowAligmentBytes () const
 Compute the maximal row alignment for current row size. More...
 
Standard_Size SizeBytes () const
 
template<typename ColorType_t >
const ColorType_t & Value (const Standard_Size theRow, const Standard_Size theCol) const
 Access image pixel with specified color type. This method does not perform any type checks - use on own risk (check Format() before)! More...
 
template<typename ColorType_t >
ColorType_t & ChangeValue (const Standard_Size theRow, const Standard_Size theCol)
 Access image pixel with specified color type. This method does not perform any type checks - use on own risk (check Format() before)! More...
 
const Standard_ByteRawValue (Standard_Size theRow, Standard_Size theCol) const
 Access image pixel as raw data pointer. This method does not perform any type checks - use on own risk (check Format() before)! More...
 
Standard_ByteChangeRawValue (Standard_Size theRow, Standard_Size theCol)
 Access image pixel as raw data pointer. This method does not perform any type checks - use on own risk (check Format() before)! More...
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 

Detailed Description

Class represents packed image plane.

Member Typedef Documentation

◆ ImgFormat

Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

Constructor & Destructor Documentation

◆ Image_PixMap()

Image_PixMap::Image_PixMap ( )

Empty constructor. Initialize the NULL image plane.

◆ ~Image_PixMap()

virtual Image_PixMap::~Image_PixMap ( )
virtual

Destructor.

Member Function Documentation

◆ ChangeData()

Standard_Byte* Image_PixMap::ChangeData ( )
inline
Returns
data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).

◆ ChangeRawValue()

Standard_Byte* Image_PixMap::ChangeRawValue ( Standard_Size  theRow,
Standard_Size  theCol 
)
inline

Access image pixel as raw data pointer. This method does not perform any type checks - use on own risk (check Format() before)!

◆ ChangeRow()

Standard_Byte* Image_PixMap::ChangeRow ( const Standard_Size  theRow)
inline
Returns
data pointer to requested row (first column).

◆ ChangeValue()

template<typename ColorType_t >
ColorType_t& Image_PixMap::ChangeValue ( const Standard_Size  theRow,
const Standard_Size  theCol 
)
inline

Access image pixel with specified color type. This method does not perform any type checks - use on own risk (check Format() before)!

◆ Clear()

virtual void Image_PixMap::Clear ( )
virtual

Method correctly deallocate internal buffer.

Reimplemented in Image_AlienPixMap.

◆ Data()

const Standard_Byte* Image_PixMap::Data ( ) const
inline
Returns
data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).

◆ DefaultAllocator()

static const Handle< NCollection_BaseAllocator >& Image_PixMap::DefaultAllocator ( )
static

Return default image data allocator.

◆ Format()

Image_Format Image_PixMap::Format ( ) const
inline

◆ Height()

Standard_Size Image_PixMap::Height ( ) const
inline
Returns
image height in pixels

◆ InitCopy()

virtual bool Image_PixMap::InitCopy ( const Image_PixMap theCopy)
virtual

Initialize by copying data. If you want to copy alien data you should create wrapper using InitWrapper() before.

Reimplemented in Image_AlienPixMap.

◆ InitTrash()

virtual bool Image_PixMap::InitTrash ( Image_Format  thePixelFormat,
const Standard_Size  theSizeX,
const Standard_Size  theSizeY,
const Standard_Size  theSizeRowBytes = 0 
)
virtual

Initialize image plane with required dimensions. Memory will be left uninitialized (performance trick).

Reimplemented in Image_AlienPixMap.

◆ InitWrapper()

virtual bool Image_PixMap::InitWrapper ( Image_Format  thePixelFormat,
Standard_Byte theDataPtr,
const Standard_Size  theSizeX,
const Standard_Size  theSizeY,
const Standard_Size  theSizeRowBytes = 0 
)
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.

◆ InitZero()

bool Image_PixMap::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).

◆ IsBigEndianHost()

static bool Image_PixMap::IsBigEndianHost ( )
inlinestatic

Determine Big-Endian at runtime.

◆ IsEmpty()

bool Image_PixMap::IsEmpty ( ) const
inline
Returns
true if data is NULL.

◆ IsTopDown()

bool Image_PixMap::IsTopDown ( ) const
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.

Returns
true if image data is top-down

◆ MaxRowAligmentBytes()

Standard_Size Image_PixMap::MaxRowAligmentBytes ( ) const
inline

Compute the maximal row alignment for current row size.

Returns
maximal row alignment in bytes (up to 16 bytes).

◆ PixelColor()

Quantity_ColorRGBA Image_PixMap::PixelColor ( const Standard_Integer  theX,
const Standard_Integer  theY,
const Standard_Boolean  theToLinearize = Standard_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().

Parameters
theX[in] column index from left
theY[in] row index from top
theToLinearize[in] when TRUE, the color stored in non-linear color space (e.g. Image_Format_RGB) will be linearized
Returns
the pixel color

◆ Ratio()

Standard_Real Image_PixMap::Ratio ( ) const
inline
Returns
width / height.

◆ RawValue()

const Standard_Byte* Image_PixMap::RawValue ( Standard_Size  theRow,
Standard_Size  theCol 
) const
inline

Access image pixel as raw data pointer. This method does not perform any type checks - use on own risk (check Format() before)!

◆ Row()

const Standard_Byte* Image_PixMap::Row ( const Standard_Size  theRow) const
inline
Returns
data pointer to requested row (first column).

◆ RowExtraBytes()

Standard_Size Image_PixMap::RowExtraBytes ( ) const
inline
Returns
the extra bytes in the row.

◆ SetFormat()

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).

◆ SetPixelColor() [1/2]

void Image_PixMap::SetPixelColor ( const Standard_Integer  theX,
const Standard_Integer  theY,
const Quantity_Color theColor,
const Standard_Boolean  theToDeLinearize = Standard_False 
)
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().

Parameters
theX[in] column index from left
theY[in] row index from top
theColor[in] color to store
theToDeLinearize[in] when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB)

◆ SetPixelColor() [2/2]

void Image_PixMap::SetPixelColor ( const Standard_Integer  theX,
const Standard_Integer  theY,
const Quantity_ColorRGBA theColor,
const Standard_Boolean  theToDeLinearize = Standard_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().

Parameters
theX[in] column index from left
theY[in] row index from top
theColor[in] color to store
theToDeLinearize[in] when TRUE, the gamma correction will be applied for storing in non-linear color space (e.g. Image_Format_RGB)

◆ SetTopDown()

void Image_PixMap::SetTopDown ( const bool  theIsTopDown)
inline

Setup scanlines order in memory - top-down or bottom-up. Drawers should explicitly specify this value if current state IsTopDown() was ignored!

Parameters
theIsTopDowntop-down flag

◆ SizeBytes()

Standard_Size Image_PixMap::SizeBytes ( ) const
inline
Returns
buffer size

◆ SizePixelBytes() [1/2]

Standard_Size Image_PixMap::SizePixelBytes ( ) const
inline
Returns
bytes reserved for one pixel (may include extra bytes for alignment).

◆ SizePixelBytes() [2/2]

static Standard_Size Image_PixMap::SizePixelBytes ( const Image_Format  thePixelFormat)
static
Returns
bytes reserved for one pixel (may include extra bytes for alignment).

◆ SizeRowBytes()

Standard_Size Image_PixMap::SizeRowBytes ( ) const
inline
Returns
bytes reserved per row. Could be larger than needed to store packed row (extra bytes for alignment etc.).

◆ SizeX()

Standard_Size Image_PixMap::SizeX ( ) const
inline
Returns
image width in pixels

◆ SizeY()

Standard_Size Image_PixMap::SizeY ( ) const
inline
Returns
image height in pixels

◆ SwapRgbaBgra()

static bool Image_PixMap::SwapRgbaBgra ( Image_PixMap theImage)
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:

  • Image_Format_RGB32 / Image_Format_BGR32
  • Image_Format_RGBA / Image_Format_BGRA
  • Image_Format_RGB / Image_Format_BGR
  • Image_Format_RGBF / Image_Format_BGRF
  • Image_Format_RGBAF / Image_Format_BGRAF

◆ ToBlackWhite()

static void Image_PixMap::ToBlackWhite ( Image_PixMap theImage)
static

Convert image to Black/White.

◆ TopDownInc()

Standard_Size Image_PixMap::TopDownInc ( ) const
inline

Returns +1 if scanlines ordered in Top->Down order in memory and -1 otherwise.

Returns
scanline increment for Top->Down iteration

◆ Value()

template<typename ColorType_t >
const ColorType_t& Image_PixMap::Value ( const Standard_Size  theRow,
const Standard_Size  theCol 
) const
inline

Access image pixel with specified color type. This method does not perform any type checks - use on own risk (check Format() before)!

◆ Width()

Standard_Size Image_PixMap::Width ( ) const
inline
Returns
image width in pixels

Field Documentation

◆ ImgAlpha

const Image_Format Image_PixMap::ImgAlpha = Image_Format_Alpha
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgAlphaF

const Image_Format Image_PixMap::ImgAlphaF = Image_Format_AlphaF
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgBGR

const Image_Format Image_PixMap::ImgBGR = Image_Format_BGR
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgBGR32

const Image_Format Image_PixMap::ImgBGR32 = Image_Format_BGR32
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgBGRA

const Image_Format Image_PixMap::ImgBGRA = Image_Format_BGRA
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgBGRAF

const Image_Format Image_PixMap::ImgBGRAF = Image_Format_BGRAF
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgBGRF

const Image_Format Image_PixMap::ImgBGRF = Image_Format_BGRF
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgGray

const Image_Format Image_PixMap::ImgGray = Image_Format_Gray
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgGrayF

const Image_Format Image_PixMap::ImgGrayF = Image_Format_GrayF
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgRGB

const Image_Format Image_PixMap::ImgRGB = Image_Format_RGB
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgRGB32

const Image_Format Image_PixMap::ImgRGB32 = Image_Format_RGB32
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgRGBA

const Image_Format Image_PixMap::ImgRGBA = Image_Format_RGBA
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgRGBAF

const Image_Format Image_PixMap::ImgRGBAF = Image_Format_RGBAF
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgRGBF

const Image_Format Image_PixMap::ImgRGBF = Image_Format_RGBF
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ ImgUNKNOWN

const Image_Format Image_PixMap::ImgUNKNOWN = Image_Format_UNKNOWN
static
Deprecated:
("This member is deprecated, use Image_Format enumeration instead")

◆ myData

Image_PixMapData Image_PixMap::myData
protected

data buffer

◆ myImgFormat

Image_Format Image_PixMap::myImgFormat
protected

pixel format


The documentation for this class was generated from the following file: