< index
< 5. Image toolkit

=====================================
5.9 Modifying an image
=====================================

You can resize an image, scaling its content, using this function :

C++ : void TCODImage::scale(int neww, int newh)
C   : void TCOD_image_scale(TCOD_image_t image,int neww, int newh)
Py  : image_scale(image, neww,newh)

If neww < oldw or newh < oldh, supersampling is used to scale down the image. Else the image is scaled up using nearest neightbor.
ParameterDescription
imageIn the C and python version, the image handler, obtained with the load function.
neww,newhThe new size of the image.
Example :

C++ : TCODImage *pix = TCODImage("mypix.bmp");
      pix->scale(10,10);
C   : TCOD_image_t pix = TCOD_image_new(80,50);
      TCOD_image_scale(pix,10,10);
Py  : pix = libtcod.image_new(80,50)
      libtcod.image_scale(pix,10,10)


You can also flip the image, either horizontally or vertically :

C++ : void TCODImage::hflip()
      void TCODImage::vflip()
C   : void TCOD_image_hflip(TCOD_image_t image)
      void TCOD_image_vflip(TCOD_image_t image)
Py  : image_hflip(image)
      image_vflip(image)

ParameterDescription
imageIn the C and python version, the image handler, obtained with the load function.
Example :

C++ : TCODImage *pix = TCODImage("mypix.bmp");
      pix->hflip();
C   : TCOD_image_t pix = TCOD_image_new(80,50);
      TCOD_image_hflip(pix);
Py  : pix = libtcod.image_new(80,50)
      libtcod.image_hflip(pix)


You can invert the colors in an image using this function :

C++ : void TCODImage::invert()
C   : void TCOD_image_invert(TCOD_image_t image)
Py  : image_invert(image)

ParameterDescription
imageIn the C and python version, the image handler, obtained with the load function.
Example :

C++ : TCODImage *pix = TCODImage("mypix.bmp");
      pix->invert();
C   : TCOD_image_t pix = TCOD_image_new(80,50);
      TCOD_image_invert(pix);
Py  : pix = libtcod.image_new(80,50)
      libtcod.image_invert(pix)

insert a comment