Crossfire Client, Trunk
|
Go to the source code of this file.
Macros | |
#define | BPP 4 |
#define | MAX_IMAGE_HEIGHT 1024 |
#define | MAX_IMAGE_WIDTH 1024 |
#define | PNGX_DATA 3 |
#define | PNGX_NOFILE 1 |
#define | PNGX_OUTOFMEM 2 |
#define | RATIO 100 |
Functions | |
guint8 * | png_to_data (guint8 *data, int len, guint32 *width, guint32 *height) |
guint8 * | rescale_rgba_data (guint8 *data, int *width, int *height, int scale) |
cairo_surface_t * | rgba_to_cairo_surface (guint8 *data, int width, int height) |
GdkPixbuf * | rgba_to_gdkpixbuf (guint8 *data, int width, int height) |
static void | user_read_data (png_structp png_ptr, png_bytep data, png_size_t length) |
Variables | |
static guint8 * | data_cp |
static int | data_len |
static int | data_start |
Functions for manipulating graphics in the GTK-V2 client.
Definition in file png.c.
guint8* png_to_data | ( | guint8 * | data, |
int | len, | ||
guint32 * | width, | ||
guint32 * | height | ||
) |
Definition at line 49 of file png.c.
References data_cp, data_len, data_start, height, LOG(), LOG_CRITICAL, LOG_ERROR, user_read_data(), and width.
Referenced by display_newpng(), and finish_face_cmd().
guint8* rescale_rgba_data | ( | guint8 * | data, |
int * | width, | ||
int * | height, | ||
int | scale | ||
) |
Takes png data and scales it accordingly. This function is based on pnmscale, but has been modified to support alpha channel - instead of blending the alpha channel, it takes the most opaque value - blending it is not likely to give sane results IMO - for any image that has transparent information, if we blended the alpha, the result would be the edges of that region being partially transparent. This function has also been re-written to use more static data - in the case of the client, it will be called thousands of times, so it doesn't make sense to free the data and then re-allocate it.
For pixels that are fully transparent, the end result after scaling is they will be tranparent black. This is a needed effect for blending to work properly.
This function returns a new pointer to the scaled image data. This is g_malloc'd data, so should be freed at some point to prevent leaks. This function does not modify the data passed to it - the caller is responsible for freeing it if it is no longer needed.
function arguments:
*data | PNG data - this is any 4 byte per pixel data, in RGBA format. |
*width | Source width modified to contain the new image size. |
*height | Source height modified to contain the new image size. |
scale | Percentage size that new image should be. 100 is a same size image - values larger than 100 will result in zoom, values less than 100 will result in a shrinkage. |
Definition at line 235 of file png.c.
References BPP, height, LOG(), LOG_CRITICAL, MAX_IMAGE_HEIGHT, MAX_IMAGE_WIDTH, RATIO, and width.
Referenced by create_and_rescale_image_from_data(), and map_init().
cairo_surface_t* rgba_to_cairo_surface | ( | guint8 * | data, |
int | width, | ||
int | height | ||
) |
Create a Cairo surface for the given RGBA data.
Definition at line 440 of file png.c.
Referenced by create_map_image().
GdkPixbuf* rgba_to_gdkpixbuf | ( | guint8 * | data, |
int | width, | ||
int | height | ||
) |
Create a GdkPixbuf for the given RGBA data.
Definition at line 414 of file png.c.
Referenced by create_full_icon_image(), and create_icon_image().
|
static |
png_ptr | |
data | |
length |
Definition at line 43 of file png.c.
References data_cp, and data_start.
Referenced by png_to_data().
|
static |
Definition at line 34 of file png.c.
Referenced by png_to_data(), and user_read_data().
|
static |
Definition at line 35 of file png.c.
Referenced by png_to_data(), and script_watch().
|
static |
Definition at line 35 of file png.c.
Referenced by png_to_data(), and user_read_data().