Crossfire Client, Branches
R11627
|
#include <config.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <png.h>
#include <client-types.h>
#include <client.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
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 | |
uint8 * | png_to_data (uint8 *data, int len, uint32 *width, uint32 *height) |
int | png_to_gdkpixmap (GdkWindow *window, uint8 *data, int len, GdkPixmap **pix, GdkBitmap **mask, GdkColormap *colormap) |
uint8 * | rescale_rgba_data (uint8 *data, int *width, int *height, int scale) |
int | rgba_to_gdkpixbuf (uint8 *data, int width, int height, GdkPixbuf **pix) |
int | rgba_to_gdkpixmap (GdkWindow *window, uint8 *data, int width, int height, GdkPixmap **pix, GdkBitmap **mask, GdkColormap *colormap) |
static void | user_read_data (png_structp png_ptr, png_bytep data, png_size_t length) |
Variables | |
static uint8 * | data_cp |
static int | data_len |
static int | data_start |
const char *const | rcsid_gtk2_png_c |
guchar | rgb [512 *512 *3] |
Functions for manipulating graphics in the GTK-V2 client.
Definition in file png.c.
#define BPP 4 |
Definition at line 237 of file png.c.
Referenced by rescale_rgba_data().
#define MAX_IMAGE_HEIGHT 1024 |
Definition at line 236 of file png.c.
Referenced by rescale_rgba_data().
#define MAX_IMAGE_WIDTH 1024 |
Definition at line 235 of file png.c.
Referenced by rescale_rgba_data().
#define PNGX_DATA 3 |
Definition at line 57 of file png.c.
Referenced by png_to_gdkpixmap().
#define PNGX_OUTOFMEM 2 |
Definition at line 56 of file png.c.
Referenced by png_to_gdkpixmap().
#define RATIO 100 |
Definition at line 233 of file png.c.
Referenced by rescale_rgba_data().
*data | |
len | |
*width | |
*height |
Definition at line 80 of file png.c.
References data_cp, data_len, data_start, height, LOG(), LOG_CRITICAL, and user_read_data().
int png_to_gdkpixmap | ( | GdkWindow * | window, |
uint8 * | data, | ||
int | len, | ||
GdkPixmap ** | pix, | ||
GdkBitmap ** | mask, | ||
GdkColormap * | colormap | ||
) |
*window | |
*data | |
len | |
**pix | |
**mask | |
*colormap |
Definition at line 544 of file png.c.
References data_cp, data_len, data_start, height, PNGX_DATA, PNGX_OUTOFMEM, rgb, user_read_data(), and width.
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 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 267 of file png.c.
References BPP, LOG(), LOG_CRITICAL, MAX_IMAGE_HEIGHT, MAX_IMAGE_WIDTH, RATIO, and width.
int rgba_to_gdkpixbuf | ( | uint8 * | data, |
int | width, | ||
int | height, | ||
GdkPixbuf ** | pix | ||
) |
Takes data that has already been converted into RGBA format (via png_to_data above perhaps) and creates a GdkPixbuf of it.
*data | |
width | |
height | |
**pix |
Definition at line 500 of file png.c.
References height, TRUE, and width.
Referenced by create_icon_image().
int rgba_to_gdkpixmap | ( | GdkWindow * | window, |
uint8 * | data, | ||
int | width, | ||
int | height, | ||
GdkPixmap ** | pix, | ||
GdkBitmap ** | mask, | ||
GdkColormap * | colormap | ||
) |
Takes data that has already been converted into RGBA format (via png_to_data above perhaps) and creates a GdkPixmap and GdkBitmap out of it.
*window | |
*data | |
width | |
height | |
**pix | |
**mask | |
*colormap |
Definition at line 441 of file png.c.
Referenced by create_icon_image(), and create_map_image().
|
static |
png_ptr | |
data | |
length |
Definition at line 68 of file png.c.
References data_cp, and data_start.
Referenced by png_to_data(), and png_to_gdkpixmap().
|
static |
Definition at line 59 of file png.c.
Referenced by png_to_data(), png_to_gdkpixmap(), and user_read_data().
|
static |
Definition at line 60 of file png.c.
Referenced by png_to_data(), and png_to_gdkpixmap().
|
static |
Definition at line 60 of file png.c.
Referenced by png_to_data(), png_to_gdkpixmap(), and user_read_data().
const char* const rcsid_gtk2_png_c |
guchar rgb[512 *512 *3] |
Make this especially big to support larger images in the future
Definition at line 425 of file png.c.
Referenced by png_to_gdkpixmap().