About
The MAXON API provides several interfaces to handle image data. All these interfaces are based on maxon::ImageBaseInterface:
- Note
- Typically these image classes represent uncompressed image data. But it is also possible that an image could store compressed or non-RGB data.
-
A maxon::ImageRef can be obtained from a BaseBitmap using BaseBitmap::GetImageRef(). See BaseBitmap Manual.
const maxon::ImageRef image = maxon::ImageClasses::IMAGE().Create()
iferr_return;
const maxon::PixelFormat rgbFormat = maxon::PixelFormats::RGB::U8();
const auto storageType = maxon::ImagePixelStorageClasses::Normal();
image.Init(width, height, storageType, rgbFormat)
iferr_return;
const maxon::BITS bitsPerPixel = rgbFormat.GetBitsPerPixel();
{
{
{
return maxon::SafeConvert<maxon::UChar>(randomValue);
};
pixelArray[0] = GetRandomValue();
pixelArray[1] = GetRandomValue();
pixelArray[2] = GetRandomValue();
}
}
const maxon::MediaOutputUrlRef png = maxon::ImageSaverClasses::Png().Create()
iferr_return;
maxon::MediaSessionRef session;
const maxon::ImageTextureRef textureRef = maxon::ImageTextureClasses::TEXTURE().Create()
iferr_return;
This class represents the number of bits in a pixel format.
Definition: gfx_image_bits.h:15
Definition: basearray.h:413
MAXON_ATTRIBUTE_FORCE_INLINE const T * GetFirst() const
Definition: basearray.h:1081
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1124
Definition: lib_math.h:19
FLOAT Get01()
Returns the next random value in the range of [0..1].
The TimeValue class encapsulates a timer value.
Definition: timevalue.h:33
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:190
Float64 Float
Definition: apibase.h:199
unsigned char UChar
unsigned 8 bit character
Definition: apibase.h:187
SETPIXELHANDLERFLAGS
Flags to control the SetPixelHandler functions.
Definition: gfx_image_pixelformat.h:66
@ IMAGE
Adds a subImage to a texture. Images are only allowed under Textures.
#define iferr_return
Definition: resultbase.h:1465
Several functions use this helper structure to pass the position within an image and number of pixels...
Definition: gfx_image_pixelhandler.h:18
Several functions use this helper structure to pass the image data to functions.
Definition: gfx_image_pixelformat.h:136
Definition: gfx_image_pixelhandler.h:134
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > SetPixel(const ImagePos &pos, const PixelConstBuffer &buffer, SETPIXELFLAGS flags) const
Definition: gfx_image_pixelhandler.h:191
ImageBaseInterface
maxon::ImageBaseInterface is the base interface of all image interfaces.
An image typically stores bitmap data. This data is accessed with:
An image can have multiple channels / components:
Changes to the image can be detected with this observable:
- ObservableRegionChanged: Is fired as soon as anybody modifies the pixel data.
maxon::ImageBaseInterface is based on
const maxon::ImageTextureRef sourceImage = maxon::ImageTextureClasses::TEXTURE().Create()
iferr_return;
const maxon::PixelFormat format = maxon::PixelFormats::RGB::U8();
const auto offset = format.GetChannelOffsets();
const maxon::Int height = sourceImage.GetHeight();
const maxon::Int size = width * format.GetChannelCount();
const maxon::BITS bitsPerPixel = format.GetBitsPerPixel();
const maxon::ImageRef invertedImage = maxon::ImageClasses::IMAGE().Create()
iferr_return;
const auto storageType = maxon::ImagePixelStorageClasses::Normal();
invertedImage.Init(width, height, storageType, format)
iferr_return;
const maxon::ColorProfile colorProfile { };
{
{
data[i] = 255 - data[i];
});
}
const maxon::ImageTextureRef targetImage = maxon::ImageTextureClasses::TEXTURE().Create()
iferr_return;
const maxon::MediaOutputUrlRef png = maxon::ImageSaverClasses::Png().Create()
iferr_return;
static auto Dynamic(FROMTYPE from, INDEXTYPE to, const LOOP &obj, Int threadCnt=PARALLELFOR_USEMAXIMUMTHREADS, const Int granularity=PARALLELFOR_DEFAULTGRANULARITY, JobQueueInterface *queue=JOBQUEUE_CURRENT) -> decltype(obj(to))
Definition: parallelfor.h:234
Definition: gfx_image_pixelhandler.h:32
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > GetPixel(const ImagePos &pos, const PixelMutableBuffer &buffer, GETPIXELFLAGS flags) const
Definition: gfx_image_pixelhandler.h:96
ImageTextureInterface
maxon::ImageTextureInterface represents a texture object with one or multiple images and layers.
The namespace maxon::ImageTextureClasses contains published objects with implementations of maxon::ImageTextureInterface. The default implementation is maxon::ImageTextureClasses::TEXTURE in gfx_image.h
.
const maxon::ImageTextureRef image = maxon::ImageTextureClasses::TEXTURE().Create()
iferr_return;
const maxon::MediaOutputUrlRef jpg = maxon::ImageSaverClasses::Jpg().Create()
iferr_return;
maxon::DataDictionary exportSettings;
exportSettings.Set(maxon::MEDIASESSION::EXPORT::QUALITY, 0.8_f)
iferr_return;
image.Set(maxon::IMAGEPROPERTIES::IMAGE::EXPORTSETTINGS, exportSettings)
iferr_return;
ImageInterface
maxon::ImageInterface represents a single image of a maxon::ImageTextureInterface.
The namespace maxon::ImageClasses contains published objects with implementations of maxon::ImageInterface. The default implementation is maxon::ImageClasses::IMAGE in gfx_image.h
.
ImageLayerInterface
maxon::ImageLayerInterface represents a single layer within a maxon::ImageInterface. The namespace maxon::ImageLayerClasses contains published objects with implementations of maxon::ImageLayerInterface. The default implementation is maxon::ImageLayerClasses::RASTER in gfx_image.h
.
Utility
Utility functions to handle images:
Further Reading