MPLAB® Harmony Graphics Suite
|
Graphics utilities is primarily responsible for managing and decoding assets such as images, fonts, and strings. It provides the means for interacting with asset data, complex data decoding, data decompression, and string asset lookup. The library also abstractly handles the accessing of external memory sources during asset decoding.
The library serves four main purposes:
All assets share a common header “GFXU_AssetHeader”. This header is defined as follows:
typedef struct GFXU_AssetHeader_t { uint32_t type; uint32_t dataLocation; void* dataAddress; uint32_t dataSize; } GFXU_AssetHeader;
Image Asset Descriptor
The image asset descriptor is defined as follows:
typedef struct GFXU_ImageAsset_t { GFXU_AssetHeader header; GFXU_ImageFormat format; uint32_t width; uint32_t height; GFX_ColorMode colorMode; GFXU_ImageCompressionType compType; GFX_Bool useMask; GFX_Color mask; GFXU_PaletteAsset* palette; } GFXU_ImageAsset;
Image decoding with the GFX Utilities library is meant to be simple and straightforward. The library provides a single API that clients can use to render image assets.
GFX_Result GFXU_DrawImage(GFXU_ImageAsset* img, int32_t src_x, int32_t src_y, int32_t src_width, int32_t src_height, int32_t dest_x, int32_t dest_y, GFXU_MemoryIntf* read_cb, GFXU_ExternalAssetReader** reader);
This function accepts a pointer to an image header and rendering dimensions for rendering sub-sections of the image. The last two arguments refer to external memory access and will be described later. If the type of an image specifies an image decoder, then that decoder is automatically invoked by the library. If an image is stored as an index map, then its associated palette is referenced during decoding.
Image Palette Asset
Palette assets are color lookup tables that can be referenced when decoding indexed images. The index format can be 1bpp, 4bpp, or 8bpp large, resulting in a maximum of 1, 16, or 256 colors, respectively.
The palette descriptor is defined as follows:
typedef struct GFXU_PaletteAsset_t { GFXU_AssetHeader header; uint32_t colorCount; GFX_ColorMode colorMode; } GFXU_PaletteAsset;
Font Assets
Fonts are chunks of data that contain color information for drawing individual linguistic characters. Font glyph data can either be stored by using a 1bpp or 8bpp format. The larger format is for storing transparency information for use in drawing anti-aliased characters.
The font descriptor is as follows:
typedef struct GFXU_FontAsset_t { GFXU_AssetHeader header; uint32_t height; uint32_t ascent; uint32_t descent; uint32_t baseline; GFXU_FontAssetBPP bpp; GFXU_FontGlyphIndexTable* indexTable; } GFXU_FontAsset;
Font Index Table
Each font provides an index table for quickly locating pixel data inside the font data chunk. The index table specifies the number of individual ranges or series of glyphs that it provides, followed by the actual range data.
A typical font range table entry is as follows:
typedef struct GFXU_FontGlyphRange_t { uint32_t glyphCount; uint32_t startID; uint32_t endID; uint8_t* lookupTable; } GFXU_FontGlyphRange;
Font Lookup Table
The font lookup table contains location and size data for referencing glyphs in the font data chunk. This table provides with values to allow geometric analysis of font glyphs without having to render any data.
The data in a font lookup table is defined as follows:
Repeating 'glyphCount' number of times:
Font Glyph Raster Data
Font raster data is stored in a single chunk of memory and is referenced through the previously mentioned lookup tables. When rendering a font, the decoder uses the code point to find the appropriate lookup table and then uses that table to get the offset of the glyph. The width value says how large the glyph is in pixels, which could be 1bpp or 8bpp, depending on the anti-alias setting. The decoder then reads "width" number of pixels starting at "offset". The pixel data offsets are always byte-aligned.
String Table
The graphics utilities library defines a special asset called the "String Table". This table is a predefined lookup table of strings, languages, and their associated fonts. This construct makes runtime localization possible for user interface libraries.
Name |
Description |
This section describes the interface for the Graphics Utilities Library. | |
|
MPLAB® Harmony Graphics Suite
|