Freeciv-3.1
|
#include "log.h"
#include "mem.h"
#include "shared.h"
#include "colors.h"
#include "mapview.h"
#include "sprite.h"
Go to the source code of this file.
Macros | |
#define | MAX_FILE_EXTENSIONS 50 |
#define | MULTI_UNc(a, b) ((a * b - (b / 2)) / 0xFF) |
#define | DIV_UNc(a, b) (((guint16) (a) * 0xFF + ((b) / 2)) / (b)) |
Functions | |
struct sprite * | 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) |
struct sprite * | create_sprite (int width, int height, struct color *pcolor) |
void | get_sprite_dimensions (struct sprite *sprite, int *width, int *height) |
const char ** | gfx_fileextensions (void) |
static void | surf_destroy_callback (void *data) |
struct sprite * | load_gfxfile (const char *filename) |
void | free_sprite (struct sprite *s) |
struct sprite * | sprite_scale (struct sprite *src, int new_w, int new_h) |
void | sprite_get_bounding_box (struct sprite *sprite, int *start_x, int *start_y, int *end_x, int *end_y) |
struct sprite * | crop_blankspace (struct sprite *s) |
GdkPixbuf * | sprite_get_pixbuf (struct sprite *sprite) |
GdkPixbuf * | surface_get_pixbuf (cairo_surface_t *surf, int width, int height) |
GdkPixbuf * | create_extra_pixbuf (const struct extra_type *pextra) |
struct sprite * | load_gfxnumber (int num) |
#define DIV_UNc | ( | a, | |
b | |||
) | (((guint16) (a) * 0xFF + ((b) / 2)) / (b)) |
#define MULTI_UNc | ( | a, | |
b | |||
) | ((a * b - (b / 2)) / 0xFF) |
GdkPixbuf * create_extra_pixbuf | ( | const struct extra_type * | pextra | ) |
Create a pixbuf containing a representative image for the given extra type, to be used as an icon in the GUI.
May return NULL on error.
NB: You must call g_object_unref on the non-NULL return value when you no longer need it.
Definition at line 494 of file sprite.c.
Referenced by editbar_reload_tileset(), get_tool_value_pixbuf(), and select_tgt_extra().
Crops all blankspace from a sprite (insofar as is possible as a rectangle)
Definition at line 386 of file sprite.c.
Referenced by create_races_dialog().
struct sprite * 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.
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.
scale gives scale of new tileset smooth means if scaling might be bilinear, if set to false use nearest neighbor
Definition at line 52 of file sprite.c.
Referenced by crop_blankspace(), load_sprite(), theme_load_sprite(), tileset_background_init(), tileset_lookup_sprite_tags(), tileset_player_init(), and tileset_setup_tile_type().
void free_sprite | ( | struct sprite * | s | ) |
Free a sprite and all associated image data.
Definition at line 278 of file sprite.c.
Referenced by cell_render_func(), create_frame(), create_line(), create_main_page(), create_races_dialog(), drawing_data_destroy(), finish_loading_sprites(), intro_free(), load_gfxfile(), load_sprite(), city_production_delegate::paint(), pixmap_put_overlay_tile_draw(), theme_finish_loading_sprites(), theme_free_sprites(), theme_unload_sprite(), tileset_background_free(), tileset_free_tiles(), tileset_lookup_sprite_tags(), tileset_player_free(), and unload_sprite().
void get_sprite_dimensions | ( | struct sprite * | sprite, |
int * | width, | ||
int * | height | ||
) |
Find the dimensions of the sprite.
Definition at line 107 of file sprite.c.
Referenced by calculate_max_upkeep_height(), canvas_fill_sprite_area(), canvas_put_sprite(), canvas_put_sprite_full(), create_main_page(), research_diagram::create_tooltip_help(), decrease_unit_hp_smooth(), draw_reqtree(), explosion_animation(), get_spaceship_dimensions(), load_sprite(), node_rectangle_minimum_size(), nuke_animation(), pixmap_put_overlay_tile_draw(), put_nuke_mushroom_pixmaps(), put_spaceship(), qtg_canvas_fill_sprite_area(), qtg_canvas_put_sprite_full(), show_full_citybar(), sprite_get_pixbuf(), sprite_scale(), and theme_load_sprite().
const char ** gfx_fileextensions | ( | void | ) |
Returns the filename extensions the client supports Order is important.
Definition at line 117 of file sprite.c.
Referenced by load_gfx_file(), load_gfx_file(), themespec_gfx_filename(), and tilespec_gfx_filename().
struct sprite * 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 170 of file sprite.c.
Referenced by create_main_page(), load_gfx_file(), and load_gfx_file().
struct sprite * load_gfxnumber | ( | int | num | ) |
Return a sprite image of a number.
Definition at line 526 of file sprite.c.
Referenced by fill_sprite_array().
void sprite_get_bounding_box | ( | struct sprite * | sprite, |
int * | start_x, | ||
int * | start_y, | ||
int * | end_x, | ||
int * | end_y | ||
) |
Method returns the bounding box of a sprite. It assumes a rectangular object/mask. The bounding box contains the border (pixel which have unset pixel as neighbors) pixel.
Definition at line 321 of file sprite.c.
Referenced by crop_blankspace(), get_flag(), meswin_dialog_refresh(), and update_max_unit_size().
GdkPixbuf * sprite_get_pixbuf | ( | struct sprite * | sprite | ) |
Render a pixbuf from the sprite.
NOTE: the pixmap and mask of a sprite must not change after this function is called!
Definition at line 402 of file sprite.c.
Referenced by cell_render_func(), city_dialog_update_building(), city_dialog_update_improvement_list(), create_city_dialog(), create_races_dialog(), drag_begin(), economy_report_update(), editbar_add_mode_button(), editbar_add_tool_button(), editbar_create(), editbar_reload_tileset(), editinfobox_refresh(), extviewer_refresh_widgets(), extviewer_view_cell_toggled(), get_flag(), get_thumb_pixbuf(), get_tool_mode_pixbuf(), get_tool_value_pixbuf(), load_cursors(), meswin_dialog_refresh(), populate_unit_image_table(), populate_unit_pic_table(), property_page_set_store_value(), real_menus_init(), select_tgt_extra(), select_tgt_unit(), tileset_changed(), and ui_main().
Scales a sprite. If the sprite contains a mask, the mask is scaled as as well.
Definition at line 291 of file sprite.c.
Referenced by cell_render_func(), create_main_page(), drag_begin(), and load_sprite().
|
static |
Called when the cairo surface with freeciv allocated data is destroyed.
Definition at line 160 of file sprite.c.
Referenced by load_gfxfile().
GdkPixbuf * surface_get_pixbuf | ( | cairo_surface_t * | surf, |
int | width, | ||
int | height | ||
) |
Render a pixbuf from the cairo surface
Definition at line 418 of file sprite.c.
Referenced by create_extra_pixbuf(), create_pixbuf_from_layers(), create_player_icon(), create_terrain_pixbuf(), picture_new_from_surface(), picture_set_from_surface(), sprite_get_pixbuf(), usdlg_get_unit_image(), and usdlg_tab_append_utype().