OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    Image_AlienPixMap Class Reference

    Image class that support file reading/writing operations using auxiliary image library. Supported image formats: More...

    #include <Image_AlienPixMap.hxx>

    Inheritance diagram for Image_AlienPixMap:

    Public Member Functions

     Image_AlienPixMap ()
     Empty constructor.
     ~Image_AlienPixMap () override
     Destructor.
    bool Load (const TCollection_AsciiString &theFileName)
     Read image data from file.
    bool Load (std::istream &theStream, const TCollection_AsciiString &theFileName)
     Read image data from stream.
    bool Load (const uint8_t *theData, const size_t theLength, const TCollection_AsciiString &theFileName)
     Read image data from memory buffer.
    bool Save (const TCollection_AsciiString &theFileName)
     Write image data to file.
    bool Save (std::ostream &theStream, const TCollection_AsciiString &theExtension)
     Write image data to stream.
    bool Save (uint8_t *theBuffer, const size_t theLength, const TCollection_AsciiString &theFileName)
     Write image data to file or memory buffer using file extension to determine format.
    bool InitTrash (Image_Format thePixelFormat, const size_t theSizeX, const size_t theSizeY, const size_t theSizeRowBytes=0) override
     Initialize image plane with required dimensions.
    bool InitCopy (const Image_PixMap &theCopy) override
     Initialize by copying data.
    void Clear () override
     Method correctly deallocate internal buffer.
    bool AdjustGamma (const double theGammaCorr)
     Performs gamma correction on image.
    Public Member Functions inherited from Image_PixMap
    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).
    size_t Width () const
     Return image width in pixels.
    size_t Height () const
     Return image height in pixels.
    size_t Depth () const
     Return image depth in pixels.
    size_t SizeX () const
     Return image width in pixels.
    size_t SizeY () const
     Return image height in pixels.
    size_t SizeZ () const
     Return image depth in pixels.
    NCollection_Vec3< size_t > SizeXYZ () const
     Return image width x height x depth in pixels.
    double Ratio () const
     Return width / height.
    bool IsEmpty () const
     Return true if data is NULL.
     Image_PixMap ()
     Empty constructor. Initialize the NULL image plane.
     ~Image_PixMap () override
     Destructor.
    Quantity_ColorRGBA PixelColor (int theX, int theY, bool 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 int theX, const int theY, const Quantity_Color &theColor, const bool 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 int theX, const int theY, const Quantity_ColorRGBA &theColor, const bool 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().
    bool InitZero (Image_Format thePixelFormat, const size_t theSizeX, const size_t theSizeY, const size_t theSizeRowBytes=0, const uint8_t theValue=0)
     Initialize image plane with required dimensions. Buffer will be zeroed (black color for most formats).
    virtual bool InitWrapper3D (Image_Format thePixelFormat, uint8_t *theDataPtr, const NCollection_Vec3< size_t > &theSizeXYZ, const size_t 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< size_t > &theSizeXYZ, const size_t theSizeRowBytes=0)
     Initialize 2D/3D image with required dimensions. Memory will be left uninitialized (performance trick).
    bool InitZero3D (Image_Format thePixelFormat, const NCollection_Vec3< size_t > &theSizeXYZ, const size_t theSizeRowBytes=0, const uint8_t theValue=0)
     Initialize 2D/3D image with required dimensions. Buffer will be zeroed (black color for most formats).
    bool IsTopDown () const
     data buffer
    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!
    size_t TopDownInc () const
     Returns +1 if scanlines ordered in Top->Down order in memory and -1 otherwise.
    const uint8_t * Data () const
     Return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).
    uint8_t * ChangeData ()
     Return data pointer for low-level operations (copying entire buffer, parsing with extra tools etc.).
    const uint8_t * Row (size_t theRow) const
     Return data pointer to requested row (first column). Indexation starts from 0.
    uint8_t * ChangeRow (size_t theRow)
     Return data pointer to requested row (first column). Indexation starts from 0.
    const uint8_t * Slice (size_t theSlice) const
     Return data pointer to requested 2D slice. Indexation starts from 0.
    uint8_t * ChangeSlice (size_t theSlice)
     Return data pointer to requested 2D slice. Indexation starts from 0.
    const uint8_t * SliceRow (size_t theSlice, size_t theRow) const
     Return data pointer to requested row (first column). Indexation starts from 0.
    uint8_t * ChangeSliceRow (size_t theSlice, size_t theRow)
     Return data pointer to requested row (first column). Indexation starts from 0.
    size_t SizePixelBytes () const
     Return bytes reserved for one pixel (may include extra bytes for alignment).
    size_t SizeRowBytes () const
     Return bytes reserved per row. Could be larger than needed to store packed row (extra bytes for alignment etc.).
    size_t RowExtraBytes () const
     Return the extra bytes in the row.
    size_t MaxRowAligmentBytes () const
     Compute the maximal row alignment for current row size.
    size_t SizeSliceBytes () const
     Return number of bytes per 2D slice.
    size_t SizeBytes () const
     Return buffer size.
    template<typename ColorType_t>
    const ColorType_t & Value (size_t theRow, size_t 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 (size_t theRow, size_t 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 uint8_t * RawValue (size_t theRow, size_t 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.
    uint8_t * ChangeRawValue (size_t theRow, size_t 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 (size_t theX, size_t 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 (size_t theX, size_t 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 uint8_t * RawValueXY (size_t theX, size_t 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.
    uint8_t * ChangeRawValueXY (size_t theX, size_t 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 (size_t theX, size_t theY, size_t 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 (size_t theX, size_t theY, size_t 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 uint8_t * RawValueXYZ (size_t theX, size_t theY, size_t 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.
    uint8_t * ChangeRawValueXYZ (size_t theX, size_t theY, size_t 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.
    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 ()=default
     Destructor must be virtual.
    virtual const opencascade::handle< Standard_Type > & DynamicType () const
     Returns a type descriptor about this object.
    bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
     Returns a true value if this is an instance of Type.
    bool IsInstance (const char *const theTypeName) const
     Returns a true value if this is an instance of TypeName.
    bool 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.
    bool IsKind (const char *const 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.
    int GetRefCount () const noexcept
     Get the reference counter of this object.
    void IncrementRefCounter () noexcept
     Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
    int DecrementRefCounter () noexcept
     Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
    virtual void Delete () const
     Memory deallocator for transient classes.

    Static Public Member Functions

    static bool IsTopDownDefault ()
     Return default rows order used by underlying image library.
    Static Public Member Functions inherited from Image_PixMap
    static bool IsBigEndianHost ()
     Determine Big-Endian at runtime.
    static size_t 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 occ::handle< NCollection_BaseAllocator > & DefaultAllocator ()
     Return default image data allocator.
    static const char * ImageFormatToString (Image_Format theFormat)
     Return string representation of pixel format.
    static const char * ImageFormatToString (Image_CompressedFormat theFormat)
     Return string representation of compressed pixel format.
    static Quantity_ColorRGBA ColorFromRawPixel (const uint8_t *theRawValue, const Image_Format theFormat, const bool theToLinearize=false)
     Convert raw pixel value into Quantity_ColorRGBA. This function is relatively slow.
    static void ColorToRawPixel (uint8_t *theRawValue, const Image_Format theFormat, const Quantity_ColorRGBA &theColor, const bool theToDeLinearize=false)
     Set raw pixel value from Quantity_ColorRGBA. This function is relatively slow.
    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.
    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.

    Additional Inherited Members

    typedef void base_type
     Returns a type descriptor about this object.
    Image_PixMapData myData
     data buffer
    Image_Format myImgFormat
     pixel format

    Detailed Description

    Image class that support file reading/writing operations using auxiliary image library. Supported image formats:

    • *.bmp - bitmap image, lossless format without compression.
    • *.ppm - PPM (Portable Pixmap Format), lossless format without compression.
    • *.png - PNG (Portable Network Graphics) lossless format with compression.
    • *.jpg, *.jpe, *.jpeg - JPEG/JIFF (Joint Photographic Experts Group) lossy format (compressed with quality losses). YUV color space used (automatically converted from/to RGB).
    • *.tif, *.tiff - TIFF (Tagged Image File Format).
    • *.tga - TGA (Truevision Targa Graphic), lossless format.
    • *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using palette (up to 256 distinct colors).
    • *.exr - OpenEXR high dynamic-range format (supports float pixel formats).

    Constructor & Destructor Documentation

    ◆ Image_AlienPixMap()

    Image_AlienPixMap::Image_AlienPixMap ( )

    Empty constructor.

    ◆ ~Image_AlienPixMap()

    Image_AlienPixMap::~Image_AlienPixMap ( )
    override

    Destructor.

    Member Function Documentation

    ◆ AdjustGamma()

    bool Image_AlienPixMap::AdjustGamma ( const double theGammaCorr)

    Performs gamma correction on image.

    Parameters
    [in]theGamma- gamma value to use; a value of 1.0 leaves the image alone

    ◆ Clear()

    void Image_AlienPixMap::Clear ( )
    overridevirtual

    Method correctly deallocate internal buffer.

    Reimplemented from Image_PixMap.

    ◆ InitCopy()

    bool Image_AlienPixMap::InitCopy ( const Image_PixMap & theCopy)
    overridevirtual

    Initialize by copying data.

    Reimplemented from Image_PixMap.

    ◆ InitTrash()

    bool Image_AlienPixMap::InitTrash ( Image_Format thePixelFormat,
    const size_t theSizeX,
    const size_t theSizeY,
    const size_t theSizeRowBytes = 0 )
    overridevirtual

    Initialize image plane with required dimensions.

    Parameters
    [in]thePixelFormatif specified pixel format doesn't supported by image library than nearest supported will be used instead!
    [in]theSizeRowBytesmay be ignored by this class and required alignment will be used instead!

    Reimplemented from Image_PixMap.

    ◆ IsTopDownDefault()

    bool Image_AlienPixMap::IsTopDownDefault ( )
    static

    Return default rows order used by underlying image library.

    ◆ Load() [1/3]

    bool Image_AlienPixMap::Load ( const TCollection_AsciiString & theFileName)
    inline

    Read image data from file.

    ◆ Load() [2/3]

    bool Image_AlienPixMap::Load ( const uint8_t * theData,
    const size_t theLength,
    const TCollection_AsciiString & theFileName )

    Read image data from memory buffer.

    Parameters
    [in]theDatamemory pointer to read from; when NULL, function will attempt to open theFileName file
    [in]theLengthmemory buffer length
    [in]theFileNameoptional file name

    ◆ Load() [3/3]

    bool Image_AlienPixMap::Load ( std::istream & theStream,
    const TCollection_AsciiString & theFileName )

    Read image data from stream.

    ◆ Save() [1/3]

    bool Image_AlienPixMap::Save ( const TCollection_AsciiString & theFileName)
    inline

    Write image data to file.

    Parameters
    [in]theFileNamefile name to save

    ◆ Save() [2/3]

    bool Image_AlienPixMap::Save ( std::ostream & theStream,
    const TCollection_AsciiString & theExtension )

    Write image data to stream.

    Parameters
    [out]theStreamstream where to write
    [in]theExtensionimage format

    ◆ Save() [3/3]

    bool Image_AlienPixMap::Save ( uint8_t * theBuffer,
    const size_t theLength,
    const TCollection_AsciiString & theFileName )

    Write image data to file or memory buffer using file extension to determine format.

    Parameters
    [out]theBufferbuffer pointer where to write when NULL, function write image data to theFileName file
    [in]theLengthmemory buffer length
    [in]theFileNamefile name to save; when theBuffer isn't NULL used only to determine format

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