ImageGear for C and C++ on Windows v19.1 - Updated
Using Direct Access via IG_image_DIB_raster_pntr_get (called only once)
User Guide > Concepts > Migrating from ImageGear v14 > Pixel Access Examples > Using Direct Access via IG_image_DIB_raster_pntr_get (called only once)

 
Copy Code
// Create a filled RGB24 image using direct pixel access
// The algorithm has been changed slightly to simplify this example
HIGEAR createFilledRGB24(AT_DIMENSION w, AT_DIMENSION h, AT_RGBQUAD c)
{
    // Create image (initially filled with black pixels)
    HIGEAR hImage = createRGB24(w, h);
    // Note: Pixel access mode does not matter here, since the pixel 
    // data is being accessed directly by getting a pointer to it
    // Get a pointer to the pixel data
    LPAT_VOID lpPixelVoid;
    IG_image_DIB_raster_pntr_get(hImage, 0, &lpPixelVoid);
    LPAT_PIXEL lpPixel = (LPAT_PIXEL) lpPixelVoid;
    // Loop through rasters in the image
    for (AT_PIXPOS y = 0; y < h; y++)
    {
        // Set each pixel to the fill color
        for (AT_PIXPOS x = 0; x < w; x++)
        {
            *lpPixel++ = c.rgbRed;
            *lpPixel++ = c.rgbGreen;
            *lpPixel++ = c.rgbBlue;
        }
        // Rasters are DWORD-padded (raster size is multiple of 4)
        // so advance to the beginning of the next raster
        lpPixel += w % 4;
    }
    return hImage;
}