2 "$Id: image.c 11043 2008-12-21 04:44:14Z kbulgrien $";
42 #include <glade/glade.h>
46 #include <gdk/gdkwin32.h>
48 #include <gdk/gdkkeysyms.h>
52 #include <SDL_image.h>
92 #define MAX_ICON_SPACES 10
116 #define ROTATE_RIGHT(c) if ((c) & 01) (c) = ((c) >>1) + 0x80000000; else (c) >>= 1;
132 LOG (
LOG_ERROR,
"gtk::create_icon_image",
"Unable to create scaled image, dest num = %d\n", pixmap_num);
147 #if defined(HAVE_SDL)
153 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
156 0xff00, 0xff0000, 0xff000000);
158 fog = SDL_CreateRGBSurface(SDL_SRCALPHA | SDL_HWSURFACE,
160 0xff00, 0xff0000, 0xff000000);
161 SDL_LockSurface(fog);
164 l = (
uint8 *) (data + i*4);
169 g = ( *l + *(l+1) + *(l+2)) / 3;
171 p = (
uint32*) fog->pixels + i;
172 *p = g | (g << 8) | (g << 16) | (*(l + 3) << 24);
175 SDL_UnlockSurface(fog);
181 0xff0000, 0xff00, 0xff);
183 fog = SDL_CreateRGBSurface(SDL_SRCALPHA | SDL_HWSURFACE,
185 0xff0000, 0xff00, 0xff);
186 SDL_LockSurface(fog);
194 l = (
uint8 *) (data + i*4);
199 g = ( *l + *(l+1) + *(l+2)) / 3;
201 p = (
uint32*) fog->pixels + i;
202 *p = (g << 8) | (g << 16) | (g << 24) | *(l + 3);
213 p = (
uint32*) (fog->pixels + i);
214 g = ( ((*p >> 24) & 0xff) + ((*p >> 16) & 0xff) + ((*p >> 8) & 0xff)) / 3;
215 tmp = (
uint32*) fog->pixels + i;
216 *tmp = (g << 24) | (g << 16) | (g << 8) | (*p & 0xff);
219 SDL_UnlockSurface(fog);
252 free(((SDL_Surface*)pi->
map_image)->pixels);
296 int nx, ny, iscale, factor;
303 if (pixmaps[pixmap_num] != pixmaps[0]) {
305 free(pixmaps[pixmap_num]);
306 pixmaps[pixmap_num] = pixmaps[0];
373 png_tmp = malloc(width * height *
BPP);
374 memcpy(png_tmp, rgba_data, width * height * BPP);
392 pixmaps[pixmap_num] = pi;
442 pixmaps[i] = pixmaps[0];
449 static GtkAdjustment *
padj=NULL;
464 int x, y, wx, wy, w, h;
467 padj = (GtkAdjustment*) gtk_adjustment_new (0, 1, total, 0, 0, 0);
469 pbar = gtk_progress_bar_new_with_adjustment(
padj);
470 gtk_progress_set_format_string(GTK_PROGRESS(
pbar),
"Downloading image %v of %u (%p%% complete)");
471 gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(
pbar), GTK_PROGRESS_CONTINUOUS);
472 gtk_progress_set_show_text(GTK_PROGRESS(
pbar),
TRUE);
483 gtk_widget_set_uposition(
pbar_window, (wx + w)/2, (wy + h) / 2);
486 gtk_widget_show(
pbar);
489 if (start == total) {
497 gtk_progress_set_value(GTK_PROGRESS(
pbar), start);
498 while ( gtk_events_pending() ) {
499 gtk_main_iteration();
546 #include "../../pixmaps/question.xpm"
555 &style->bg[GTK_STATE_NORMAL],
556 (gchar **)question_xpm);
563 #include "../../pixmaps/question.sdl"
564 pixmaps[0]->
map_image = SDL_CreateRGBSurfaceFrom(question_sdl,
565 32, 32, 1, 4, 1, 1, 1, 1);
566 SDL_SetAlpha(pixmaps[0]->map_image, SDL_SRCALPHA, 70);
567 pixmaps[0]->
fog_image = SDL_CreateRGBSurfaceFrom(question_sdl,
568 32, 32, 1, 4, 1, 1, 1, 1);
569 SDL_SetAlpha(pixmaps[0]->fog_image, SDL_SRCALPHA, 70);
594 pixmaps[i] = pixmaps[0];
#define DEFAULT_IMAGE_SIZE
static const int icon_rescale_factor[MAX_ICON_SPACES]
void opengl_free_pixmap(PixmapInfo *pi)
void image_update_download_status(int start, int end, int total)
struct @2 private_cache[MAXPIXMAPNUM]
void get_window_coord(GtkWidget *win, int *x, int *y, int *wx, int *wy, int *w, int *h)
sint16 want_config[CONFIG_NUMS]
void create_opengl_map_image(uint8 *data, PixmapInfo *pi)
static GtkWidget * pbar_window
int create_and_rescale_image_from_data(Cache_Entry *ce, int pixmap_num, uint8 *rgba_data, int width, int height)
void LOG(LogLevel level, const char *origin, const char *format,...)
void addsmooth(uint16 face, uint16 smooth_face)
void init_cache_data(void)
void create_opengl_question_mark(void)
sint16 use_config[CONFIG_NUMS]
static void create_map_image(uint8 *data, PixmapInfo *pi)
static void create_icon_image(uint8 *data, PixmapInfo *pi, int pixmap_num)
void reset_image_cache_data(void)
uint8 * rescale_rgba_data(uint8 *data, int *width, int *height, int scale)
void reset_image_data(void)
int rgba_to_gdkpixmap(GdkWindow *window, uint8 *data, int width, int height, GdkPixmap **pix, GdkBitmap **mask, GdkColormap *colormap)
int rgba_to_gdkpixbuf(uint8 *data, int width, int height, GdkPixbuf **pix)
static GtkAdjustment * padj
static void free_pixmap(PixmapInfo *pi)
PixmapInfo * pixmaps[MAXPIXMAPNUM]
void get_map_image_size(int face, uint8 *w, uint8 *h)
void init_common_cache_data(void)
#define CONFIG_DISPLAYMODE
int associate_cache_entry(Cache_Entry *ce, int pixnum)
const char *const rcsid_gtk2_image_c