Using Pixel Access Functions in Legacy Mode
|
Copy Code
|
// Create a filled RGB24 image using pixel access functions (legacy mode)
HIGEAR createFilledRGB24(AT_DIMENSION w, AT_DIMENSION h, AT_RGBQUAD c)
{
// Create image (initially filled with black pixels)
HIGEAR hImage = createRGB24(w, h);
// Set pixel access mode to legacy (even though it's the default)
AT_MODE pixAccessMode = IG_PIX_ACCESS_MODE_LEGACY;
IG_gctrl_item_set("DIB.PIX_ACCESS_USE_LEGACY_MODE", AM_TID_AT_MODE,
&pixAccessMode, sizeof(pixAccessMode), NULL);
// Create a raster with the desired color (BGR channel order!)
LPAT_PIXEL lpRaster = (LPAT_PIXEL) malloc(w * 3);
for (AT_PIXPOS x = 0; x < w; x++)
{
lpRaster[x * 3 + 0] = c.rgbBlue;
lpRaster[x * 3 + 1] = c.rgbGreen;
lpRaster[x * 3 + 2] = c.rgbRed;
}
// Loop over the image and set each raster
for (AT_PIXPOS y = 0; y < h; y++)
IG_DIB_raster_set(hImage, y, lpRaster, IG_PIXEL_UNPACKED);
free(lpRaster);
return hImage;
}
|