Freeciv-3.3
Loading...
Searching...
No Matches
Functions | Variables
sprite.cpp File Reference
#include <QImageReader>
#include <QPainter>
#include "colors.h"
#include "fc_client.h"
#include "qtg_cxxside.h"
#include "sprite.h"

Go to the source code of this file.

Functions

const char ** gfx_fileextensions (void)
 
struct spriteqtg_load_gfxfile (const char *filename, bool svgflag)
 
struct spriteqtg_crop_sprite (struct sprite *source, int x, int y, int width, int height, struct sprite *mask, int mask_offset_x, int mask_offset_y, float scale, bool smooth)
 
void qtg_get_sprite_dimensions (struct sprite *sprite, int *width, int *height)
 
void qtg_free_sprite (struct sprite *s)
 
struct spriteqtg_create_sprite (int width, int height, struct color *pcolor)
 
struct spriteqtg_load_gfxnumber (int num)
 

Variables

static const char ** gfx_array_extensions = nullptr
 

Function Documentation

◆ gfx_fileextensions()

const char ** gfx_fileextensions ( void  )

Return a nullptr-terminated, permanently allocated array of possible graphics types extensions. Extensions listed first will be checked first.

Definition at line 35 of file sprite.cpp.

◆ qtg_create_sprite()

struct sprite * qtg_create_sprite ( int  width,
int  height,
struct color pcolor 
)

Create a new sprite with the given height, width and color.

Definition at line 181 of file sprite.cpp.

Referenced by city_production_delegate::paint(), and setup_gui_funcs().

◆ qtg_crop_sprite()

struct sprite * qtg_crop_sprite ( struct sprite source,
int  x,
int  y,
int  width,
int  height,
struct sprite mask,
int  mask_offset_x,
int  mask_offset_y,
float  scale,
bool  smooth 
)

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 104 of file sprite.cpp.

Referenced by setup_gui_funcs().

◆ qtg_free_sprite()

void qtg_free_sprite ( struct sprite s)

Free a sprite and all associated image data.

Definition at line 172 of file sprite.cpp.

Referenced by city_production_delegate::paint(), and setup_gui_funcs().

◆ qtg_get_sprite_dimensions()

void qtg_get_sprite_dimensions ( struct sprite sprite,
int width,
int height 
)

Find the dimensions of the sprite.

Definition at line 163 of file sprite.cpp.

Referenced by setup_gui_funcs().

◆ qtg_load_gfxfile()

struct sprite * qtg_load_gfxfile ( const char filename,
bool  svgflag 
)

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 67 of file sprite.cpp.

Referenced by setup_gui_funcs().

◆ qtg_load_gfxnumber()

struct sprite * qtg_load_gfxnumber ( int  num)

Creates a sprite with the number in it.

Definition at line 195 of file sprite.cpp.

Referenced by setup_gui_funcs().

Variable Documentation

◆ gfx_array_extensions

const char** gfx_array_extensions = nullptr
static

Definition at line 28 of file sprite.cpp.

Referenced by gfx_fileextensions().