![]() |
NDEVR
API Documentation
|
The core class for reading/writing and storing images in an optimized way. More...
Public Member Functions | |
| void | addFormatHandler (ImageFormatHandler *handler) |
| Registers a format handler with this ImageFactory instance. | |
| void | addImageCompressed (const StringView &id, const Buffer< uint01 > &compressed, bool clear_other) |
| Adds a compressed image to the cache, auto-detecting the compression format. | |
| void | addImageCompressed (const StringView &id, const StringView &extension, const Buffer< uint01 > &compressed, bool clear_other) |
| Adds a compressed image with a known format extension to the cache. | |
| void | addImageCompressed (const StringView &id, const StringView &extension, const Buffer< uint01 > &compressed, const Vector< 2, uint04 > &size, bool clear_other) |
| Adds a compressed image with a known format extension and explicit dimensions to the cache. | |
| void | addImageFile (const StringView &id, const File &file, bool clear_other) |
| Adds an image to the cache by reading from a file on disk. | |
| void | addImageUncompressed (const StringView &id, const Buffer< uint01 > &uncompressed, bool clear_other) |
| Adds an uncompressed (raw ARGB) image to the cache. | |
| void | addImageUncompressed (const StringView &id, const Buffer< uint01 > &uncompressed, const Vector< 2, uint04 > &size, bool clear_other) |
| Adds an uncompressed (raw ARGB) image with explicit dimensions to the cache. | |
| Dictionary< String, DynamicPointer< ImageCacheData > > | cachedData () const |
| Returns a copy of the internal cache dictionary mapping image IDs to their cache data. | |
| const Buffer< uint01 > & | calculateAndGetDecompressed (ImageCacheData &data) |
| Ensures the decompressed data is available, decompressing if necessary, and returns it. | |
| bool | canRead (const File &file) |
| Checks whether any registered handler can read the given file. | |
| void | clearAllImageData (const StringView &id) |
| Removes all cached data (compressed, decompressed, metadata) for the given image. | |
| StringView | compressionFormat (const StringView &id) |
| Returns the compression format extension of the cached image's compressed data. | |
| void | convertColorTheme (const Buffer< std::pair< LABColor, LABColor > > &color, String &image, bool preserve_brightness, bool preserve_alpha) |
| Remaps the colors of a cached image using LAB color space substitutions. | |
| void | convertDirectory (const File &directory, const StringView &from_ext, const StringView &to_ext) |
| Converts all images in a directory from one format to another. | |
| void | copyImage (const StringView &id_destination, const StringView &id_source) |
| Copies cached image data from one identifier to another. | |
| bool | determineCompressionFormat (ImageCacheData &data) |
| Attempts to determine the compression format of the image's compressed data by inspecting its header bytes. | |
| ImageReadPointer | getCompressed (const StringView &id, StringView default_extension=".png") |
| Retrieves the compressed data for the cached image in its current or default format. | |
| ImageReadPointer | getCompressedInFormat (const StringView &id, const Buffer< StringView > &acceptable_formats) |
| Retrieves the compressed data for the cached image in one of the acceptable formats. | |
| ImageReadPointer | getCompressedInFormat (const StringView &id, const StringView &extension) |
| Retrieves the compressed data for the cached image, converting to a specific format. | |
| ImageWritePointer | getEditableData (const StringView &id) |
| Returns a writable pointer to the image cache data with a write lock acquired. | |
| ImageReadPointer | getMetaData (const StringView &id) |
| Retrieves metadata for the cached image, reading it from the source if necessary. | |
| ImageReadPointer | getReadOnlyData (const StringView &id) const |
| Returns a read-only pointer to the image cache data with a read lock acquired. | |
| ImageReadPointer | getSize (const StringView &id) |
| Retrieves the image dimensions without fully decompressing the image data. | |
| virtual void | getSupportedFormats (AlocatingAlignedBuffer< FileFormat, 64 > &formats, bool is_read) const |
| Populates a buffer with all file formats supported by this factory and its handlers. | |
| ImageReadPointer | getUncompressed (const StringView &id, bool ensure_valid_transparancy=false) |
| Retrieves the uncompressed (raw ARGB) pixel data for the cached image. | |
| void | handleMetaData (ImageCacheData &data) |
| Reads and processes metadata (e.g., EXIF) from the image data using registered handlers. | |
| bool | hasImage (const StringView &id) const |
| Checks whether an image with the given identifier exists in the cache. | |
| bool | hasTransparency (ImageCacheData &data) |
| Determines whether the image truly contains transparent pixels (not just an alpha channel). | |
| Time | modifiedTime (const StringView &id) const |
| Returns the last modification time of the cached image. | |
| String | optimizedWriteFileName (const StringView &id, const Buffer< String > &optional_extensions=Buffer< String >()) |
| Determines the optimal file name and extension for writing the image to disk. | |
| void | readFromBMP (ImageCacheData &data) |
| Reads image data from a BMP-formatted source into the cache data. | |
| bool | readFromCompressed (ImageCacheData &data) |
| Reads image data from the compressed_data buffer in the cache data using registered handlers. | |
| bool | readFromFile (ImageCacheData &data, StringView format_extension=StringView()) |
| Reads image data from the file referenced in the cache data. | |
| void | removeFormatHandler (const UUID &handler) |
| Removes a previously registered format handler by its UUID. | |
| void | setWriteQuality (fltp08 quality) |
| Sets the quality level used when writing compressed images (e.g., JPEG quality). | |
| void | writeToFile (const StringView &id, const File &file) |
| Writes the cached image to a file on disk. | |
Static Public Member Functions | |
| static void | AddFormatHandler (ImageFormatHandler *handler) |
| Registers a format handler with the global static handler registry, available to all ImageFactory instances. | |
| static ImageFactory & | DefaultFactory () |
| Returns the singleton default ImageFactory instance. | |
| static FileFormat | PNGFormat () |
| Creates and returns a FileFormat descriptor for the PNG image format. | |
| static void | ReadJPG (const uint01 *input, uint04 input_length, uint01 *buffer, bool has_alpha, uint04 dst_line_span, const Vector< 2, uint04 > &offset) |
| Decodes JPEG data from a memory buffer into a raw pixel buffer. | |
| static void | RemoveFormatHandler (const UUID &handler) |
| Removes a format handler from the global static handler registry. | |
| static void | Resize (const Buffer< uint01 > &input, const Vector< 2, uint04 > &in_size, const Vector< 2, uint04 > &out_size, Buffer< uint01 > &output) |
| Resizes raw pixel data from one resolution to another using bilinear or nearest-neighbor sampling. | |
| static void | WriteToFile (const uint01 *data, Vector< 2, uint04 > size, uint04 px_size, const File &file, fltp08 write_quality=1.0) |
| Writes raw pixel data to a file on disk in the format determined by the file extension. | |
Protected Attributes | |
| Dictionary< String, DynamicPointer< ImageCacheData > > | m_cached_data |
| Cache mapping image identifiers to their associated data. | |
| Dictionary< UUID, ImageFormatHandler * > | m_format_handlers |
| Instance-level registered format handlers keyed by UUID. | |
| RWLock | m_lock |
| Read-write lock protecting access to the cache and handler dictionaries. | |
| fltp08 | m_write_quality = 1.0 |
| Default write quality for compressed output (0.0 to 1.0). | |
Static Protected Attributes | |
| static Dictionary< UUID, ImageFormatHandler * > | s_format_handlers |
| Global static registry of format handlers shared across all ImageFactory instances. | |
The core class for reading/writing and storing images in an optimized way.
All raw data is stored in ARGB 32-bit format. Compressed images consist of an in-memory format such as jpeg/png/etc
Definition at line 210 of file ImageFactory.h.
|
static |
Registers a format handler with the global static handler registry, available to all ImageFactory instances.
| [in] | handler | Pointer to the ImageFormatHandler to register globally. |
| void ImageFactory::addFormatHandler | ( | ImageFormatHandler * | handler | ) |
Registers a format handler with this ImageFactory instance.
| [in] | handler | Pointer to the ImageFormatHandler to add. Ownership is not transferred. |
| void ImageFactory::addImageCompressed | ( | const StringView & | id, |
| const Buffer< uint01 > & | compressed, | ||
| bool | clear_other ) |
Adds a compressed image to the cache, auto-detecting the compression format.
| [in] | id | The unique string identifier for the image. |
| [in] | compressed | The compressed image data buffer. |
| [in] | clear_other | Whether to clear other cached representations of this image. |
| void ImageFactory::addImageCompressed | ( | const StringView & | id, |
| const StringView & | extension, | ||
| const Buffer< uint01 > & | compressed, | ||
| bool | clear_other ) |
Adds a compressed image with a known format extension to the cache.
| [in] | id | The unique string identifier for the image. |
| [in] | extension | The compression format extension (e.g., ".png", ".jpg"). |
| [in] | compressed | The compressed image data buffer. |
| [in] | clear_other | Whether to clear other cached representations of this image. |
| void ImageFactory::addImageCompressed | ( | const StringView & | id, |
| const StringView & | extension, | ||
| const Buffer< uint01 > & | compressed, | ||
| const Vector< 2, uint04 > & | size, | ||
| bool | clear_other ) |
Adds a compressed image with a known format extension and explicit dimensions to the cache.
| [in] | id | The unique string identifier for the image. |
| [in] | extension | The compression format extension (e.g., ".png", ".jpg"). |
| [in] | compressed | The compressed image data buffer. |
| [in] | size | The image dimensions (width, height) in pixels. |
| [in] | clear_other | Whether to clear other cached representations of this image. |
| void ImageFactory::addImageFile | ( | const StringView & | id, |
| const File & | file, | ||
| bool | clear_other ) |
Adds an image to the cache by reading from a file on disk.
| [in] | id | The unique string identifier for the image. |
| [in] | file | The file to read image data from. |
| [in] | clear_other | Whether to clear other cached representations (compressed/decompressed) of this image. |
| void ImageFactory::addImageUncompressed | ( | const StringView & | id, |
| const Buffer< uint01 > & | uncompressed, | ||
| bool | clear_other ) |
Adds an uncompressed (raw ARGB) image to the cache.
| [in] | id | The unique string identifier for the image. |
| [in] | uncompressed | The raw uncompressed pixel data buffer. |
| [in] | clear_other | Whether to clear other cached representations of this image. |
Referenced by MaterialRaster::MaterialRaster(), OpenCVImageRaster::setup(), MaterialRaster::updateImage(), and OpenCVImageRaster::updateImage().
| void ImageFactory::addImageUncompressed | ( | const StringView & | id, |
| const Buffer< uint01 > & | uncompressed, | ||
| const Vector< 2, uint04 > & | size, | ||
| bool | clear_other ) |
Adds an uncompressed (raw ARGB) image with explicit dimensions to the cache.
| [in] | id | The unique string identifier for the image. |
| [in] | uncompressed | The raw uncompressed pixel data buffer. |
| [in] | size | The image dimensions (width, height) in pixels. |
| [in] | clear_other | Whether to clear other cached representations of this image. |
| Dictionary< String, DynamicPointer< ImageCacheData > > ImageFactory::cachedData | ( | ) | const |
Returns a copy of the internal cache dictionary mapping image IDs to their cache data.
| const Buffer< uint01 > & ImageFactory::calculateAndGetDecompressed | ( | ImageCacheData & | data | ) |
Ensures the decompressed data is available, decompressing if necessary, and returns it.
| [in] | data | The image cache data to decompress if needed. |
| bool ImageFactory::canRead | ( | const File & | file | ) |
Checks whether any registered handler can read the given file.
| [in] | file | The file to check. |
| void ImageFactory::clearAllImageData | ( | const StringView & | id | ) |
Removes all cached data (compressed, decompressed, metadata) for the given image.
| [in] | id | The unique string identifier for the image to clear. |
| StringView ImageFactory::compressionFormat | ( | const StringView & | id | ) |
Returns the compression format extension of the cached image's compressed data.
| [in] | id | The unique string identifier for the image. |
| void ImageFactory::convertColorTheme | ( | const Buffer< std::pair< LABColor, LABColor > > & | color, |
| String & | image, | ||
| bool | preserve_brightness, | ||
| bool | preserve_alpha ) |
Remaps the colors of a cached image using LAB color space substitutions.
| [in] | color | Buffer of LAB color pairs (source, target) defining the color mapping. |
| [in] | image | The image identifier to convert (modified in place). |
| [in] | preserve_brightness | Whether to preserve the original pixel brightness during conversion. |
| [in] | preserve_alpha | Whether to preserve the original alpha channel during conversion. |
| void ImageFactory::convertDirectory | ( | const File & | directory, |
| const StringView & | from_ext, | ||
| const StringView & | to_ext ) |
Converts all images in a directory from one format to another.
| [in] | directory | The directory containing image files. |
| [in] | from_ext | The source format extension to convert from. |
| [in] | to_ext | The target format extension to convert to. |
| void ImageFactory::copyImage | ( | const StringView & | id_destination, |
| const StringView & | id_source ) |
Copies cached image data from one identifier to another.
| [in] | id_destination | The target image identifier. |
| [in] | id_source | The source image identifier. |
|
static |
Returns the singleton default ImageFactory instance.
Referenced by MaterialRaster::MaterialRaster(), ImageChooserGallery::fillWithImages(), OpenCVImageRaster::setup(), GLESImageData::update(), MaterialRaster::updateImage(), and OpenCVImageRaster::updateImage().
| bool ImageFactory::determineCompressionFormat | ( | ImageCacheData & | data | ) |
Attempts to determine the compression format of the image's compressed data by inspecting its header bytes.
| [in] | data | The image cache data whose compression_format field will be set. |
| ImageReadPointer ImageFactory::getCompressed | ( | const StringView & | id, |
| StringView | default_extension = ".png" ) |
Retrieves the compressed data for the cached image in its current or default format.
| [in] | id | The unique string identifier for the image. |
| [in] | default_extension | The preferred compression format if conversion is needed. |
| ImageReadPointer ImageFactory::getCompressedInFormat | ( | const StringView & | id, |
| const Buffer< StringView > & | acceptable_formats ) |
Retrieves the compressed data for the cached image in one of the acceptable formats.
| [in] | id | The unique string identifier for the image. |
| [in] | acceptable_formats | A buffer of acceptable format extensions, in order of preference. |
| ImageReadPointer ImageFactory::getCompressedInFormat | ( | const StringView & | id, |
| const StringView & | extension ) |
Retrieves the compressed data for the cached image, converting to a specific format.
| [in] | id | The unique string identifier for the image. |
| [in] | extension | The required compression format extension. |
| ImageWritePointer ImageFactory::getEditableData | ( | const StringView & | id | ) |
Returns a writable pointer to the image cache data with a write lock acquired.
| [in] | id | The unique string identifier for the image. |
| ImageReadPointer ImageFactory::getMetaData | ( | const StringView & | id | ) |
Retrieves metadata for the cached image, reading it from the source if necessary.
| [in] | id | The unique string identifier for the image. |
| ImageReadPointer ImageFactory::getReadOnlyData | ( | const StringView & | id | ) | const |
Returns a read-only pointer to the image cache data with a read lock acquired.
| [in] | id | The unique string identifier for the image. |
| ImageReadPointer ImageFactory::getSize | ( | const StringView & | id | ) |
Retrieves the image dimensions without fully decompressing the image data.
| [in] | id | The unique string identifier for the image. |
|
virtual |
Populates a buffer with all file formats supported by this factory and its handlers.
| [in] | formats | The buffer to populate with supported FileFormat entries. |
| [in] | is_read | Whether to return read-supported formats (true) or write-supported formats (false). |
| ImageReadPointer ImageFactory::getUncompressed | ( | const StringView & | id, |
| bool | ensure_valid_transparancy = false ) |
Retrieves the uncompressed (raw ARGB) pixel data for the cached image.
| [in] | id | The unique string identifier for the image. |
| [in] | ensure_valid_transparancy | Whether to verify and set the transparency flag accurately. |
Referenced by GLESImageData::update().
| void ImageFactory::handleMetaData | ( | ImageCacheData & | data | ) |
Reads and processes metadata (e.g., EXIF) from the image data using registered handlers.
| [in] | data | The image cache data to populate with metadata. |
| bool ImageFactory::hasImage | ( | const StringView & | id | ) | const |
Checks whether an image with the given identifier exists in the cache.
| [in] | id | The unique string identifier for the image. |
Referenced by GLESImageData::update().
| bool ImageFactory::hasTransparency | ( | ImageCacheData & | data | ) |
Determines whether the image truly contains transparent pixels (not just an alpha channel).
| [in] | data | The image cache data to check. |
| Time ImageFactory::modifiedTime | ( | const StringView & | id | ) | const |
Returns the last modification time of the cached image.
| [in] | id | The unique string identifier for the image. |
Referenced by GLESImageData::needsUpdate().
| String ImageFactory::optimizedWriteFileName | ( | const StringView & | id, |
| const Buffer< String > & | optional_extensions = Buffer< String >() ) |
Determines the optimal file name and extension for writing the image to disk.
| [in] | id | The unique string identifier for the image. |
| [in] | optional_extensions | Optional buffer of preferred extensions to consider. |
|
static |
Creates and returns a FileFormat descriptor for the PNG image format.
| void ImageFactory::readFromBMP | ( | ImageCacheData & | data | ) |
Reads image data from a BMP-formatted source into the cache data.
| [in] | data | The image cache data to populate. |
| bool ImageFactory::readFromCompressed | ( | ImageCacheData & | data | ) |
Reads image data from the compressed_data buffer in the cache data using registered handlers.
| [in] | data | The image cache data containing compressed data to decompress. |
| bool ImageFactory::readFromFile | ( | ImageCacheData & | data, |
| StringView | format_extension = StringView() ) |
Reads image data from the file referenced in the cache data.
| [in] | data | The image cache data containing the file reference. |
| [in] | format_extension | Optional format hint for reading. If empty, the format is auto-detected. |
|
static |
Decodes JPEG data from a memory buffer into a raw pixel buffer.
| [in] | input | Pointer to the compressed JPEG data. |
| [in] | input_length | Length of the compressed data in bytes. |
| [in] | buffer | Destination buffer for decompressed pixel data. |
| [in] | has_alpha | Whether the destination buffer includes an alpha channel. |
| [in] | dst_line_span | The byte stride of each row in the destination buffer. |
| [in] | offset | Pixel offset (x, y) into the destination buffer where writing begins. |
|
static |
Removes a format handler from the global static handler registry.
| [in] | handler | The UUID of the handler to remove. |
| void ImageFactory::removeFormatHandler | ( | const UUID & | handler | ) |
|
static |
Resizes raw pixel data from one resolution to another using bilinear or nearest-neighbor sampling.
| [in] | input | The source raw pixel data buffer. |
| [in] | in_size | The source image dimensions (width, height). |
| [in] | out_size | The target image dimensions (width, height). |
| [in] | output | The destination buffer for the resized pixel data. |
Referenced by GLESImageData::update().
| void ImageFactory::setWriteQuality | ( | fltp08 | quality | ) |
Sets the quality level used when writing compressed images (e.g., JPEG quality).
| [in] | quality | The write quality from 0.0 (lowest) to 1.0 (highest). |
|
static |
Writes raw pixel data to a file on disk in the format determined by the file extension.
| [in] | data | Pointer to the raw pixel data. |
| [in] | size | The image dimensions (width, height) in pixels. |
| [in] | px_size | The number of bytes per pixel. |
| [in] | file | The destination file to write. |
| [in] | write_quality | The compression quality from 0.0 (lowest) to 1.0 (highest). |
| void ImageFactory::writeToFile | ( | const StringView & | id, |
| const File & | file ) |
Writes the cached image to a file on disk.
| [in] | id | The unique string identifier for the image. |
| [in] | file | The destination file to write to. |