1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
25 /****************************************************************************
26 Return a NULL-terminated, permanently allocated array of possible
27 graphics types extensions. Extensions listed first will be checked
29 ****************************************************************************/
30 const char **gfx_fileextensions(void)
34 /* hack to allow stub to run */
35 static const char *ext
[] = {
36 "png", /* png should be the default. */
44 /****************************************************************************
45 Load the given graphics file into a sprite. This function loads an
46 entire image file, which may later be broken up into individual sprites
48 ****************************************************************************/
49 struct sprite
*gui_load_gfxfile(const char *filename
)
55 /****************************************************************************
56 Create a new sprite by cropping and taking only the given portion of
59 source gives the sprite that is to be cropped.
61 x,y, width, height gives the rectangle to be cropped. The pixel at
62 position of the source sprite will be at (0,0) in the new sprite, and
63 the new sprite will have dimensions (width, height).
65 mask gives an additional mask to be used for clipping the new
66 sprite. Only the transparency value of the mask is used in
67 crop_sprite. The formula is: dest_trans = src_trans *
68 mask_trans. Note that because the transparency is expressed as an
69 integer it is common to divide it by 256 afterwards.
71 mask_offset_x, mask_offset_y is the offset of the mask relative to the
72 origin of the source image. The pixel at (mask_offset_x,mask_offset_y)
73 in the mask image will be used to clip pixel (0,0) in the source image
74 which is pixel (-x,-y) in the new image.
75 ****************************************************************************/
76 struct sprite
*gui_crop_sprite(struct sprite
*source
,
77 int x
, int y
, int width
, int height
,
79 int mask_offset_x
, int mask_offset_y
,
80 float scale
, bool smooth
)
86 /****************************************************************************
87 Create a new sprite with the given height, width and color.
88 ****************************************************************************/
89 struct sprite
*gui_create_sprite(int width
, int height
, struct color
*pcolor
)
95 /****************************************************************************
96 Find the dimensions of the sprite.
97 ****************************************************************************/
98 void gui_get_sprite_dimensions(struct sprite
*sprite
, int *width
, int *height
)
102 *width
= sprite
->width
;
103 *height
= sprite
->height
;
107 /****************************************************************************
108 Free a sprite and all associated image data.
109 ****************************************************************************/
110 void gui_free_sprite(struct sprite
*s
)