Crossfire Client, Trunk  R20507
Macros | Functions | Variables
image.c File Reference

Contains highlevel image related functions and mostly deals with the image caching, processing the image commands from the server, etc. More...

#include "client.h"
#include <gtk/gtk.h>
#include "image.h"
#include "main.h"
#include "mapdata.h"
#include "gtk2proto.h"
#include "../../pixmaps/question.xpm"
Include dependency graph for image.c:

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 (guint16 face, guint16 smooth_face)
 Referenced from common/commands.c. More...
 
int associate_cache_entry (Cache_Entry *ce, int pixnum)
 This functions associates image_data in the cache entry with the specific pixmap number. More...
 
int create_and_rescale_image_from_data (Cache_Entry *ce, int pixmap_num, guint8 *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). More...
 
static void create_icon_image (guint8 *data, PixmapInfo *pi)
 Helper function to make the code more readable. More...
 
static void create_map_image (guint8 *data, PixmapInfo *pi)
 Helper function to make the code more readable. More...
 
static void free_pixmap (PixmapInfo *pi)
 Memory management. More...
 
void get_map_image_size (int face, guint8 *w, guint8 *h)
 
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. More...
 
void init_image_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. More...
 
void reset_image_data (void)
 Connecting to different servers, try to clear out any old images. More...
 

Variables

int have_new_image =0
 
static const int icon_rescale_factor [MAX_ICON_SPACES]
 
int image_size =DEFAULT_IMAGE_SIZE
 
int last_face_num =0
 
static GtkWidget * pbar
 
static GtkWidget * pbar_window
 
PixmapInfopixmaps [MAXPIXMAPNUM]
 
struct {
   guint32   checksum
 
   guint32   height
 
   char *   name
 
   guint8 *   png_data
 
   guint32   width
 
private_cache [MAXPIXMAPNUM]
 
GtkWidget * window_root
 In main.c. More...
 

Detailed Description

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.

Macro Definition Documentation

#define BPP   4

Definition at line 45 of file image.c.

Referenced by create_and_rescale_image_from_data().

#define MAX_ICON_SPACES   10

Definition at line 68 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;

Definition at line 92 of file image.c.

Function Documentation

void addsmooth ( guint16  face,
guint16  smooth_face 
)

Referenced from common/commands.c.

Parameters
face
smooth_face

Definition at line 403 of file image.c.

References PixmapInfo::smooth_face.

Referenced by SmoothCmd().

Here is the caller graph for this function:

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.

Returns
0 on success, -1 on failure.

Definition at line 416 of file image.c.

References Cache_Entry::image_data.

Referenced by finish_face_cmd().

Here is the caller graph for this function:

int create_and_rescale_image_from_data ( Cache_Entry ce,
int  pixmap_num,
guint8 *  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.

Parameters
cecan be NULL
pixmap_num
rgba_data
width
height
Returns
1 on failure.

Definition at line 261 of file image.c.

References BPP, CFG_DM_OPENGL, CFG_DM_PIXMAP, CFG_DM_SDL, CONFIG_CACHE, CONFIG_DISPLAYMODE, CONFIG_ICONSCALE, CONFIG_MAPSCALE, create_icon_image(), create_map_image(), DEFAULT_IMAGE_SIZE, free_pixmap(), have_new_image, 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.

Referenced by display_newpng(), and finish_face_cmd().

Here is the call graph for this function:

Here is the caller graph for this function:

static void create_icon_image ( guint8 *  data,
PixmapInfo pi 
)
static

Helper function to make the code more readable.

Definition at line 99 of file image.c.

References PixmapInfo::icon_height, PixmapInfo::icon_image, PixmapInfo::icon_mask, PixmapInfo::icon_width, and rgba_to_gdkpixbuf().

Referenced by create_and_rescale_image_from_data().

Here is the call graph for this function:

Here is the caller graph for this function:

static void create_map_image ( guint8 *  data,
PixmapInfo pi 
)
static

Helper function to make the code more readable.

Parameters
data
pi

Definition at line 110 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_cairo_surface(), and use_config.

Referenced by create_and_rescale_image_from_data().

Here is the call graph for this function:

Here is the caller graph for this function:

static void free_pixmap ( PixmapInfo pi)
static

Memory management.

Parameters
pi

Definition at line 206 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void get_map_image_size ( int  face,
guint8 *  w,
guint8 *  h 
)
Parameters
face
w
h

Definition at line 493 of file image.c.

References PixmapInfo::map_height, map_image_size, PixmapInfo::map_width, and MAXPIXMAPNUM.

Referenced by mapdata_get_image_size().

Here is the caller graph for this function:

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.

Parameters
startThe start value just sent to the server.
end
totalThe total number of images.

Definition at line 461 of file image.c.

References get_window_coord(), pbar, pbar_window, and window_root.

Referenced by client_negotiate().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 526 of file image.c.

References CFG_DM_OPENGL, CFG_DM_PIXMAP, CFG_DM_SDL, CONFIG_DISPLAYMODE, create_opengl_question_mark(), PixmapInfo::fog_image, PixmapInfo::icon_height, PixmapInfo::icon_image, PixmapInfo::icon_mask, PixmapInfo::icon_width, init_common_cache_data(), LOG(), LOG_DEBUG, PixmapInfo::map_height, PixmapInfo::map_image, map_image_size, PixmapInfo::map_mask, PixmapInfo::map_width, MAXPIXMAPNUM, PixmapInfo::smooth_face, use_config, and window_root.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

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 428 of file image.c.

References CONFIG_CACHE, free_pixmap(), MAXPIXMAPNUM, reset_image_cache_data(), and want_config.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

guint32 checksum

Definition at line 40 of file image.c.

Referenced by Face2Cmd(), get_image_sums(), image_add_hash(), and image_process_line().

int have_new_image =0

Definition at line 52 of file image.c.

Referenced by create_and_rescale_image_from_data(), and redraw().

guint32 height
const int icon_rescale_factor[MAX_ICON_SPACES]
static
Initial value:
= {
100, 100, 80 , 60 ,
50 , 45 , 40 ,
35 , 35 , 33
}

Definition at line 69 of file image.c.

Referenced by create_and_rescale_image_from_data().

int image_size =DEFAULT_IMAGE_SIZE

Definition at line 36 of file image.c.

Referenced by config_check(), draw_inv_table(), init_choose_char_window(), and setup_list_columns().

int last_face_num =0

Definition at line 49 of file image.c.

char* name
GtkWidget* pbar
static

Definition at line 448 of file image.c.

Referenced by image_update_download_status().

GtkWidget * pbar_window
static

Definition at line 448 of file image.c.

Referenced by image_update_download_status().

guint8* png_data

Definition at line 41 of file image.c.

struct { ... } private_cache[MAXPIXMAPNUM]
guint32 width
GtkWidget* window_root