< index
< 5. Image toolkit

=====================================
5.5 Getting the color of a pixel
=====================================

You can read the colors from an image with :

C++ : TCODColor TCODImage::getPixel(int x, int y) const
C   : TCOD_color_t TCOD_image_get_pixel(TCOD_image_t image,int x, int y)

ParameterDescription
imageIn the C version, the image handler, obtained with the load function.
x,yThe pixel coordinates inside the image.
0 <= x < width
0 <= y < height
Example :

C++ : TCODImage *pix = new TCODImage(80,50);
      TCODColor col=pix->getPixel(40,25);
C   : TCOD_image_t pix = TCOD_image_new(80,50);
      TCOD_color_t col=TCOD_image_get_pixel(pix,40,25);