Exemple #1
0
/*
   Set display settings to startup values
   which are used whenever a new image is loaded.
 */
void reset_display_settings(gint * win_x, gint * win_y, gint * w, gint * h)
{
	if (rotate_press && return_press) {
		gdk_imlib_destroy_image(im);
		im = gdk_imlib_load_image(image_names[image_idx]);
		*w = org_w = im->rgb_width;
		*h = org_h = im->rgb_height;
		*win_x = (screen_x - *w) / 2;
		*win_y = (screen_y - *h) / 2;
		rotate_press = return_press = 0;
	}
	*w = org_w;
	*h = org_h;
	*win_x = (screen_x - *w) / 2;
	*win_y = (screen_y - *h) / 2;
}
Exemple #2
0
static void
load_scenario (char *fname)
{
	char *tmp, *fn;
        GdkColor bgcolor;
        GdkImage *tmpimage;
    
	tmp = g_strconcat ( "same-gnome/", fname, NULL);

	fn = gnome_unconditional_pixmap_file ( tmp );
	g_free( tmp );

	if (!g_file_exists (fn)) {
		printf (_("Could not find the \'%s\' theme for SameGnome\n"), fn);
		exit (1);
	}

	if (scenario)
		g_free (scenario);

	scenario = g_strdup(fname);

	configure_sync (fname);

	if (image)
		gdk_imlib_destroy_image (image);

	image = gdk_imlib_load_image (fn);
	gdk_imlib_render (image, image->rgb_width, image->rgb_height);

	stones = gdk_imlib_move_image (image);
	mask = gdk_imlib_move_mask (image);

        tmpimage = gdk_image_get(stones, 0, 0, 1, 1);
        bgcolor.pixel = gdk_image_get_pixel(tmpimage, 0, 0);
        gdk_window_set_background (draw_area->window, &bgcolor);
        gdk_image_destroy(tmpimage);
  
	g_free( fn );

	nstones = image->rgb_width / STONE_SIZE;
/*	ncolors = image->rgb_height / STONE_SIZE; */
	ncolors = 3;


	gtk_widget_draw (draw_area, NULL);
}
static void
destroy_image_callback (gpointer key, gpointer data, gpointer user_data)
{
	gdk_imlib_destroy_image (data);
	g_free (key);
}
Exemple #4
0
/* load a map file or get it from the cache */
static struct pixmap_info *load_image_mtime(char *name,time_t *mtime  /*GdkWindow *win*/)
{
  GList *cached;
  struct cache_entry ce_search;
  struct cache_entry *ce;
  struct stat st;
  char filename[512];
#ifdef USE_IMLIB
  GdkPixmap *p;
  GdkImlibImage *im;
#else
  struct pixmap_info *p;
#endif

  cache_count++;
  ce_search.name=name;
  p=NULL;
 
  cached=g_list_find_custom(cache_list,
			    &ce_search,find_cache);
  if (cached)
    {
      ce=(struct cache_entry *)cached->data;
      if (ce) {
	ce->count=cache_count;
	if (mtime)
	  *mtime=ce->mtime;
	return ce->p;
      }
    }
  if (g_list_length(cache_list)>=MAX_CACHE)
    {
      GList *rem;
      cache_list=g_list_sort(cache_list,compare_cache);
      ce=(struct cache_entry *)g_list_nth_data(cache_list,0);
      if (ce->p)
#ifdef USE_IMLIB
	gdk_imlib_free_pixmap(ce->p);
#else
      free_pinfo(ce->p);
#endif
      /* printf("entferne %s\n",ce->name); */
      g_free(ce->name);
      g_free(ce);
      rem=g_list_first(cache_list);
      cache_list=g_list_remove_link(cache_list,rem);
      g_list_free(rem);
      
    }
  
    snprintf(filename,sizeof(filename),"%s.str", name);
    read_str_file(filename,name);
    snprintf(filename,sizeof(filename),"%s.png", name);
#ifndef USE_IMLIB
    p=load_gfxfile(filename);
    if (!p) {
      if (!stat(filename,&st)) {
	if (mtime)
	  *mtime=st.st_mtime;
	return NULL;
      }
      snprintf(filename,sizeof(filename),"%s.jpg", name);
      p=load_gfxfile(filename);
    }
#endif
#ifdef USE_IMLIB
    im=gdk_imlib_load_image(filename);
    if (im)
      break;
    snprintf(filename,sizeof(filename),"%s/%s.bmp",kartenpfad[i],
	     name);
    im=gdk_imlib_load_image(filename);
    if (im)
      break;
#endif
#ifdef USE_IMLIB
  if (!im)
    return NULL;
  w=im->rgb_width; h=im->rgb_height;
  if (!gdk_imlib_render(im,w,h)) {
    gdk_imlib_destroy_image(im);
    return NULL;
  }
  p=gdk_imlib_move_image(im);
  gdk_imlib_destroy_image(im);
#endif
  if (p) {
    struct stat st;
    ce=g_malloc(sizeof(struct cache_entry));
    ce->p=p;
    ce->name=g_strdup(name);
    ce->count=cache_count;
    cache_list=g_list_append(cache_list,ce);
    stat(filename,&st);
    ce->mtime=st.st_mtime;
    if (mtime)
	*mtime=ce->mtime;
  } else {
    if (!stat(filename,&st)) {
      if (mtime)
	*mtime=st.st_mtime;
      return NULL;
    }
      
  }
  
  return p;  
}