Crossfire Client, Branches
R11627
|
#include <config.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <png.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include "client-types.h"
#include "client.h"
#include "image.h"
#include "main.h"
#include "mapdata.h"
#include "gtk2proto.h"
#include "../../pixmaps/question.xpm"
Go to the source code of this file.
Macros | |
#define | BPP 4 |
#define | MAX_ICON_SPACES 10 |
#define | ROTATE_RIGHT(c) if ((c) & 01) (c) = ((c) >>1) + 0x80000000; else (c) >>= 1; |
Functions | |
void | addsmooth (uint16 face, uint16 smooth_face) |
int | associate_cache_entry (Cache_Entry *ce, int pixnum) |
int | create_and_rescale_image_from_data (Cache_Entry *ce, int pixmap_num, uint8 *rgba_data, int width, int height) |
static void | create_icon_image (uint8 *data, PixmapInfo *pi, int pixmap_num) |
static void | create_map_image (uint8 *data, PixmapInfo *pi) |
static void | free_pixmap (PixmapInfo *pi) |
void | get_map_image_size (int face, uint8 *w, uint8 *h) |
void | image_update_download_status (int start, int end, int total) |
void | init_cache_data (void) |
void | reset_image_data (void) |
Variables | |
static const int | icon_rescale_factor [MAX_ICON_SPACES] |
int | image_size =DEFAULT_IMAGE_SIZE |
int | last_face_num =0 |
static GtkAdjustment * | padj =NULL |
static GtkWidget * | pbar =NULL |
static GtkWidget * | pbar_window =NULL |
PixmapInfo * | pixmaps [MAXPIXMAPNUM] |
struct { | |
uint32 checksum | |
uint32 height | |
char * name | |
uint8 * png_data | |
uint32 width | |
} | private_cache [MAXPIXMAPNUM] |
const char *const | rcsid_gtk2_image_c |
GtkWidget * | window_root |
Contains highlevel image related functions and mostly deals with the image caching, processing the image commands from the server, etc. It is gtk-specific as it returns gtk pixmaps.
Definition in file image.c.
#define BPP 4 |
Definition at line 72 of file image.c.
Referenced by create_and_rescale_image_from_data().
#define MAX_ICON_SPACES 10 |
Definition at line 92 of file image.c.
Referenced by create_and_rescale_image_from_data().
#define ROTATE_RIGHT | ( | c | ) | if ((c) & 01) (c) = ((c) >>1) + 0x80000000; else (c) >>= 1; |
Referenced from common/commands.c
face | |
smooth_face |
Definition at line 402 of file image.c.
References PixmapInfo::smooth_face.
int associate_cache_entry | ( | Cache_Entry * | ce, |
int | pixnum | ||
) |
This functions associates image_data in the cache entry with the specific pixmap number. Currently, there is no failure condition, but there is the potential that in the future, we want to more closely look at the data and if it isn't valid, return the failure code.
Definition at line 415 of file image.c.
References Cache_Entry::image_data.
int create_and_rescale_image_from_data | ( | Cache_Entry * | ce, |
int | pixmap_num, | ||
uint8 * | rgba_data, | ||
int | width, | ||
int | height | ||
) |
Takes the pixmap to put the data into, as well as the rgba data (ie, already loaded with png_to_data). Scales and stores the relevant data into the pixmap structure.
ce | can be NULL |
pixmap_num | |
rgba_data | |
width | |
height |
Definition at line 294 of file image.c.
References BPP, CFG_DM_OPENGL, CFG_DM_PIXMAP, CFG_DM_SDL, CONFIG_DISPLAYMODE, CONFIG_ICONSCALE, CONFIG_MAPSCALE, create_icon_image(), create_map_image(), DEFAULT_IMAGE_SIZE, free_pixmap(), height, PixmapInfo::icon_height, PixmapInfo::icon_image, icon_rescale_factor, PixmapInfo::icon_width, Cache_Entry::image_data, PixmapInfo::map_height, PixmapInfo::map_image, PixmapInfo::map_width, MAX_ICON_SPACES, MAXPIXMAPNUM, rescale_rgba_data(), use_config, and width.
|
static |
Helper function to make the code more readable
data | |
pi | |
pixmap_num |
Definition at line 127 of file image.c.
References PixmapInfo::icon_height, PixmapInfo::icon_image, PixmapInfo::icon_mask, PixmapInfo::icon_width, LOG(), LOG_ERROR, and rgba_to_gdkpixbuf().
Referenced by create_and_rescale_image_from_data().
|
static |
Helper function to make the code more readable
data | |
pi |
Definition at line 141 of file image.c.
References CFG_DM_OPENGL, CFG_DM_PIXMAP, CFG_DM_SDL, CONFIG_DISPLAYMODE, create_opengl_map_image(), PixmapInfo::fog_image, PixmapInfo::map_height, PixmapInfo::map_image, PixmapInfo::map_mask, PixmapInfo::map_width, rgba_to_gdkpixmap(), use_config, and window_root.
Referenced by create_and_rescale_image_from_data().
|
static |
Memory management.
pi |
Definition at line 243 of file image.c.
References CFG_DM_OPENGL, CFG_DM_PIXMAP, CFG_DM_SDL, CONFIG_DISPLAYMODE, PixmapInfo::fog_image, PixmapInfo::icon_image, PixmapInfo::icon_mask, PixmapInfo::map_image, PixmapInfo::map_mask, opengl_free_pixmap(), and use_config.
Referenced by create_and_rescale_image_from_data(), and reset_image_data().
face | |
w | |
h |
Definition at line 509 of file image.c.
References PixmapInfo::map_height, map_image_size, PixmapInfo::map_width, and MAXPIXMAPNUM.
void image_update_download_status | ( | int | start, |
int | end, | ||
int | total | ||
) |
Draws a status bar showing where we our in terms of downloading all the image data. A few hacks: If start is 1, this is the first batch, so it means we need to create the appropriate status window. If start = end = total, it means were finished, so destroy the gui element.
start | The start value just sent to the server. |
end | |
total | The total number of images. |
Definition at line 462 of file image.c.
References FALSE, get_window_coord(), padj, pbar, pbar_window, TRUE, and window_root.
void init_cache_data | ( | void | ) |
Initializes the data for image caching Create question mark to display in each supported rendering mode when an image is not cached. When image caching is enabled, if a needed image is not yet in the cache, a question mark image is displayed instead. The image displayed is unique to the display mode. This function creates the image to use when OpenGL mode is in effect.
void reset_image_data | ( | void | ) |
Connecting to different servers, try to clear out any old images. Try to free the data to prevent memory leaks. This could be more clever, ie, if we're caching images and go to a new server and get a name, we should try to re-arrange our cache or the like.
Definition at line 427 of file image.c.
References CONFIG_CACHE, free_pixmap(), MAXPIXMAPNUM, reset_image_cache_data(), and want_config.
|
static |
Definition at line 93 of file image.c.
Referenced by create_and_rescale_image_from_data().
int image_size =DEFAULT_IMAGE_SIZE |
|
static |
Definition at line 449 of file image.c.
Referenced by image_update_download_status().
|
static |
Definition at line 447 of file image.c.
Referenced by image_update_download_status().
|
static |
Definition at line 448 of file image.c.
Referenced by image_update_download_status().
PixmapInfo* pixmaps[MAXPIXMAPNUM] |
Definition at line 74 of file image.c.
Referenced by addsmooth(), associate_cache_entry(), create_and_rescale_image_from_data(), get_map_image_size(), and reset_image_data().
struct { ... } private_cache[MAXPIXMAPNUM] |
const char* const rcsid_gtk2_image_c |
GtkWidget* window_root |
In main.c
Definition at line 56 of file main.c.
Referenced by create_map_image(), enable_menu_items(), get_metaserver(), image_update_download_status(), init_cache_data(), and save_winpos().