ImageGear for C and C++ on Windows v19.8 - Updated
IG_DIB_pixel_set
API Reference Guide > Core Component API Reference > Core Component Functions Reference > DIB Functions > IG_DIB_pixel_set

This function sets the pixel, at the location pointed to by lpPixel, into the image bitmap of image hIGear at coordinates (nXpos, nYpos).

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_DIB_pixel_set ( 
        HIGEAR hIGear, 
        AT_PIXPOS nXpos, 
        AT_PIXPOS nYpos, 
        const LPAT_PIXEL lpPixel
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of an image.
nXpos AT_PIXPOS X offset (in pixels) from beginning of raster line. First pixel on line is pixel number 0.
nYpos AT_PIXPOS Raster line number. 0 is top line.
pPixel const LPAT_PIXEL Far pointer to byte containing pixel, or to a 3-byte area if a 24-bit pixel.

Return Value:

Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Sample:

Pixel Access

Example:

 
Copy Code
HIGEAR hIGear;/* HIGEAR handle of image                                          */
AT_PIXEL cPixelValue[3];/* 3 bytes in case 24-bit image                                                         */
/* Set upper-leftmost pixel in image, to max pixel value:                                                                               */
cPixelValue[0] = cPixelValue[1] = cPixelValue[2] = 255;
IG_DIB_pixel_set ( hIGear, 0, 0, &cPixelValue[0] );

Remarks:

The pixel is assumed to have the same number of Bits Per Pixel as the image, and if it is 1 or 4 bits, it is assumed to be right justified (that is, in the least significant bits) at location lpPixel. If the image is 24-bit, 3 bytes are transferred. Normally, these bytes will be in the order of Blue-Green-Red (unless the order of the image bitmap bytes has been changed by a call such as IG_IP_swap_red_blue()).

ImageGear's pixel access functions consider the coordinates (0,0) to refer to the upper left-hand corner of the bitmap data. They do not follow the DIB's orientation, which considers (0,0) to refer to the lower left-hand corner of the bitmap.

If the image you are modifying is 1-bit, you must convert the image from run-end encoded to a standard DIB, before you can set pixel values. Please see the section Accessing Image Pixels for details.