ImageGear for C and C++ on Linux v18.8 - Updated
IG_pixel_create
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Pixel Functions > IG_pixel_create

This function creates a new pixel object based on specified attributes.

Declaration:

 
Copy Code
HIGPIXEL ACCUAPI IG_pixel_create(
        AT_INT channelCount,
        AT_DEPTH bitsPerChannel
);

Arguments:

Name Type Description
channelCount AT_INT Number of channels to allocate.
bitsPerChannel AT_DEPTH Bits per channel to allocate.

Return Value:

Handle of new pixel object.

Supported Raster Image Formats:

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

Example:

 
Copy Code
AT_ERRCOUNT nErrcount;  /* Number of errors on stack */
HIGEAR hImage;          /* Handle of image */
HIGPIXEL hPix;          /* Handle of pixel */
AT_INT ChannelCount;    /* Number of channels in image */
AT_INT BitsPerChannel;  /* Bits per channel in image */
nErrcount = IG_load_file("test.jpg", &hImage);
nErrcount = IG_image_channel_count_get(hImage, &ChannelCount);
nErrcount = IG_image_bits_per_channel_get(hImage, &BitsPerChannel);
hPix = IG_pixel_create(ChannelCount, BitsPerChannel);
/* Pixel is created using same attributes as image */
IG_pixel_delete(hPix);
IG_image_delete(hImage);

Remarks:

The number of bits per channel is the amount to allocate, and it must be 8, 16, or 32.