Method 2: Pixel Access Functions
As with previous versions of ImageGear, there are pixel access functions that can be used to access pixel data associated with a HIGEAR image. These functions have names like IG_DIB_area_get/set, IG_DIB_raster_get/set, IG_DIB_pixel_get/set, and so on. The pixel access functions have two modes of operation: legacy (prior to 14.5) and new (14.5 and beyond). The default mode is legacy, in which these functions behave the same way they did before 14.5. So if you have existing code using pixel access functions, you shouldn't need to update it for 14.5. If you're considering using the pixel access functions for new code and you don't need to work directly with higher bit depths, uncommon color spaces, or alpha/extra channel data included with the main channel data, we recommend using the legacy mode. This mode shields you from the added complexity of these new formats.
If you want to use the new formats, or achieve maximum efficiency, you can use the new mode of pixel access to get more direct access to the new storage system. If you use the new mode, you must be aware of the following differences as compared to legacy mode:
- For RGB images, color channel order is RGB (in legacy mode, it's BGR)
- You can access higher bit depths (i.e. 36-bit, 48-bit RGB)
- You can access other color spaces (i.e. LAB, YUV)
- Alpha and extra channel data is included on a per-pixel basis. For example, if you have a 24-bit RGB image with an 8-bit alpha channel, the pixel data will look like RGBA, RGBA, RGBA and so on, where R, G, B, and A are each one byte.
- Pixel packing and raster padding are as follows:
Packing Mode |
Legacy |
New |
IG_PIXEL_PACKED |
1, 4bpp packed, DWORD padding |
1bpp packed, DWORD padding |
IG_PIXEL_UNPACKED |
No packing, BYTE padding |
No packing, DWORD padding |
Note that 1-bit channels are the only channels that are packed in the new mode - 8 pixels stored in each byte. All other channel depths are stored as 1, 2, or 4 byte values. A channel value with depth of 2-8 bits will be stored in one byte, 9-16 bits in two bytes, and 17-32 bits in four bytes. Channel values with depths of 33-64 bits are possible on 64-bit platforms and are stored in eight bytes.
To use the new mode, you need to set the DIB.PIX_ACCESS_USE_LEGACY_MODE global control parameter to IG_PIX_ACCESS_MODE_NEW. For example:
|
Copy Code
|
AT_MODE pixAccessMode = IG_PIX_ACCESS_MODE_NEW;
IG_gctrl_item_set("DIB.PIX_ACCESS_USE_LEGACY_MODE", AM_TID_AT_MODE,
&pixAccessMode, sizeof(pixAccessMode), NULL);
|