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

 
Copy Code
// Create a filled RGB24 image using direct pixel access
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
    // Create a raster with the desired color (RGB channel order!)
    LPAT_PIXEL lpSrcRaster = (LPAT_PIXEL) malloc(w * 3);
    for (AT_PIXPOS x = 0; x < w; x++)
    {
        lpSrcRaster[x * 3 + 0] = c.rgbRed;
        lpSrcRaster[x * 3 + 1] = c.rgbGreen;
        lpSrcRaster[x * 3 + 2] = c.rgbBlue;
    }
    // Loop over the image and set each raster
    for (AT_PIXPOS y = 0; y < h; y++)
    {
        // Get a pointer to the image raster
        LPAT_VOID lpDstRaster;
        IG_image_DIB_raster_pntr_get(hImage, y, &lpDstRaster);
        // Copy the source raster to image raster
        memcpy(lpDstRaster, lpSrcRaster, w * 3);
    }
    free(lpSrcRaster);
    return hImage;
}
Is this page helpful?
Yes No
Thanks for your feedback.