ImageGear for C and C++ on Windows v20.0 - Updated
Using Pixel Access Functions in New Mode
User Guide > Concepts > Migrating from ImageGear v14 > Pixel Access Examples > Using Pixel Access Functions in New Mode

 
Copy Code
// Create a filled RGB24 image using pixel access functions (new 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 new
    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);
    // Create a raster with the desired color (RGB channel order!)
    LPAT_PIXEL lpRaster = (LPAT_PIXEL) malloc(w * 3);
    for (AT_PIXPOS x = 0; x < w; x++)
    {
        lpRaster[x * 3 + 0] = c.rgbRed;
        lpRaster[x * 3 + 1] = c.rgbGreen;
        lpRaster[x * 3 + 2] = c.rgbBlue;
    }
    // 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;
}
Is this page helpful?
Yes No
Thanks for your feedback.