]>
git.saurik.com Git - wxWidgets.git/blob - src/gdk_imlib/misc.c
2 #include "../gdk_imlib/gdk_imlib.h"
3 #include "../gdk_imlib/gdk_imlib_private.h"
6 gdk_imlib_get_render_type()
9 return id
->render_type
;
15 gdk_imlib_set_render_type(gint rend_type
)
20 id
->render_type
= rend_type
;
23 if ((rend_type
== RT_PLAIN_TRUECOL
) ||
24 (rend_type
== RT_DITHER_TRUECOL
))
25 id
->render_type
= RT_DITHER_PALETTE_FAST
;
27 id
->render_type
= rend_type
;
36 gdk_imlib_set_fast_render(ImlibData
* id
, Display
* disp
)
38 /* Turn off fastrender if there is an endianess diff between */
39 /* client and Xserver */
42 byt
= ImageByteOrder(id
->x
.disp
); /* LSBFirst | MSBFirst */
43 bit
= BitmapBitOrder(id
->x
.disp
); /* LSBFirst | MSBFirst */
44 /* if little endian && server big */
45 if (htonl(1) != 1 && byt
== MSBFirst
)
47 /* if big endian && server little */
48 if (htonl(1) == 1 && byt
== LSBFirst
)
53 gdk_imlib_set_color_map(ImlibData
* id
, Display
* disp
)
55 XSetWindowAttributes at
;
60 at
.backing_store
= NotUseful
;
61 at
.background_pixel
= 0;
62 at
.save_under
= False
;
63 at
.override_redirect
= True
;
64 mask
= CWOverrideRedirect
| CWBackPixel
| CWBorderPixel
|
65 CWBackingStore
| CWSaveUnder
;
67 if (id
->x
.visual
!= DefaultVisual(disp
, id
->x
.screen
))
71 cm
= XCreateColormap(id
->x
.disp
, id
->x
.root
,
72 id
->x
.visual
, AllocNone
);
81 id
->x
.base_window
= XCreateWindow(id
->x
.disp
, id
->x
.root
,
82 -100, -100, 10, 10, 0,
83 id
->x
.depth
, InputOutput
,
84 id
->x
.visual
, mask
, &at
);
85 id
->x
.gdk_win
= gdk_window_foreign_new(id
->x
.base_window
);
87 id
->x
.gdk_cmap
= gdk_colormap_new(gdk_window_get_visual
88 (id
->x
.gdk_win
), FALSE
);
90 id
->x
.gdk_cmap
= gdk_colormap_get_system();
98 XWindowAttributes xwa
;
99 XVisualInfo xvi
, *xvir
;
111 char *palfile
= NULL
;
116 disp
= (Display
*) gdk_display
;
119 fprintf(stderr
, "gdk_imlib ERROR: gdk has not connected to the display\n");
126 id
= (ImlibData
*) malloc(sizeof(ImlibData
));
129 fprintf(stderr
, "gdk_imlib ERROR: Cannot alloc RAM for Initial data struct\n");
133 id
->palette_orig
= NULL
;
139 id
->x
.screen
= DefaultScreen(disp
); /* the screen number */
140 id
->x
.root
= DefaultRootWindow(disp
); /* the root window id */
141 id
->x
.visual
= DefaultVisual(disp
, id
->x
.screen
); /* the visual type */
142 id
->x
.depth
= DefaultDepth(disp
, id
->x
.screen
); /* the depth of the screen in bpp */
143 if (XShmQueryExtension(id
->x
.disp
))
146 id
->x
.shm_event
= XShmGetEventBase(id
->x
.disp
) + ShmCompletion
;
147 id
->x
.last_xim
= NULL
;
148 id
->x
.last_sxim
= NULL
;
149 id
->max_shm
= 0x7fffffff;
150 if (XShmPixmapFormat(id
->x
.disp
) == ZPixmap
)
158 id
->cache
.on_image
= 0;
159 id
->cache
.size_image
= 0;
160 id
->cache
.num_image
= 0;
161 id
->cache
.used_image
= 0;
162 id
->cache
.image
= NULL
;
163 id
->cache
.on_pixmap
= 0;
164 id
->cache
.size_pixmap
= 0;
165 id
->cache
.num_pixmap
= 0;
166 id
->cache
.used_pixmap
= 0;
167 id
->cache
.pixmap
= NULL
;
173 id
->mod
.brightness
= 256;
174 id
->mod
.contrast
= 256;
175 id
->rmod
.gamma
= 256;
176 id
->rmod
.brightness
= 256;
177 id
->rmod
.contrast
= 256;
178 id
->gmod
.gamma
= 256;
179 id
->gmod
.brightness
= 256;
180 id
->gmod
.contrast
= 256;
181 id
->bmod
.gamma
= 256;
182 id
->bmod
.brightness
= 256;
183 id
->bmod
.contrast
= 256;
184 id
->ordered_dither
= 1;
186 if (XGetWindowAttributes(disp
, id
->x
.root
, &xwa
))
189 id
->x
.root_cmap
= xwa
.colormap
;
197 homedir
= getenv("HOME");
198 g_snprintf(s
, sizeof(s
), "%s/.imrc", homedir
);
201 f
= fopen(SYSTEM_IMRC
, "r");
204 while (fgets(s
, 4096, f
))
209 s1
= strtok(s
, " \t\n");
216 s2
= strtok(NULL
, " \t\n");
218 s2
= ""; /* NULL argument */
220 if (!strcasecmp("PaletteFile", s1
))
222 palfile
= strdup(s2
);
224 else if (!strcasecmp("PaletteOverride", s1
))
226 if (!strcasecmp("yes", s2
))
231 else if (!strcasecmp("Dither", s1
))
233 if (!strcasecmp("yes", s2
))
238 else if (!strcasecmp("Remap", s1
))
240 if (!strcasecmp("fast", s2
))
245 else if (!strcasecmp("Mit-Shm", s1
))
247 if (!strcasecmp("off", s2
))
253 else if (!strcasecmp("SharedPixmaps", s1
))
255 if (!strcasecmp("off", s2
))
258 else if (!strcasecmp("FastRender", s1
))
260 if (!strcasecmp("on", s2
))
263 else if (!strcasecmp("HighQuality", s1
))
265 if (!strcasecmp("on", s2
))
268 else if (!strcasecmp("Shm_Max_Size", s1
))
273 else if (!strcasecmp("Image_Cache_Size", s1
))
276 id
->cache
.size_image
= num
;
278 else if (!strcasecmp("Pixmap_Cache_Size", s1
))
281 id
->cache
.size_pixmap
= num
;
283 else if (!strcasecmp("Image_Cache", s1
))
285 if (!strcasecmp("on", s2
))
286 id
->cache
.on_image
= 1;
288 else if (!strcasecmp("Pixmap_Cache", s1
))
290 if (!strcasecmp("on", s2
))
291 id
->cache
.on_pixmap
= 1;
293 else if (!strcasecmp("ForceVisualID", s1
))
295 sscanf(s
, "%1024s %x", s1
, &num
);
298 else if (!strcasecmp("Fallback", s1
))
300 if (!strcasecmp("off", s2
))
305 else if (!strcasecmp("Gamma", s1
))
307 id
->mod
.gamma
= (int)(256.0 * atof(s2
));
309 else if (!strcasecmp("Brightness", s1
))
311 id
->mod
.brightness
= (int)(256.0 * atof(s2
));
313 else if (!strcasecmp("Contrast", s1
))
315 id
->mod
.contrast
= (int)(256.0 * atof(s2
));
317 else if (!strcasecmp("Red_Gamma", s1
))
319 id
->rmod
.gamma
= (int)(256.0 * atof(s2
));
321 else if (!strcasecmp("Red_Brightness", s1
))
323 id
->rmod
.brightness
= (int)(256.0 * atof(s2
));
325 else if (!strcasecmp("Red_Contrast", s1
))
327 id
->rmod
.contrast
= (int)(256.0 * atof(s2
));
329 else if (!strcasecmp("Green_Gamma", s1
))
331 id
->gmod
.gamma
= (int)(256.0 * atof(s2
));
333 else if (!strcasecmp("Green_Brightness", s1
))
335 id
->gmod
.brightness
= (int)(256.0 * atof(s2
));
337 else if (!strcasecmp("Green_Contrast", s1
))
339 id
->gmod
.contrast
= (int)(256.0 * atof(s2
));
341 else if (!strcasecmp("Blue_Gamma", s1
))
343 id
->bmod
.gamma
= (int)(256.0 * atof(s2
));
345 else if (!strcasecmp("Blue_Brightness", s1
))
347 id
->bmod
.brightness
= (int)(256.0 * atof(s2
));
349 else if (!strcasecmp("Blue_Contrast", s1
))
351 id
->bmod
.contrast
= (int)(256.0 * atof(s2
));
353 else if (!strcasecmp("Ordered_Dither", s1
))
355 if (!strcasecmp("off", s2
))
356 id
->ordered_dither
= 0;
358 id
->ordered_dither
= 1;
363 /* list all visuals for the default screen */
364 xvi
.screen
= id
->x
.screen
;
365 xvir
= XGetVisualInfo(disp
, VisualScreenMask
, &xvi
, &num
);
368 /* use the forced visual id */
370 for (i
= 0; i
< num
; i
++)
372 if (xvir
[i
].visualid
== (VisualID
) vis
)
377 unsigned long rmsk
, gmsk
, bmsk
;
379 id
->x
.depth
= xvir
[maxn
].depth
;
380 id
->x
.visual
= xvir
[maxn
].visual
;
381 rmsk
= xvir
[maxn
].red_mask
;
382 gmsk
= xvir
[maxn
].green_mask
;
383 bmsk
= xvir
[maxn
].blue_mask
;
385 if ((rmsk
> gmsk
) && (gmsk
> bmsk
))
386 id
->byte_order
= BYTE_ORD_24_RGB
;
387 else if ((rmsk
> bmsk
) && (bmsk
> gmsk
))
388 id
->byte_order
= BYTE_ORD_24_RBG
;
389 else if ((bmsk
> rmsk
) && (rmsk
> gmsk
))
390 id
->byte_order
= BYTE_ORD_24_BRG
;
391 else if ((bmsk
> gmsk
) && (gmsk
> rmsk
))
392 id
->byte_order
= BYTE_ORD_24_BGR
;
393 else if ((gmsk
> rmsk
) && (rmsk
> bmsk
))
394 id
->byte_order
= BYTE_ORD_24_GRB
;
395 else if ((gmsk
> bmsk
) && (bmsk
> rmsk
))
396 id
->byte_order
= BYTE_ORD_24_GBR
;
401 fprintf(stderr
, "Visual Id no 0x%x specified in the imrc file is invalid on this display.\nUsing Default Visual.\n", vis
);
407 /* find the highest bit-depth supported by visuals */
409 for (i
= 0; i
< num
; i
++)
411 if (xvir
[i
].depth
> max
)
419 for (i
= 0; i
< num
; i
++)
421 if (xvir
[i
].depth
== id
->x
.depth
)
423 if ((xvir
[i
].class > clas
) && (xvir
[i
].class != DirectColor
))
426 clas
= xvir
[i
].class;
432 unsigned long rmsk
, gmsk
, bmsk
;
434 id
->x
.visual
= xvir
[maxn
].visual
;
435 rmsk
= xvir
[maxn
].red_mask
;
436 gmsk
= xvir
[maxn
].green_mask
;
437 bmsk
= xvir
[maxn
].blue_mask
;
439 if ((rmsk
> gmsk
) && (gmsk
> bmsk
))
440 id
->byte_order
= BYTE_ORD_24_RGB
;
441 else if ((rmsk
> bmsk
) && (bmsk
> gmsk
))
442 id
->byte_order
= BYTE_ORD_24_RBG
;
443 else if ((bmsk
> rmsk
) && (rmsk
> gmsk
))
444 id
->byte_order
= BYTE_ORD_24_BRG
;
445 else if ((bmsk
> gmsk
) && (gmsk
> rmsk
))
446 id
->byte_order
= BYTE_ORD_24_BGR
;
447 else if ((gmsk
> rmsk
) && (rmsk
> bmsk
))
448 id
->byte_order
= BYTE_ORD_24_GRB
;
449 else if ((gmsk
> bmsk
) && (bmsk
> rmsk
))
450 id
->byte_order
= BYTE_ORD_24_GBR
;
457 id
->x
.render_depth
= id
->x
.depth
;
460 if (id
->x
.depth
== 16)
462 xvi
.visual
= id
->x
.visual
;
463 xvi
.visualid
= XVisualIDFromVisual(id
->x
.visual
);
464 xvir
= XGetVisualInfo(disp
, VisualIDMask
, &xvi
, &num
);
467 if (xvir
->red_mask
!= 0xf800)
468 id
->x
.render_depth
= 15;
472 if (id
->x
.depth
<= 8 || override
== 1)
480 id
->render_type
= RT_DITHER_PALETTE_FAST
;
482 id
->render_type
= RT_DITHER_PALETTE
;
487 id
->render_type
= RT_PLAIN_PALETTE_FAST
;
489 id
->render_type
= RT_PLAIN_PALETTE
;
491 /* Should we error this case or default it nicely */
493 gdk_imlib_load_colors(palfile
);
494 if (id
->num_colors
== 0)
496 fprintf(stderr
, "gdk_imlib: Cannot Find Palette. A Palette is required for this mode\n");
507 id
->render_type
= RT_DITHER_TRUECOL
;
509 id
->render_type
= RT_PLAIN_TRUECOL
;
512 newcm
= gdk_imlib_set_color_map(id
, disp
);
514 gdk_imlib_set_fast_render(id
, disp
);
521 gdk_imlib_init_params(GdkImlibInitParams
* p
)
524 XWindowAttributes xwa
;
525 XVisualInfo xvi
, *xvir
;
527 /* char file[4096]; */
528 char s
[4096], *s1
, *s2
;
536 char *palfile
= NULL
;
541 disp
= (Display
*) gdk_display
;
544 fprintf(stderr
, "gdk_imlib ERROR: gdk has not connected to the display\n");
551 id
= (ImlibData
*) malloc(sizeof(ImlibData
));
554 fprintf(stderr
, "gdk_imlib ERROR: Cannot alloc RAM for Initial data struct\n");
558 id
->palette_orig
= NULL
;
564 id
->x
.screen
= DefaultScreen(disp
); /* the screen number */
565 id
->x
.root
= DefaultRootWindow(disp
); /* the root window id */
566 id
->x
.visual
= DefaultVisual(disp
, id
->x
.screen
); /* the visual type */
567 id
->x
.depth
= DefaultDepth(disp
, id
->x
.screen
); /* the depth of the screen in bpp */
568 if (XShmQueryExtension(id
->x
.disp
))
571 id
->x
.shm_event
= XShmGetEventBase(id
->x
.disp
) + ShmCompletion
;
572 id
->x
.last_xim
= NULL
;
573 id
->x
.last_sxim
= NULL
;
574 id
->max_shm
= 0x7fffffff;
575 if (XShmPixmapFormat(id
->x
.disp
) == ZPixmap
)
583 id
->cache
.on_image
= 0;
584 id
->cache
.size_image
= 0;
585 id
->cache
.num_image
= 0;
586 id
->cache
.used_image
= 0;
587 id
->cache
.image
= NULL
;
588 id
->cache
.on_pixmap
= 0;
589 id
->cache
.size_pixmap
= 0;
590 id
->cache
.num_pixmap
= 0;
591 id
->cache
.used_pixmap
= 0;
592 id
->cache
.pixmap
= NULL
;
598 id
->mod
.brightness
= 256;
599 id
->mod
.contrast
= 256;
600 id
->rmod
.gamma
= 256;
601 id
->rmod
.brightness
= 256;
602 id
->rmod
.contrast
= 256;
603 id
->gmod
.gamma
= 256;
604 id
->gmod
.brightness
= 256;
605 id
->gmod
.contrast
= 256;
606 id
->bmod
.gamma
= 256;
607 id
->bmod
.brightness
= 256;
608 id
->bmod
.contrast
= 256;
610 if (XGetWindowAttributes(disp
, id
->x
.root
, &xwa
))
613 id
->x
.root_cmap
= xwa
.colormap
;
620 homedir
= getenv("HOME");
621 g_snprintf(s
, sizeof(s
), "%s/.imrc", homedir
);
624 f
= fopen(SYSTEM_IMRC
, "r");
627 while (fgets(s
, 4096, f
))
632 s1
= strtok(s
, " \t\n");
639 s2
= strtok(NULL
, " \t\n");
641 s2
= ""; /* NULL argument */
643 if (!strcasecmp("PaletteFile", s1
))
645 palfile
= strdup(s2
);
647 else if (!strcasecmp("PaletteOverride", s1
))
649 if (!strcasecmp("yes", s2
))
654 else if (!strcasecmp("Dither", s1
))
656 if (!strcasecmp("yes", s2
))
661 else if (!strcasecmp("Remap", s1
))
663 if (!strcasecmp("fast", s2
))
668 else if (!strcasecmp("Mit-Shm", s1
))
670 if (!strcasecmp("off", s2
))
676 else if (!strcasecmp("SharedPixmaps", s1
))
678 if (!strcasecmp("off", s2
))
681 else if (!strcasecmp("FastRender", s1
))
683 if (!strcasecmp("on", s2
))
686 else if (!strcasecmp("HighQuality", s1
))
688 if (!strcasecmp("on", s2
))
691 else if (!strcasecmp("Shm_Max_Size", s1
))
696 if (!strcasecmp("Image_Cache_Size", s1
))
699 id
->cache
.size_image
= num
;
701 else if (!strcasecmp("Pixmap_Cache_Size", s1
))
704 id
->cache
.size_pixmap
= num
;
706 else if (!strcasecmp("Image_Cache", s1
))
708 if (!strcasecmp("on", s2
))
709 id
->cache
.on_image
= 1;
711 else if (!strcasecmp("Pixmap_Cache", s1
))
713 if (!strcasecmp("on", s2
))
714 id
->cache
.on_pixmap
= 1;
716 else if (!strcasecmp("ForceVisualID", s1
))
718 sscanf(s
, "%1024s %x", s1
, &num
);
721 else if (!strcasecmp("Fallback", s1
))
723 if (!strcasecmp("off", s2
))
728 else if (!strcasecmp("Gamma", s1
))
730 id
->mod
.gamma
= (int)(256.0 * atof(s2
));
732 else if (!strcasecmp("Brightness", s1
))
734 id
->mod
.brightness
= (int)(256.0 * atof(s2
));
736 else if (!strcasecmp("Contrast", s1
))
738 id
->mod
.contrast
= (int)(256.0 * atof(s2
));
740 else if (!strcasecmp("Red_Gamma", s1
))
742 id
->rmod
.gamma
= (int)(256.0 * atof(s2
));
744 else if (!strcasecmp("Red_Brightness", s1
))
746 id
->rmod
.brightness
= (int)(256.0 * atof(s2
));
748 else if (!strcasecmp("Red_Contrast", s1
))
750 id
->rmod
.contrast
= (int)(256.0 * atof(s2
));
752 else if (!strcasecmp("Green_Gamma", s1
))
754 id
->gmod
.gamma
= (int)(256.0 * atof(s2
));
756 else if (!strcasecmp("Green_Brightness", s1
))
758 id
->gmod
.brightness
= (int)(256.0 * atof(s2
));
760 else if (!strcasecmp("Green_Contrast", s1
))
762 id
->gmod
.contrast
= (int)(256.0 * atof(s2
));
764 else if (!strcasecmp("Blue_Gamma", s1
))
766 id
->bmod
.gamma
= (int)(256.0 * atof(s2
));
768 else if (!strcasecmp("Blue_Brightness", s1
))
770 id
->bmod
.brightness
= (int)(256.0 * atof(s2
));
772 else if (!strcasecmp("Blue_Contrast", s1
))
774 id
->bmod
.contrast
= (int)(256.0 * atof(s2
));
776 else if (!strcasecmp("Ordered_Dither", s1
))
778 if (!strcasecmp("off", s2
))
779 id
->ordered_dither
= 0;
781 id
->ordered_dither
= 1;
788 if (p
->flags
& PARAMS_VISUALID
)
790 if (p
->flags
& PARAMS_PALETTEFILE
)
791 palfile
= strdup(p
->palettefile
);
792 if (p
->flags
& PARAMS_SHAREDMEM
)
805 if (p
->flags
& PARAMS_SHAREDPIXMAPS
)
808 id
->x
.shmp
= p
->sharedpixmaps
;
810 if (p
->flags
& PARAMS_PALETTEOVERRIDE
)
811 override
= p
->paletteoverride
;
812 if (p
->flags
& PARAMS_REMAP
)
814 if (p
->flags
& PARAMS_FASTRENDER
)
815 id
->fastrend
= p
->fastrender
;
816 if (p
->flags
& PARAMS_HIQUALITY
)
817 id
->hiq
= p
->hiquality
;
818 if (p
->flags
& PARAMS_DITHER
)
820 if (p
->flags
& PARAMS_IMAGECACHESIZE
)
821 id
->cache
.size_image
= p
->imagecachesize
;
822 if (p
->flags
& PARAMS_PIXMAPCACHESIZE
)
823 id
->cache
.size_pixmap
= p
->pixmapcachesize
;
825 /* list all visuals for the default screen */
826 xvi
.screen
= id
->x
.screen
;
827 xvir
= XGetVisualInfo(disp
, VisualScreenMask
, &xvi
, &num
);
830 /* use the forced visual id */
832 for (i
= 0; i
< num
; i
++)
834 if (xvir
[i
].visualid
== (VisualID
) vis
)
839 unsigned long rmsk
, gmsk
, bmsk
;
841 id
->x
.depth
= xvir
[maxn
].depth
;
842 id
->x
.visual
= xvir
[maxn
].visual
;
843 rmsk
= xvir
[maxn
].red_mask
;
844 gmsk
= xvir
[maxn
].green_mask
;
845 bmsk
= xvir
[maxn
].blue_mask
;
847 if ((rmsk
> gmsk
) && (gmsk
> bmsk
))
848 id
->byte_order
= BYTE_ORD_24_RGB
;
849 else if ((rmsk
> bmsk
) && (bmsk
> gmsk
))
850 id
->byte_order
= BYTE_ORD_24_RBG
;
851 else if ((bmsk
> rmsk
) && (rmsk
> gmsk
))
852 id
->byte_order
= BYTE_ORD_24_BRG
;
853 else if ((bmsk
> gmsk
) && (gmsk
> rmsk
))
854 id
->byte_order
= BYTE_ORD_24_BGR
;
855 else if ((gmsk
> rmsk
) && (rmsk
> bmsk
))
856 id
->byte_order
= BYTE_ORD_24_GRB
;
857 else if ((gmsk
> bmsk
) && (bmsk
> rmsk
))
858 id
->byte_order
= BYTE_ORD_24_GBR
;
863 fprintf(stderr
, "Visual Id no 0x%x specified in the imrc file is invalid on this display.\nUsing Default Visual.\n", vis
);
869 /* find the highest bit-depth supported by visuals */
871 for (i
= 0; i
< num
; i
++)
873 if (xvir
[i
].depth
> max
)
881 for (i
= 0; i
< num
; i
++)
883 if (xvir
[i
].depth
== id
->x
.depth
)
885 if ((xvir
[i
].class > clas
) && (xvir
[i
].class != DirectColor
))
888 clas
= xvir
[i
].class;
894 unsigned long rmsk
, gmsk
, bmsk
;
896 id
->x
.visual
= xvir
[maxn
].visual
;
897 rmsk
= xvir
[maxn
].red_mask
;
898 gmsk
= xvir
[maxn
].green_mask
;
899 bmsk
= xvir
[maxn
].blue_mask
;
901 if ((rmsk
> gmsk
) && (gmsk
> bmsk
))
902 id
->byte_order
= BYTE_ORD_24_RGB
;
903 else if ((rmsk
> bmsk
) && (bmsk
> gmsk
))
904 id
->byte_order
= BYTE_ORD_24_RBG
;
905 else if ((bmsk
> rmsk
) && (rmsk
> gmsk
))
906 id
->byte_order
= BYTE_ORD_24_BRG
;
907 else if ((bmsk
> gmsk
) && (gmsk
> rmsk
))
908 id
->byte_order
= BYTE_ORD_24_BGR
;
909 else if ((gmsk
> rmsk
) && (rmsk
> bmsk
))
910 id
->byte_order
= BYTE_ORD_24_GRB
;
911 else if ((gmsk
> bmsk
) && (bmsk
> rmsk
))
912 id
->byte_order
= BYTE_ORD_24_GBR
;
919 id
->x
.render_depth
= id
->x
.depth
;
921 if (id
->x
.depth
== 16)
923 xvi
.visual
= id
->x
.visual
;
924 xvi
.visualid
= XVisualIDFromVisual(id
->x
.visual
);
925 xvir
= XGetVisualInfo(disp
, VisualIDMask
, &xvi
, &num
);
928 if (xvir
->red_mask
!= 0xf800)
929 id
->x
.render_depth
= 15;
933 if ((id
->x
.depth
<= 8) || (override
== 1))
940 id
->render_type
= RT_DITHER_PALETTE_FAST
;
942 id
->render_type
= RT_DITHER_PALETTE
;
947 id
->render_type
= RT_PLAIN_PALETTE_FAST
;
949 id
->render_type
= RT_PLAIN_PALETTE
;
951 gdk_imlib_load_colors(palfile
);
952 if (id
->num_colors
== 0)
954 fprintf(stderr
, "gdk_imlib: Cannot Find Palette. A Palette is required for this mode\n");
965 id
->render_type
= RT_DITHER_TRUECOL
;
967 id
->render_type
= RT_PLAIN_TRUECOL
;
970 newcm
= gdk_imlib_set_color_map(id
, disp
);
971 gdk_imlib_set_fast_render(id
, disp
);
977 gdk_imlib_copy_image(GdkImlibImage
* im
)
982 if ((!im
) || (!im
->pixmap
))
984 p
= gdk_pixmap_new(id
->x
.gdk_win
, im
->width
, im
->height
, id
->x
.depth
);
986 gdk_draw_pixmap(p
, gc
, im
->pixmap
, 0, 0, 0, 0, im
->width
, im
->height
);
992 gdk_imlib_move_image(GdkImlibImage
* im
)
1004 gdk_imlib_copy_mask(GdkImlibImage
* im
)
1009 if ((!im
) || (!im
->shape_mask
))
1011 p
= gdk_pixmap_new(id
->x
.gdk_win
, im
->width
, im
->height
, 1);
1013 gdk_draw_pixmap(p
, gc
, im
->shape_mask
, 0, 0, 0, 0, im
->width
, im
->height
);
1019 gdk_imlib_move_mask(GdkImlibImage
* im
)
1026 im
->shape_mask
= NULL
;
1031 gdk_imlib_destroy_image(GdkImlibImage
* im
)
1035 if (id
->cache
.on_image
)
1046 gdk_imlib_kill_image(GdkImlibImage
* im
)
1050 if (id
->cache
.on_image
)
1062 gdk_imlib_free_pixmap(GdkPixmap
* pmap
)
1066 gfree_pixmappmap(pmap
);
1072 gdk_imlib_free_bitmap(GdkBitmap
* pmap
)
1076 gfree_pixmappmap(pmap
);
1082 gdk_imlib_set_image_border(GdkImlibImage
* im
, GdkImlibBorder
* border
)
1084 if ((im
) && (border
))
1086 im
->border
.left
= border
->left
;
1087 im
->border
.right
= border
->right
;
1088 im
->border
.top
= border
->top
;
1089 im
->border
.bottom
= border
->bottom
;
1095 gdk_imlib_get_image_border(GdkImlibImage
* im
, GdkImlibBorder
* border
)
1097 if ((im
) && (border
))
1099 border
->left
= im
->border
.left
;
1100 border
->right
= im
->border
.right
;
1101 border
->top
= im
->border
.top
;
1102 border
->bottom
= im
->border
.bottom
;
1107 gdk_imlib_get_image_shape(GdkImlibImage
* im
, GdkImlibColor
* color
)
1109 if ((!im
) || (!color
))
1111 color
->r
= im
->shape_color
.r
;
1112 color
->g
= im
->shape_color
.g
;
1113 color
->b
= im
->shape_color
.b
;
1117 gdk_imlib_set_image_shape(GdkImlibImage
* im
, GdkImlibColor
* color
)
1119 if ((!im
) || (!color
))
1121 im
->shape_color
.r
= color
->r
;
1122 im
->shape_color
.g
= color
->g
;
1123 im
->shape_color
.b
= color
->b
;
1128 gdk_imlib_get_fallback()
1132 return id
->fallback
;
1136 gdk_imlib_set_fallback(gint fallback
)
1140 id
->fallback
= fallback
;
1144 gdk_imlib_get_visual()
1148 return gdk_window_get_visual(id
->x
.gdk_win
);
1152 gdk_imlib_get_colormap()
1156 return (id
->x
.gdk_cmap
);
1160 gdk_imlib_get_sysconfig()
1164 return strdup(SYSTEM_IMRC
);