Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl2/sprite.c File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Functions
sprite.c File Reference
`#include <SDL2/SDL.h>`
`#include <SDL2/SDL_image.h>`
`#include "fcintl.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "colors.h"`
`#include "graphics.h"`
`#include "sprite.h"`

Go to the source code of this file.

## Functions

static struct sprite * | ctor_sprite (SDL_Surface *surf)
const char ** | gfx_fileextensions (void)
struct sprite * | load_gfxfile (const char *filename, bool svgflag)
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)
void | free_sprite (struct sprite *s)
struct sprite * | load_gfxnumber (int num)

## Function Documentation

## ◆ create_sprite()

struct sprite * create_sprite | ( | int | width,
|  | int | height,
|  | struct color * | pcolor
| ) |  |

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

Definition at line 127 of file sprite.c.

## ◆ crop_sprite()

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. 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.

scale gives scale of new tileset smooth means if scaling might be bilinear, if set to false use nearest neighbor

Definition at line 105 of file sprite.c.

## ◆ ctor_sprite()

static struct sprite * ctor_sprite | ( | SDL_Surface * | surf | ) |

static

Create a sprite struct and fill it with SDL_Surface pointer

Definition at line 177 of file sprite.c.

Referenced by create_sprite(), crop_sprite(), and load_gfxfile().

## ◆ free_sprite()

void free_sprite | ( | struct sprite * | s | ) |

Free a sprite and all associated image data.

Definition at line 167 of file sprite.c.

## ◆ get_sprite_dimensions()

void get_sprite_dimensions | ( | struct sprite * | sprite,
|  | int * | width,
|  | int * | height
| ) |  |

Find the dimensions of the sprite.

Definition at line 158 of file sprite.c.

## ◆ gfx_fileextensions()

const char ** gfx_fileextensions | ( | void |  | ) |

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

Definition at line 45 of file sprite.c.

## ◆ load_gfxfile()

struct sprite * 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 61 of file sprite.c.

## ◆ load_gfxnumber()

struct sprite * load_gfxnumber | ( | int | num | ) |

Return a sprite image of a number.

Definition at line 189 of file sprite.c.