GetPixelHandlerStruct Struct Reference

#include <gfx_image_pixelhandler.h>

Detailed Description

Helper class returned by GetPixelHandler. This class provides/caches a fast the access to pixels. A lambda contains the most efficient code to access the pixel data. This object is only valid as long as the bitmap properties (pixel format, pixel storage layout, width, height) wont change.

Public Types

using GetFunc = Delegate< Result< void >(const ImagePos &pos, const PixelMutableBuffer &buffer, GETPIXELFLAGS flags)>
using FreeFunc = Delegate< void(GetPixelHandlerStruct &selfPtr)>

Public Member Functions

 GetPixelHandlerStruct ()
 GetPixelHandlerStruct (GetPixelHandlerStruct &&other)
template<typename GETFUNC , typename FREEFUNC >
 GetPixelHandlerStruct (GETFUNC &&getFunc, FREEFUNC &&freeFunc, const ColorProfile &destinationProfile)
Bool IsValid () const
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > GetPixel (const ImagePos &pos, const PixelMutableBuffer &buffer, GETPIXELFLAGS flags) const
const ColorProfileGetTargetColorProfile ()

Private Attributes

GetFunc _getFunc
FreeFunc _freeFunc
ColorProfile _targetColorProfile

Member Typedef Documentation

◆ GetFunc

using GetFunc = Delegate<Result<void>(const ImagePos &pos, const PixelMutableBuffer &buffer, GETPIXELFLAGS flags)>

◆ FreeFunc

using FreeFunc = Delegate<void(GetPixelHandlerStruct& selfPtr)>

Constructor & Destructor Documentation

◆ GetPixelHandlerStruct() [1/3]

Default Constructor. Initializes everything with nullptr.

◆ GetPixelHandlerStruct() [2/3]

Move Constructor.

◆ GetPixelHandlerStruct() [3/3]

GetPixelHandlerStruct ( GETFUNC &&  getFunc,
FREEFUNC &&  freeFunc,
const ColorProfile destinationProfile 

Constructor to initialize the helper class.

[in]getFuncGet pixel function callback.
[in]freeFuncFree pixel handler callback.
[in]destinationProfileTODO: (Tilo) please document

◆ ~GetPixelHandlerStruct()

Member Function Documentation





◆ IsValid()

Bool IsValid ( ) const

Returns true if the structure is initialized correctly and a GetPixelHandler is set.

◆ GetPixel()

MAXON_ATTRIBUTE_FORCE_INLINE Result<void> GetPixel ( const ImagePos pos,
const PixelMutableBuffer buffer,
) const

Copies/Read the pixel data from the source to the given buffer.

[in]posImagePos of the pixel data to read from.
[in]bufferDestination of the pixel data.
[in]flagsControl the operation with the flags.
OK on success.

◆ GetTargetColorProfile()

const ColorProfile& GetTargetColorProfile ( )

Returns the color profile for the pixel data delivered by this handler. This function is important the pixelhandler was requested without the GETPIXELHANDLERFLAGS::FORCECOLORPROFILECONVERSION flag! In that case the pixel handler will not process color profile conversions if the color space matches between the internal and requested pixel format. This speeds up the conversion and allows to pass the profile to the gpu or to the exporter. (e.g. a bitmap with a sRGB color profile will return the original data if the pixel handler requests a linear rgb profile).

The color profile in which the pixel data will be delivered. If GETPIXELHANDLERFLAGS::FORCECOLORPROFILECONVERSION was set on request of the pixel handler the color profile is the same as the requested profile. If GETPIXELHANDLERFLAGS::FORCECOLORPROFILECONVERSION was NOT set on request of the pixel handler the color profile might be different if the color space matched.

Member Data Documentation

◆ _getFunc

GetFunc _getFunc

◆ _freeFunc

FreeFunc _freeFunc

◆ _targetColorProfile

ColorProfile _targetColorProfile