![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <QImageReader>#include <QPainter>#include "log.h"#include "fc_client.h"#include "sprite.h"
Include dependency graph for sprite.cpp:Go to the source code of this file.
Functions | |
| QPixmap * | load_gfxfile (const char *filename) |
| Load the given graphics file into a sprite. More... | |
| QPixmap * | crop_sprite (const QPixmap *source, int x, int y, int width, int height, const QPixmap *mask, int mask_offset_x, int mask_offset_y) |
| Create a new sprite by cropping and taking only the given portion of the image. More... | |
| QPixmap* crop_sprite | ( | const QPixmap * | source, |
| int | x, | ||
| int | y, | ||
| int | width, | ||
| int | height, | ||
| const QPixmap * | mask, | ||
| int | mask_offset_x, | ||
| int | mask_offset_y | ||
| ) |
Create a new sprite by cropping and taking only the given portion of the image.
source gives the sprite that is to be cropped.
x,y, width, height gives the rectangle to be cropped. The pixel at position of the source sprite will be at (0,0) in the new sprite, and the new sprite will have dimensions (width, height).
mask gives an additional mask to be used for clipping the new sprite. Only the transparency value of the mask is used in crop_sprite. The formula is: dest_trans = src_trans * mask_trans. Note that because the transparency is expressed as an integer it is common to divide it by 256 afterwards.
mask_offset_x, mask_offset_y is the offset of the mask relative to the origin of the source image. The pixel at (mask_offset_x,mask_offset_y) in the mask image will be used to clip pixel (0,0) in the source image which is pixel (-x,-y) in the new image.
Definition at line 59 of file sprite.cpp.
| QPixmap* load_gfxfile | ( | const char * | filename | ) |
Load the given graphics file into a sprite.
This function loads an entire image file, which may later be broken up into individual sprites with crop_sprite.
Definition at line 25 of file sprite.cpp.
Referenced by load_gfx_file().