|
| | TCODImage () noexcept=default |
| | Default constructs an image. This will be in a partially invalid state until assigned a real image.
|
| | TCODImage (int width, int height) |
| | You can create an image of any size, filled with black with this function.
|
| | TCODImage (const char *filename) |
| | You can read data from a .bmp or .png file (for example to draw an image using the background color of the console cells).
|
| | TCODImage (const TCODConsole *console) |
| | You can create an image from any console (either the root console or an offscreen console).
|
| | TCODImage (tcod::ImagePtr image) noexcept |
| | Take ownership of an image pointer.
|
|
| TCODImage (const TCODImage &)=delete |
|
TCODImage & | operator= (const TCODImage &)=delete |
|
| TCODImage (TCODImage &&rhs) noexcept |
|
TCODImage & | operator= (TCODImage &&rhs) noexcept |
| | TCODImage (const tcod::Matrix< TCOD_ColorRGB, 2 > &pixels) |
| | Construct a new TCODImage object from a Matrix of pixels.
|
| void | refreshConsole (const TCODConsole *console) |
| | If you need to refresh the image with the console's new content, you don't have to delete it and create another one.
|
| void | getSize (int *w, int *h) const |
| | You can read the size of an image in pixels with this function.
|
| auto | getSize () const noexcept -> std::array< int, 2 > |
| | Get the {width, height} of this image.
|
| TCODColor | getPixel (int x, int y) const |
| | You can read the colors from an image with this function.
|
| int | getAlpha (int x, int y) const |
| | If you have set a key color for this image with setKeyColor, or if this image was created from a 32 bits PNG file (with alpha layer), you can get the pixel transparency with this function.
|
| bool | isPixelTransparent (int x, int y) const |
| | You can use this simpler version (for images with alpha layer, returns true only if alpha == 0) :
|
| TCODColor | getMipmapPixel (float x0, float y0, float x1, float y1) |
| | This method uses mipmaps to get the average color of an arbitrary rectangular region of the image.
|
| void | clear (const TCODColor col) |
| | You can fill the whole image with a color with :
|
| void | putPixel (int x, int y, const TCODColor col) |
| void | scale (int new_w, int new_h) |
| | You can resize an image and scale its content.
|
| void | hflip () |
| void | vflip () |
| void | rotate90 (int numRotations=1) |
| | Rotate the image clockwise by increment of 90 degrees.
|
| void | invert () |
| void | save (const char *filename) const |
| void | blitRect (TCODConsole *console, int x, int y, int w=-1, int h=-1, TCOD_bkgnd_flag_t bkgnd_flag=TCOD_BKGND_SET) const |
| | This function blits a rectangular part of the image on a console without scaling it or rotating it.
|
|
void | blitRect (TCOD_Console &console, int x, int y, int w=-1, int h=-1, TCOD_bkgnd_flag_t bkgnd_flag=TCOD_BKGND_SET) const |
| void | blit (TCODConsole *console, float x, float y, TCOD_bkgnd_flag_t bkgnd_flag=TCOD_BKGND_SET, float scale_x=1.0f, float scale_y=1.0f, float angle=0.0f) const |
| | This function allows you to specify the floating point coordinates of the center of the image, its scale and its rotation angle.
|
|
void | blit (TCOD_Console &console, float x, float y, TCOD_bkgnd_flag_t bkgnd_flag=TCOD_BKGND_SET, float scale_x=1.0f, float scale_y=1.0f, float angle=0.0f) const |
| void | setKeyColor (const TCODColor keyColor) |
| | When blitting an image, you can define a key color that will be ignored by the blitting function.
|
| void | blit2x (TCODConsole *dest, int dx, int dy, int sx=0, int sy=0, int w=-1, int h=-1) const |
| | Eventually, you can use some special characters in the libtcod fonts :
|
|
void | blit2x (TCOD_Console &dest, int dx, int dy, int sx=0, int sy=0, int w=-1, int h=-1) const |
| TCOD_Image * | get_data () noexcept |
| | Return the pointer to this objects TCOD_Image data.
|
| const TCOD_Image * | get_data () const noexcept |
| | Return the const pointer to this objects TCOD_Image data.
|
|
| TCODImage (TCOD_image_t img) |
| | operator TCOD_Image & () |
| | Allow implicit conversions to TCOD_Image&.
|
| | operator const TCOD_Image & () const |
| | Allow implicit conversions to const TCOD_Image&.
|
| void TCODImage::blit |
( |
TCODConsole * | console, |
|
|
float | x, |
|
|
float | y, |
|
|
TCOD_bkgnd_flag_t | bkgnd_flag = TCOD_BKGND_SET, |
|
|
float | scale_x = 1.0f, |
|
|
float | scale_y = 1.0f, |
|
|
float | angle = 0.0f ) const |
This function allows you to specify the floating point coordinates of the center of the image, its scale and its rotation angle.
void TCODImage::blit(TCODConsole console, float x, float y) void TCODImage::blit(TCODConsole console, float x, float y, TCODBackgroundFlag bkgnd_flag) void TCODImage::blit(TCODConsole console, float x, float y, TCODBackgroundFlag bkgnd_flag, float scale_x) void TCODImage::blit(TCODConsole console, float x, float y, TCODBackgroundFlag bkgnd_flag, float scale_x, float scale_y) void TCODImage::blit(TCODConsole console, float x, float y, TCODBackgroundFlag bkgnd_flag, float scale_x, float scale_y, float angle)
- Parameters
-
| image | In the C version, the image handler, obtained with the load function. |
| console | The console on which the image will be drawn. In the C version, use NULL for the root console. |
| x,y | Coordinates in the console of the center of the image. |
| flag | This flag defines how the cell's background color is modified. See TCOD_bkgnd_flag_t. |
| scale_x,scale_y | Scale coefficient. Must be > 0.0. |
| angle | Rotation angle in radians. |
| void TCODImage::blit2x |
( |
TCODConsole * | dest, |
|
|
int | dx, |
|
|
int | dy, |
|
|
int | sx = 0, |
|
|
int | sy = 0, |
|
|
int | w = -1, |
|
|
int | h = -1 ) const |
Eventually, you can use some special characters in the libtcod fonts :
to double the console resolution using this blitting function.
Comparison before/after subcell resolution in TCOD :
 | Pyromancer ! screenshot, making full usage of subcell resolution :
 |
void TCODImage::blit2x(TCODConsole dest, int dx, int dy); void TCODImage::blit2x(TCODConsole dest, int dx, int dy, int sx); void TCODImage::blit2x(TCODConsole dest, int dx, int dy, int sx, int sy); void TCODImage::blit2x(TCODConsole dest, int dx, int dy, int sx, int sy, int w); void TCODImage::blit2x(TCODConsole dest, int dx, int dy, int sx, int sy, int w, int h);
- Parameters
-
| image | In the C and Python version, the image handler, obtained with the load function. |
| dest | The console of which the image will be blitted. Foreground, background and character data will be overwritten. |
| dx,dy | Coordinate of the console cell where the upper left corner of the blitted image will be. |
| sx,sy,w,h | Part of the image to blit. Use -1 in w and h to blit the whole image. |
| TCODColor TCODImage::getMipmapPixel |
( |
float | x0, |
|
|
float | y0, |
|
|
float | x1, |
|
|
float | y1 ) |
This method uses mipmaps to get the average color of an arbitrary rectangular region of the image.
It can be used to draw a scaled-down version of the image. It's used by libtcod's blitting functions.
- Parameters
-
| image | In the C version, the image handler, obtained with the load function. |
| x0,y0 | Coordinates in pixels of the upper-left corner of the region. 0.0 <= x0 < x1 0.0 <= y0 < y1 |
| x1,y1 | Coordinates in pixels of the lower-right corner of the region. x0 < x1 < width y0 < y1 < height |
Get the average color of a 5x5 "superpixel" in the center of the image. TCODImage *pix = new TCODImage(80,50); TCODColor col=pix->getMipMapPixel(37.5f, 22.5f, 42.5f, 28.5f);
TCOD_image_t pix = TCOD_image_new(80,50); TCOD_color_t col=TCOD_image_get_mipmap_pixel(pix,37.5f, 22.5f, 42.5f, 28.5f);
pix = libtcod.image_new(80,50) col=libtcod.image_get_mipmap_pixel(pix,37.5, 22.5, 42.5, 28.5)
| void TCODImage::setKeyColor |
( |
const TCODColor | keyColor | ) |
|
When blitting an image, you can define a key color that will be ignored by the blitting function.
This makes it possible to blit non rectangular images or images with transparent pixels.
- Parameters
-
| image | In the C and Python version, the image handler, obtained with the load function. |
| color | Pixels with this color will be skipped by blitting functions. |
TCODImage *pix = TCODImage("mypix.bmp"); pix->setKeyColor(TCODColor::red); blitting the image, omitting red pixels pix->blitRect(TCODConsole::root,40,25);
TCOD_image_t pix = TCOD_image_new(10,10); TCOD_image_set_key_color(pix,TCOD_red); TCOD_image_blit_rect(pix,NULL,40,25,5,5,TCOD_BKGND_SET);
pix = libtcod.image_new(10,10) libtcod.image_set_key_color(pix,libtcod.red) libtcod.image_blit_rect(pix,0,40,25,5,5,libtcod.BKGND_SET)