]>
git.saurik.com Git - wxWidgets.git/blob - src/gdk_imlib/rend.c
2 #include "../gdk_imlib/gdk_imlib.h"
3 #include "../gdk_imlib/gdk_imlib_private.h"
6 gdk_imlib_pixmap_foreign_new(gint width
, gint height
,
7 gint depth
, Pixmap pmap
)
10 GdkWindowPrivate
*private;
11 GdkWindowPrivate
*window_private
;
13 private = g_new(GdkWindowPrivate
, 1);
14 pixmap
= (GdkPixmap
*) private;
16 window_private
= (GdkWindowPrivate
*) id
->x
.gdk_win
;
18 private->xdisplay
= window_private
->xdisplay
;
19 private->window_type
= GDK_WINDOW_PIXMAP
;
20 private->xwindow
= pmap
;
21 private->colormap
= id
->x
.gdk_cmap
;
22 private->children
= NULL
;
23 private->parent
= NULL
;
26 private->width
= width
;
27 private->height
= height
;
28 private->resize_count
= 0;
29 private->ref_count
= 1;
30 private->destroyed
= 0;
32 gdk_xid_table_insert(&private->xwindow
, pixmap
);
38 gdk_imlib_best_color_match(gint
* r
, gint
* g
, gint
* b
)
44 int mindif
= 0x7fffffff;
50 fprintf(stderr
, "ImLib ERROR: No ImlibData initialised\n");
53 if ((id
->render_type
== RT_PLAIN_TRUECOL
) ||
54 (id
->render_type
== RT_DITHER_TRUECOL
))
56 xcl
.red
= (unsigned short)((*r
<< 8) | (*r
));
57 xcl
.green
= (unsigned short)((*g
<< 8) | (*g
));
58 xcl
.blue
= (unsigned short)((*b
<< 8) | (*b
));
59 xcl
.flags
= DoRed
| DoGreen
| DoBlue
;
60 XAllocColor(id
->x
.disp
, id
->x
.root_cmap
, &xcl
);
66 for (i
= 0; i
< id
->num_colors
; i
++)
68 dr
= *r
- id
->palette
[i
].r
;
71 dg
= *g
- id
->palette
[i
].g
;
74 db
= *b
- id
->palette
[i
].b
;
84 *r
-= id
->palette
[col
].r
;
85 *g
-= id
->palette
[col
].g
;
86 *b
-= id
->palette
[col
].b
;
87 col
= id
->palette
[col
].pixel
;
92 gindex_best_color_match(gint
* r
, gint
* g
, gint
* b
)
98 int mindif
= 0x7fffffff;
104 fprintf(stderr
, "ImLib ERROR: No ImlibData initialised\n");
107 if ((id
->render_type
== RT_PLAIN_TRUECOL
) ||
108 (id
->render_type
== RT_DITHER_TRUECOL
))
110 xcl
.red
= (unsigned short)((*r
<< 8) | (*r
));
111 xcl
.green
= (unsigned short)((*g
<< 8) | (*g
));
112 xcl
.blue
= (unsigned short)((*b
<< 8) | (*b
));
113 xcl
.flags
= DoRed
| DoGreen
| DoBlue
;
114 XAllocColor(id
->x
.disp
, id
->x
.root_cmap
, &xcl
);
120 for (i
= 0; i
< id
->num_colors
; i
++)
122 dr
= *r
- id
->palette
[i
].r
;
125 dg
= *g
- id
->palette
[i
].g
;
128 db
= *b
- id
->palette
[i
].b
;
138 *r
-= id
->palette
[col
].r
;
139 *g
-= id
->palette
[col
].g
;
140 *b
-= id
->palette
[col
].b
;
145 grender_shaped_15_fast_dither(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
146 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
147 unsigned char **yarray
)
149 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
154 jmp
= (xim
->bytes_per_line
>> 1) - w
;
155 img
= (unsigned short *)xim
->data
;
156 for (y
= 0; y
< h
; y
++)
161 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
164 for (x
= 0; x
< w
; x
++)
166 ptr2
= yarray
[y
] + xarray
[x
];
170 if ((r
== im
->shape_color
.r
) &&
171 (g
== im
->shape_color
.g
) &&
172 (b
== im
->shape_color
.b
))
174 XPutPixel(sxim
, x
, y
, 0);
180 XPutPixel(sxim
, x
, y
, 1);
190 val
= ((er
& 0xf8) << 7) | ((eg
& 0xf8) << 2) | ((eb
& 0xf8) >> 3);
194 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
203 grender_shaped_15_fast_dither_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
204 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
205 unsigned char **yarray
)
207 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
212 unsigned char dither
[4][4] =
221 jmp
= (xim
->bytes_per_line
>> 1) - w
;
222 img
= (unsigned short *)xim
->data
;
223 for (y
= 0; y
< h
; y
++)
226 for (x
= 0; x
< w
; x
++)
228 ptr2
= yarray
[y
] + xarray
[x
];
232 if ((r
== im
->shape_color
.r
) &&
233 (g
== im
->shape_color
.g
) &&
234 (b
== im
->shape_color
.b
))
236 XPutPixel(sxim
, x
, y
, 0);
241 XPutPixel(sxim
, x
, y
, 1);
246 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
248 if ((dither
[dithy
][dithx
] < eg
) && (g
< (256 - 8)))
250 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
252 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
261 grender_15_fast_dither(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
262 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
263 unsigned char **yarray
)
265 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
270 jmp
= (xim
->bytes_per_line
>> 1) - w
;
271 img
= (unsigned short *)xim
->data
;
272 for (y
= 0; y
< h
; y
++)
277 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
280 for (x
= 0; x
< w
; x
++)
282 ptr2
= yarray
[y
] + xarray
[x
];
295 val
= ((er
& 0xf8) << 7) | ((eg
& 0xf8) << 2) | ((eb
& 0xf8) >> 3);
299 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
307 grender_15_fast_dither_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
308 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
309 unsigned char **yarray
)
311 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
317 unsigned char dither
[4][4] =
326 jmp
= (xim
->bytes_per_line
>> 1) - w
;
327 img
= (unsigned short *)xim
->data
;
328 for (y
= 0; y
< h
; y
++)
331 for (x
= 0; x
< w
; x
++)
333 ptr2
= yarray
[y
] + xarray
[x
];
341 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
343 if ((dither
[dithy
][dithx
] < eg
) && (g
< (256 - 8)))
345 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
347 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
355 grender_shaped_16_fast_dither(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
356 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
357 unsigned char **yarray
)
359 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
364 jmp
= (xim
->bytes_per_line
>> 1) - w
;
365 img
= (unsigned short *)xim
->data
;
366 for (y
= 0; y
< h
; y
++)
371 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
374 for (x
= 0; x
< w
; x
++)
376 ptr2
= yarray
[y
] + xarray
[x
];
380 if ((r
== im
->shape_color
.r
) &&
381 (g
== im
->shape_color
.g
) &&
382 (b
== im
->shape_color
.b
))
384 XPutPixel(sxim
, x
, y
, 0);
390 XPutPixel(sxim
, x
, y
, 1);
400 val
= ((er
& 0xf8) << 8) | ((eg
& 0xfc) << 3) | ((eb
& 0xf8) >> 3);
404 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
413 grender_shaped_16_fast_dither_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
414 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
415 unsigned char **yarray
)
417 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
422 unsigned char dither
[4][4] =
431 jmp
= (xim
->bytes_per_line
>> 1) - w
;
432 img
= (unsigned short *)xim
->data
;
433 for (y
= 0; y
< h
; y
++)
436 for (x
= 0; x
< w
; x
++)
438 ptr2
= yarray
[y
] + xarray
[x
];
442 if ((r
== im
->shape_color
.r
) &&
443 (g
== im
->shape_color
.g
) &&
444 (b
== im
->shape_color
.b
))
446 XPutPixel(sxim
, x
, y
, 0);
451 XPutPixel(sxim
, x
, y
, 1);
456 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
458 if ((dither
[dithy
][dithx
] < (eg
<< 1)) && (g
< (256 - 4)))
460 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
462 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
471 grender_16_fast_dither(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
472 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
473 unsigned char **yarray
)
475 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
481 jmp
= (xim
->bytes_per_line
>> 1) - w
;
482 img
= (unsigned short *)xim
->data
;
483 for (y
= 0; y
< h
; y
++)
488 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
491 for (x
= 0; x
< w
; x
++)
493 ptr2
= yarray
[y
] + xarray
[x
];
506 val
= ((er
& 0xf8) << 8) | ((eg
& 0xfc) << 3) | ((eb
& 0xf8) >> 3);
510 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
518 grender_16_fast_dither_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
519 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
520 unsigned char **yarray
)
522 int x
, y
, val
, r
, g
, b
, /* *ter, ex, */ er
, eg
, eb
;
528 unsigned char dither
[4][4] =
537 jmp
= (xim
->bytes_per_line
>> 1) - w
;
538 img
= (unsigned short *)xim
->data
;
539 for (y
= 0; y
< h
; y
++)
542 for (x
= 0; x
< w
; x
++)
544 ptr2
= yarray
[y
] + xarray
[x
];
552 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
554 if ((dither
[dithy
][dithx
] < (eg
<< 1)) && (g
< (256 - 4)))
556 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
558 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
566 grender_shaped_15_dither(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
567 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
568 unsigned char **yarray
)
570 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
573 for (y
= 0; y
< h
; y
++)
578 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
581 for (x
= 0; x
< w
; x
++)
583 ptr2
= yarray
[y
] + xarray
[x
];
587 if ((r
== im
->shape_color
.r
) &&
588 (g
== im
->shape_color
.g
) &&
589 (b
== im
->shape_color
.b
))
591 XPutPixel(sxim
, x
, y
, 0);
596 XPutPixel(sxim
, x
, y
, 1);
606 val
= ((er
& 0xf8) << 7) | ((eg
& 0xf8) << 2) | ((eb
& 0xf8) >> 3);
622 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
626 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
627 XPutPixel(xim
, x
, y
, val
);
634 grender_shaped_15_dither_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
635 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
636 unsigned char **yarray
)
638 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
641 unsigned char dither
[4][4] =
650 for (y
= 0; y
< h
; y
++)
653 for (x
= 0; x
< w
; x
++)
655 ptr2
= yarray
[y
] + xarray
[x
];
659 if ((r
== im
->shape_color
.r
) &&
660 (g
== im
->shape_color
.g
) &&
661 (b
== im
->shape_color
.b
))
663 XPutPixel(sxim
, x
, y
, 0);
667 XPutPixel(sxim
, x
, y
, 1);
672 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
674 if ((dither
[dithy
][dithx
] < eg
) && (g
< (256 - 8)))
676 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
678 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
679 XPutPixel(xim
, x
, y
, val
);
686 grender_15_dither(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
687 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
688 unsigned char **yarray
)
690 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
693 for (y
= 0; y
< h
; y
++)
698 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
701 for (x
= 0; x
< w
; x
++)
703 ptr2
= yarray
[y
] + xarray
[x
];
716 val
= ((er
& 0xf8) << 7) | ((eg
& 0xf8) << 2) | ((eb
& 0xf8) >> 3);
720 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
721 XPutPixel(xim
, x
, y
, val
);
727 grender_15_dither_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
728 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
729 unsigned char **yarray
)
731 int x
, y
, val
, r
, g
, b
, /* *ter, ex, */ er
, eg
, eb
;
734 unsigned char dither
[4][4] =
743 for (y
= 0; y
< h
; y
++)
746 for (x
= 0; x
< w
; x
++)
748 ptr2
= yarray
[y
] + xarray
[x
];
756 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
758 if ((dither
[dithy
][dithx
] < eg
) && (g
< (256 - 8)))
760 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
762 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
763 XPutPixel(xim
, x
, y
, val
);
769 grender_shaped_16_dither(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
770 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
771 unsigned char **yarray
)
773 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
776 for (y
= 0; y
< h
; y
++)
781 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
784 for (x
= 0; x
< w
; x
++)
786 ptr2
= yarray
[y
] + xarray
[x
];
790 if ((r
== im
->shape_color
.r
) &&
791 (g
== im
->shape_color
.g
) &&
792 (b
== im
->shape_color
.b
))
794 XPutPixel(sxim
, x
, y
, 0);
799 XPutPixel(sxim
, x
, y
, 1);
809 val
= ((er
& 0xf8) << 8) | ((eg
& 0xfc) << 3) | ((eb
& 0xf8) >> 3);
813 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
814 XPutPixel(xim
, x
, y
, val
);
821 grender_shaped_16_dither_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
822 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
823 unsigned char **yarray
)
825 int x
, y
, val
, r
, g
, b
, /* *ter, ex, */ er
, eg
, eb
;
828 unsigned char dither
[4][4] =
837 for (y
= 0; y
< h
; y
++)
840 for (x
= 0; x
< w
; x
++)
842 ptr2
= yarray
[y
] + xarray
[x
];
846 if ((r
== im
->shape_color
.r
) &&
847 (g
== im
->shape_color
.g
) &&
848 (b
== im
->shape_color
.b
))
850 XPutPixel(sxim
, x
, y
, 0);
854 XPutPixel(sxim
, x
, y
, 1);
859 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
861 if ((dither
[dithy
][dithx
] < (eg
<< 1)) && (g
< (256 - 4)))
863 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
865 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
866 XPutPixel(xim
, x
, y
, val
);
873 grender_16_dither(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
874 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
875 unsigned char **yarray
)
877 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
880 for (y
= 0; y
< h
; y
++)
885 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
888 for (x
= 0; x
< w
; x
++)
890 ptr2
= yarray
[y
] + xarray
[x
];
903 val
= ((er
& 0xf8) << 8) | ((eg
& 0xfc) << 3) | ((eb
& 0xf8) >> 3);
907 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
908 XPutPixel(xim
, x
, y
, val
);
914 grender_16_dither_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
915 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
916 unsigned char **yarray
)
918 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
921 unsigned char dither
[4][4] =
930 for (y
= 0; y
< h
; y
++)
933 for (x
= 0; x
< w
; x
++)
935 ptr2
= yarray
[y
] + xarray
[x
];
943 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
945 if ((dither
[dithy
][dithx
] < (eg
<< 1)) && (g
< (256 - 4)))
947 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
949 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
950 XPutPixel(xim
, x
, y
, val
);
956 grender_shaped_15_fast(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
957 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
958 unsigned char **yarray
)
960 int x
, y
, val
, r
, g
, b
;
965 jmp
= (xim
->bytes_per_line
>> 1) - w
;
966 img
= (unsigned short *)xim
->data
;
967 for (y
= 0; y
< h
; y
++)
969 for (x
= 0; x
< w
; x
++)
971 ptr2
= yarray
[y
] + xarray
[x
];
975 if ((r
== im
->shape_color
.r
) &&
976 (g
== im
->shape_color
.g
) &&
977 (b
== im
->shape_color
.b
))
979 XPutPixel(sxim
, x
, y
, 0);
984 XPutPixel(sxim
, x
, y
, 1);
985 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
994 grender_15_fast(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
995 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
996 unsigned char **yarray
)
998 int x
, y
, val
, r
, g
, b
;
1000 unsigned short *img
;
1003 jmp
= (xim
->bytes_per_line
>> 1) - w
;
1004 img
= (unsigned short *)xim
->data
;
1005 for (y
= 0; y
< h
; y
++)
1007 for (x
= 0; x
< w
; x
++)
1009 ptr2
= yarray
[y
] + xarray
[x
];
1013 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
1021 grender_shaped_16_fast(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1022 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1023 unsigned char **yarray
)
1025 int x
, y
, val
, r
, g
, b
;
1026 unsigned char *ptr2
;
1027 unsigned short *img
;
1030 jmp
= (xim
->bytes_per_line
>> 1) - w
;
1031 img
= (unsigned short *)xim
->data
;
1032 for (y
= 0; y
< h
; y
++)
1034 for (x
= 0; x
< w
; x
++)
1036 ptr2
= yarray
[y
] + xarray
[x
];
1040 if ((r
== im
->shape_color
.r
) &&
1041 (g
== im
->shape_color
.g
) &&
1042 (b
== im
->shape_color
.b
))
1044 XPutPixel(sxim
, x
, y
, 0);
1049 XPutPixel(sxim
, x
, y
, 1);
1050 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
1059 grender_16_fast(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1060 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1061 unsigned char **yarray
)
1063 int x
, y
, val
, r
, g
, b
;
1064 unsigned char *ptr2
;
1066 unsigned short *img
;
1069 jmp
= (xim
->bytes_per_line
>> 1) - w
;
1070 img
= (unsigned short *)xim
->data
;
1071 for (y
= 0; y
< h
; y
++)
1073 for (x
= 0; x
< w
; x
++)
1075 ptr2
= yarray
[y
] + xarray
[x
];
1079 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
1087 grender_shaped_24_fast(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1088 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1089 unsigned char **yarray
)
1092 unsigned char *ptr2
;
1096 jmp
= (xim
->bytes_per_line
) - w
;
1097 img
= (unsigned char *)xim
->data
;
1098 if (id
->byte_order
== BYTE_ORD_24_RGB
)
1100 for (y
= 0; y
< h
; y
++)
1102 for (x
= 0; x
< w
; x
++)
1104 ptr2
= yarray
[y
] + xarray
[x
];
1108 if ((r
== im
->shape_color
.r
) &&
1109 (g
== im
->shape_color
.g
) &&
1110 (b
== im
->shape_color
.b
))
1112 XPutPixel(sxim
, x
, y
, 0);
1117 XPutPixel(sxim
, x
, y
, 1);
1126 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
1128 for (y
= 0; y
< h
; y
++)
1130 for (x
= 0; x
< w
; x
++)
1132 ptr2
= yarray
[y
] + xarray
[x
];
1136 if ((r
== im
->shape_color
.r
) &&
1137 (g
== im
->shape_color
.g
) &&
1138 (b
== im
->shape_color
.b
))
1140 XPutPixel(sxim
, x
, y
, 0);
1145 XPutPixel(sxim
, x
, y
, 1);
1154 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
1156 for (y
= 0; y
< h
; y
++)
1158 for (x
= 0; x
< w
; x
++)
1160 ptr2
= yarray
[y
] + xarray
[x
];
1164 if ((r
== im
->shape_color
.r
) &&
1165 (g
== im
->shape_color
.g
) &&
1166 (b
== im
->shape_color
.b
))
1168 XPutPixel(sxim
, x
, y
, 0);
1173 XPutPixel(sxim
, x
, y
, 1);
1182 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
1184 for (y
= 0; y
< h
; y
++)
1186 for (x
= 0; x
< w
; x
++)
1188 ptr2
= yarray
[y
] + xarray
[x
];
1192 if ((r
== im
->shape_color
.r
) &&
1193 (g
== im
->shape_color
.g
) &&
1194 (b
== im
->shape_color
.b
))
1196 XPutPixel(sxim
, x
, y
, 0);
1201 XPutPixel(sxim
, x
, y
, 1);
1210 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
1212 for (y
= 0; y
< h
; y
++)
1214 for (x
= 0; x
< w
; x
++)
1216 ptr2
= yarray
[y
] + xarray
[x
];
1220 if ((r
== im
->shape_color
.r
) &&
1221 (g
== im
->shape_color
.g
) &&
1222 (b
== im
->shape_color
.b
))
1224 XPutPixel(sxim
, x
, y
, 0);
1229 XPutPixel(sxim
, x
, y
, 1);
1238 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
1240 for (y
= 0; y
< h
; y
++)
1242 for (x
= 0; x
< w
; x
++)
1244 ptr2
= yarray
[y
] + xarray
[x
];
1248 if ((r
== im
->shape_color
.r
) &&
1249 (g
== im
->shape_color
.g
) &&
1250 (b
== im
->shape_color
.b
))
1252 XPutPixel(sxim
, x
, y
, 0);
1257 XPutPixel(sxim
, x
, y
, 1);
1269 grender_24_fast(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1270 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1271 unsigned char **yarray
)
1274 unsigned char *ptr2
;
1278 jmp
= (xim
->bytes_per_line
) - w
;
1279 img
= (unsigned char *)xim
->data
;
1280 if (id
->byte_order
== BYTE_ORD_24_RGB
)
1282 for (y
= 0; y
< h
; y
++)
1284 for (x
= 0; x
< w
; x
++)
1286 ptr2
= yarray
[y
] + xarray
[x
];
1297 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
1299 for (y
= 0; y
< h
; y
++)
1301 for (x
= 0; x
< w
; x
++)
1303 ptr2
= yarray
[y
] + xarray
[x
];
1314 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
1316 for (y
= 0; y
< h
; y
++)
1318 for (x
= 0; x
< w
; x
++)
1320 ptr2
= yarray
[y
] + xarray
[x
];
1331 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
1333 for (y
= 0; y
< h
; y
++)
1335 for (x
= 0; x
< w
; x
++)
1337 ptr2
= yarray
[y
] + xarray
[x
];
1348 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
1350 for (y
= 0; y
< h
; y
++)
1352 for (x
= 0; x
< w
; x
++)
1354 ptr2
= yarray
[y
] + xarray
[x
];
1365 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
1367 for (y
= 0; y
< h
; y
++)
1369 for (x
= 0; x
< w
; x
++)
1371 ptr2
= yarray
[y
] + xarray
[x
];
1385 grender_shaped_32_fast(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1386 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1387 unsigned char **yarray
)
1389 int x
, y
, val
, r
, g
, b
;
1390 unsigned char *ptr2
;
1394 jmp
= (xim
->bytes_per_line
>> 2) - w
;
1395 img
= (unsigned int *)xim
->data
;
1396 if (id
->byte_order
== BYTE_ORD_24_RGB
)
1398 for (y
= 0; y
< h
; y
++)
1400 for (x
= 0; x
< w
; x
++)
1402 ptr2
= yarray
[y
] + xarray
[x
];
1406 if ((r
== im
->shape_color
.r
) &&
1407 (g
== im
->shape_color
.g
) &&
1408 (b
== im
->shape_color
.b
))
1410 XPutPixel(sxim
, x
, y
, 0);
1415 XPutPixel(sxim
, x
, y
, 1);
1416 val
= (r
<< 16) | (g
<< 8) | b
;
1423 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
1425 for (y
= 0; y
< h
; y
++)
1427 for (x
= 0; x
< w
; x
++)
1429 ptr2
= yarray
[y
] + xarray
[x
];
1433 if ((r
== im
->shape_color
.r
) &&
1434 (g
== im
->shape_color
.g
) &&
1435 (b
== im
->shape_color
.b
))
1437 XPutPixel(sxim
, x
, y
, 0);
1442 XPutPixel(sxim
, x
, y
, 1);
1443 val
= (r
<< 16) | (b
<< 8) | g
;
1450 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
1452 for (y
= 0; y
< h
; y
++)
1454 for (x
= 0; x
< w
; x
++)
1456 ptr2
= yarray
[y
] + xarray
[x
];
1460 if ((r
== im
->shape_color
.r
) &&
1461 (g
== im
->shape_color
.g
) &&
1462 (b
== im
->shape_color
.b
))
1464 XPutPixel(sxim
, x
, y
, 0);
1469 XPutPixel(sxim
, x
, y
, 1);
1470 val
= (b
<< 16) | (r
<< 8) | g
;
1477 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
1479 for (y
= 0; y
< h
; y
++)
1481 for (x
= 0; x
< w
; x
++)
1483 ptr2
= yarray
[y
] + xarray
[x
];
1487 if ((r
== im
->shape_color
.r
) &&
1488 (g
== im
->shape_color
.g
) &&
1489 (b
== im
->shape_color
.b
))
1491 XPutPixel(sxim
, x
, y
, 0);
1496 XPutPixel(sxim
, x
, y
, 1);
1497 val
= (b
<< 16) | (g
<< 8) | r
;
1504 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
1506 for (y
= 0; y
< h
; y
++)
1508 for (x
= 0; x
< w
; x
++)
1510 ptr2
= yarray
[y
] + xarray
[x
];
1514 if ((r
== im
->shape_color
.r
) &&
1515 (g
== im
->shape_color
.g
) &&
1516 (b
== im
->shape_color
.b
))
1518 XPutPixel(sxim
, x
, y
, 0);
1523 XPutPixel(sxim
, x
, y
, 1);
1524 val
= (g
<< 16) | (r
<< 8) | b
;
1531 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
1533 for (y
= 0; y
< h
; y
++)
1535 for (x
= 0; x
< w
; x
++)
1537 ptr2
= yarray
[y
] + xarray
[x
];
1541 if ((r
== im
->shape_color
.r
) &&
1542 (g
== im
->shape_color
.g
) &&
1543 (b
== im
->shape_color
.b
))
1545 XPutPixel(sxim
, x
, y
, 0);
1550 XPutPixel(sxim
, x
, y
, 1);
1551 val
= (g
<< 16) | (b
<< 8) | r
;
1561 grender_32_fast(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1562 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1563 unsigned char **yarray
)
1565 int x
, y
, val
, r
, g
, b
;
1566 unsigned char *ptr2
;
1570 jmp
= (xim
->bytes_per_line
>> 2) - w
;
1571 img
= (unsigned int *)xim
->data
;
1572 if (id
->byte_order
== BYTE_ORD_24_RGB
)
1574 for (y
= 0; y
< h
; y
++)
1576 for (x
= 0; x
< w
; x
++)
1578 ptr2
= yarray
[y
] + xarray
[x
];
1582 val
= (r
<< 16) | (g
<< 8) | b
;
1588 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
1590 for (y
= 0; y
< h
; y
++)
1592 for (x
= 0; x
< w
; x
++)
1594 ptr2
= yarray
[y
] + xarray
[x
];
1598 val
= (r
<< 16) | (b
<< 8) | g
;
1604 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
1606 for (y
= 0; y
< h
; y
++)
1608 for (x
= 0; x
< w
; x
++)
1610 ptr2
= yarray
[y
] + xarray
[x
];
1614 val
= (b
<< 16) | (r
<< 8) | g
;
1620 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
1622 for (y
= 0; y
< h
; y
++)
1624 for (x
= 0; x
< w
; x
++)
1626 ptr2
= yarray
[y
] + xarray
[x
];
1630 val
= (b
<< 16) | (g
<< 8) | r
;
1636 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
1638 for (y
= 0; y
< h
; y
++)
1640 for (x
= 0; x
< w
; x
++)
1642 ptr2
= yarray
[y
] + xarray
[x
];
1646 val
= (g
<< 16) | (r
<< 8) | b
;
1652 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
1654 for (y
= 0; y
< h
; y
++)
1656 for (x
= 0; x
< w
; x
++)
1658 ptr2
= yarray
[y
] + xarray
[x
];
1662 val
= (g
<< 16) | (b
<< 8) | r
;
1671 grender_shaped_15(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1672 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1673 unsigned char **yarray
)
1675 int x
, y
, val
, r
, g
, b
;
1676 unsigned char *ptr2
;
1678 for (y
= 0; y
< h
; y
++)
1680 for (x
= 0; x
< w
; x
++)
1682 ptr2
= yarray
[y
] + xarray
[x
];
1686 if ((r
== im
->shape_color
.r
) &&
1687 (g
== im
->shape_color
.g
) &&
1688 (b
== im
->shape_color
.b
))
1689 XPutPixel(sxim
, x
, y
, 0);
1692 XPutPixel(sxim
, x
, y
, 1);
1693 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
1694 XPutPixel(xim
, x
, y
, val
);
1701 grender_15(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1702 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1703 unsigned char **yarray
)
1705 int x
, y
, val
, r
, g
, b
;
1706 unsigned char *ptr2
;
1708 for (y
= 0; y
< h
; y
++)
1710 for (x
= 0; x
< w
; x
++)
1712 ptr2
= yarray
[y
] + xarray
[x
];
1716 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
1717 XPutPixel(xim
, x
, y
, val
);
1723 grender_shaped_16(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1724 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1725 unsigned char **yarray
)
1727 int x
, y
, val
, r
, g
, b
;
1728 unsigned char *ptr2
;
1730 for (y
= 0; y
< h
; y
++)
1732 for (x
= 0; x
< w
; x
++)
1734 ptr2
= yarray
[y
] + xarray
[x
];
1738 if ((r
== im
->shape_color
.r
) &&
1739 (g
== im
->shape_color
.g
) &&
1740 (b
== im
->shape_color
.b
))
1741 XPutPixel(sxim
, x
, y
, 0);
1744 XPutPixel(sxim
, x
, y
, 1);
1745 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
1746 XPutPixel(xim
, x
, y
, val
);
1753 grender_16(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1754 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1755 unsigned char **yarray
)
1757 int x
, y
, val
, r
, g
, b
;
1758 unsigned char *ptr2
;
1760 for (y
= 0; y
< h
; y
++)
1762 for (x
= 0; x
< w
; x
++)
1764 ptr2
= yarray
[y
] + xarray
[x
];
1768 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
1769 XPutPixel(xim
, x
, y
, val
);
1775 grender_shaped_24(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1776 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1777 unsigned char **yarray
)
1779 int x
, y
, val
, r
, g
, b
;
1780 unsigned char *ptr2
;
1782 if (id
->byte_order
== BYTE_ORD_24_RGB
)
1784 for (y
= 0; y
< h
; y
++)
1786 for (x
= 0; x
< w
; x
++)
1788 ptr2
= yarray
[y
] + xarray
[x
];
1792 if ((r
== im
->shape_color
.r
) &&
1793 (g
== im
->shape_color
.g
) &&
1794 (b
== im
->shape_color
.b
))
1795 XPutPixel(sxim
, x
, y
, 0);
1798 XPutPixel(sxim
, x
, y
, 1);
1799 val
= (r
<< 16) | (g
<< 8) | b
;
1800 XPutPixel(xim
, x
, y
, val
);
1805 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
1807 for (y
= 0; y
< h
; y
++)
1809 for (x
= 0; x
< w
; x
++)
1811 ptr2
= yarray
[y
] + xarray
[x
];
1815 if ((r
== im
->shape_color
.r
) &&
1816 (g
== im
->shape_color
.g
) &&
1817 (b
== im
->shape_color
.b
))
1818 XPutPixel(sxim
, x
, y
, 0);
1821 XPutPixel(sxim
, x
, y
, 1);
1822 val
= (r
<< 16) | (b
<< 8) | g
;
1823 XPutPixel(xim
, x
, y
, val
);
1828 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
1830 for (y
= 0; y
< h
; y
++)
1832 for (x
= 0; x
< w
; x
++)
1834 ptr2
= yarray
[y
] + xarray
[x
];
1838 if ((r
== im
->shape_color
.r
) &&
1839 (g
== im
->shape_color
.g
) &&
1840 (b
== im
->shape_color
.b
))
1841 XPutPixel(sxim
, x
, y
, 0);
1844 XPutPixel(sxim
, x
, y
, 1);
1845 val
= (b
<< 16) | (r
<< 8) | g
;
1846 XPutPixel(xim
, x
, y
, val
);
1851 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
1853 for (y
= 0; y
< h
; y
++)
1855 for (x
= 0; x
< w
; x
++)
1857 ptr2
= yarray
[y
] + xarray
[x
];
1861 if ((r
== im
->shape_color
.r
) &&
1862 (g
== im
->shape_color
.g
) &&
1863 (b
== im
->shape_color
.b
))
1864 XPutPixel(sxim
, x
, y
, 0);
1867 XPutPixel(sxim
, x
, y
, 1);
1868 val
= (b
<< 16) | (g
<< 8) | r
;
1869 XPutPixel(xim
, x
, y
, val
);
1874 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
1876 for (y
= 0; y
< h
; y
++)
1878 for (x
= 0; x
< w
; x
++)
1880 ptr2
= yarray
[y
] + xarray
[x
];
1884 if ((r
== im
->shape_color
.r
) &&
1885 (g
== im
->shape_color
.g
) &&
1886 (b
== im
->shape_color
.b
))
1887 XPutPixel(sxim
, x
, y
, 0);
1890 XPutPixel(sxim
, x
, y
, 1);
1891 val
= (g
<< 16) | (r
<< 8) | b
;
1892 XPutPixel(xim
, x
, y
, val
);
1897 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
1899 for (y
= 0; y
< h
; y
++)
1901 for (x
= 0; x
< w
; x
++)
1903 ptr2
= yarray
[y
] + xarray
[x
];
1907 if ((r
== im
->shape_color
.r
) &&
1908 (g
== im
->shape_color
.g
) &&
1909 (b
== im
->shape_color
.b
))
1910 XPutPixel(sxim
, x
, y
, 0);
1913 XPutPixel(sxim
, x
, y
, 1);
1914 val
= (g
<< 16) | (b
<< 8) | r
;
1915 XPutPixel(xim
, x
, y
, val
);
1923 grender_24(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
1924 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
1925 unsigned char **yarray
)
1927 int x
, y
, val
, r
, g
, b
;
1928 unsigned char *ptr2
;
1930 if (id
->byte_order
== BYTE_ORD_24_RGB
)
1932 for (y
= 0; y
< h
; y
++)
1934 for (x
= 0; x
< w
; x
++)
1936 ptr2
= yarray
[y
] + xarray
[x
];
1940 val
= (r
<< 16) | (g
<< 8) | b
;
1941 XPutPixel(xim
, x
, y
, val
);
1945 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
1947 for (y
= 0; y
< h
; y
++)
1949 for (x
= 0; x
< w
; x
++)
1951 ptr2
= yarray
[y
] + xarray
[x
];
1955 val
= (r
<< 16) | (b
<< 8) | g
;
1956 XPutPixel(xim
, x
, y
, val
);
1960 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
1962 for (y
= 0; y
< h
; y
++)
1964 for (x
= 0; x
< w
; x
++)
1966 ptr2
= yarray
[y
] + xarray
[x
];
1970 val
= (b
<< 16) | (r
<< 8) | g
;
1971 XPutPixel(xim
, x
, y
, val
);
1975 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
1977 for (y
= 0; y
< h
; y
++)
1979 for (x
= 0; x
< w
; x
++)
1981 ptr2
= yarray
[y
] + xarray
[x
];
1985 val
= (b
<< 16) | (g
<< 8) | r
;
1986 XPutPixel(xim
, x
, y
, val
);
1990 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
1992 for (y
= 0; y
< h
; y
++)
1994 for (x
= 0; x
< w
; x
++)
1996 ptr2
= yarray
[y
] + xarray
[x
];
2000 val
= (g
<< 16) | (r
<< 8) | b
;
2001 XPutPixel(xim
, x
, y
, val
);
2005 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
2007 for (y
= 0; y
< h
; y
++)
2009 for (x
= 0; x
< w
; x
++)
2011 ptr2
= yarray
[y
] + xarray
[x
];
2015 val
= (g
<< 16) | (b
<< 8) | r
;
2016 XPutPixel(xim
, x
, y
, val
);
2023 grender_shaped(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
2024 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
2025 unsigned char **yarray
, int bpp
)
2027 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
2028 unsigned char *ptr2
;
2032 jmp
= (xim
->bytes_per_line
) - w
;
2033 img
= (unsigned char *)xim
->data
;
2034 switch (id
->render_type
)
2036 case RT_PLAIN_PALETTE
:
2037 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
2039 for (y
= 0; y
< h
; y
++)
2041 for (x
= 0; x
< w
; x
++)
2043 ptr2
= yarray
[y
] + xarray
[x
];
2047 if ((r
== im
->shape_color
.r
) &&
2048 (g
== im
->shape_color
.g
) &&
2049 (b
== im
->shape_color
.b
))
2051 XPutPixel(sxim
, x
, y
, 0);
2056 XPutPixel(sxim
, x
, y
, 1);
2057 val
= gdk_imlib_best_color_match(&r
, &g
, &b
);
2066 for (y
= 0; y
< h
; y
++)
2068 for (x
= 0; x
< w
; x
++)
2070 ptr2
= yarray
[y
] + xarray
[x
];
2074 if ((r
== im
->shape_color
.r
) &&
2075 (g
== im
->shape_color
.g
) &&
2076 (b
== im
->shape_color
.b
))
2077 XPutPixel(sxim
, x
, y
, 0);
2080 XPutPixel(sxim
, x
, y
, 1);
2081 val
= gdk_imlib_best_color_match(&r
, &g
, &b
);
2082 XPutPixel(xim
, x
, y
, val
);
2088 case RT_PLAIN_PALETTE_FAST
:
2089 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
2091 for (y
= 0; y
< h
; y
++)
2093 for (x
= 0; x
< w
; x
++)
2095 ptr2
= yarray
[y
] + xarray
[x
];
2099 if ((r
== im
->shape_color
.r
) &&
2100 (g
== im
->shape_color
.g
) &&
2101 (b
== im
->shape_color
.b
))
2103 XPutPixel(sxim
, x
, y
, 0);
2108 XPutPixel(sxim
, x
, y
, 1);
2109 val
= COLOR_RGB(r
>> 3, g
>> 3, b
>> 3);
2118 for (y
= 0; y
< h
; y
++)
2120 for (x
= 0; x
< w
; x
++)
2122 ptr2
= yarray
[y
] + xarray
[x
];
2126 if ((r
== im
->shape_color
.r
) &&
2127 (g
== im
->shape_color
.g
) &&
2128 (b
== im
->shape_color
.b
))
2129 XPutPixel(sxim
, x
, y
, 0);
2132 XPutPixel(sxim
, x
, y
, 1);
2133 val
= COLOR_RGB(r
>> 3, g
>> 3, b
>> 3);
2134 XPutPixel(xim
, x
, y
, val
);
2140 case RT_DITHER_PALETTE
:
2141 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
2143 for (y
= 0; y
< h
; y
++)
2148 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2151 for (x
= 0; x
< w
; x
++)
2153 ptr2
= yarray
[y
] + xarray
[x
];
2157 if ((r
== im
->shape_color
.r
) &&
2158 (g
== im
->shape_color
.g
) &&
2159 (b
== im
->shape_color
.b
))
2162 XPutPixel(sxim
, x
, y
, 0);
2169 XPutPixel(sxim
, x
, y
, 1);
2185 val
= gdk_imlib_best_color_match(&er
, &eg
, &eb
);
2186 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2195 for (y
= 0; y
< h
; y
++)
2200 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2203 for (x
= 0; x
< w
; x
++)
2205 ptr2
= yarray
[y
] + xarray
[x
];
2209 if ((r
== im
->shape_color
.r
) &&
2210 (g
== im
->shape_color
.g
) &&
2211 (b
== im
->shape_color
.b
))
2213 XPutPixel(sxim
, x
, y
, 0);
2218 XPutPixel(sxim
, x
, y
, 1);
2234 val
= gdk_imlib_best_color_match(&er
, &eg
, &eb
);
2235 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2236 XPutPixel(xim
, x
, y
, val
);
2242 case RT_DITHER_PALETTE_FAST
:
2243 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
2245 for (y
= 0; y
< h
; y
++)
2250 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2253 for (x
= 0; x
< w
; x
++)
2255 ptr2
= yarray
[y
] + xarray
[x
];
2259 if ((r
== im
->shape_color
.r
) &&
2260 (g
== im
->shape_color
.g
) &&
2261 (b
== im
->shape_color
.b
))
2264 XPutPixel(sxim
, x
, y
, 0);
2271 XPutPixel(sxim
, x
, y
, 1);
2287 val
= INDEX_RGB(er
>> 3, eg
>> 3, eb
>> 3);
2288 er
= ERROR_RED(er
, val
);
2289 eg
= ERROR_GRN(eg
, val
);
2290 eb
= ERROR_BLU(eb
, val
);
2291 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2292 *img
++ = COLOR_INDEX(val
);
2300 for (y
= 0; y
< h
; y
++)
2305 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2308 for (x
= 0; x
< w
; x
++)
2310 ptr2
= yarray
[y
] + xarray
[x
];
2314 if ((r
== im
->shape_color
.r
) &&
2315 (g
== im
->shape_color
.g
) &&
2316 (b
== im
->shape_color
.b
))
2318 XPutPixel(sxim
, x
, y
, 0);
2323 XPutPixel(sxim
, x
, y
, 1);
2339 val
= INDEX_RGB(er
>> 3, eg
>> 3, eb
>> 3);
2340 er
= ERROR_RED(er
, val
);
2341 eg
= ERROR_GRN(eg
, val
);
2342 eb
= ERROR_BLU(eb
, val
);
2343 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2344 XPutPixel(xim
, x
, y
, COLOR_INDEX(val
));
2358 if (id
->render_type
== RT_DITHER_TRUECOL
)
2360 if (id
->ordered_dither
)
2361 grender_shaped_15_fast_dither_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2363 grender_shaped_15_fast_dither(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2366 grender_shaped_15_fast(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2369 if (id
->render_type
== RT_DITHER_TRUECOL
)
2371 if (id
->ordered_dither
)
2372 grender_shaped_16_fast_dither_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2374 grender_shaped_16_fast_dither(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2377 grender_shaped_16_fast(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2381 if (xim
->bits_per_pixel
== 24)
2382 grender_shaped_24_fast(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2384 grender_shaped_32_fast(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2397 if (id
->render_type
== RT_DITHER_TRUECOL
)
2399 if (id
->ordered_dither
)
2400 grender_shaped_15_dither_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2402 grender_shaped_15_dither(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2405 grender_shaped_15(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2408 if (id
->render_type
== RT_DITHER_TRUECOL
)
2410 if (id
->ordered_dither
)
2411 grender_shaped_16_dither_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2413 grender_shaped_16_dither(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2416 grender_shaped_16(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2419 grender_shaped_24(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2421 grender_shaped_24(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2432 grender(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
2433 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
2434 unsigned char **yarray
, int bpp
)
2436 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
2437 unsigned char *ptr2
;
2441 jmp
= (xim
->bytes_per_line
) - w
;
2442 img
= (unsigned char *)xim
->data
;
2443 switch (id
->render_type
)
2445 case RT_PLAIN_PALETTE
:
2446 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
2448 for (y
= 0; y
< h
; y
++)
2450 for (x
= 0; x
< w
; x
++)
2452 ptr2
= yarray
[y
] + xarray
[x
];
2456 val
= gdk_imlib_best_color_match(&r
, &g
, &b
);
2464 for (y
= 0; y
< h
; y
++)
2466 for (x
= 0; x
< w
; x
++)
2468 ptr2
= yarray
[y
] + xarray
[x
];
2472 val
= gdk_imlib_best_color_match(&r
, &g
, &b
);
2473 XPutPixel(xim
, x
, y
, val
);
2478 case RT_PLAIN_PALETTE_FAST
:
2479 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
2481 for (y
= 0; y
< h
; y
++)
2483 for (x
= 0; x
< w
; x
++)
2485 ptr2
= yarray
[y
] + xarray
[x
];
2489 val
= COLOR_RGB(r
>> 3, g
>> 3, b
>> 3);
2497 for (y
= 0; y
< h
; y
++)
2499 for (x
= 0; x
< w
; x
++)
2501 ptr2
= yarray
[y
] + xarray
[x
];
2505 val
= COLOR_RGB(r
>> 3, g
>> 3, b
>> 3);
2506 XPutPixel(xim
, x
, y
, val
);
2511 case RT_DITHER_PALETTE
:
2512 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
2514 for (y
= 0; y
< h
; y
++)
2519 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2522 for (x
= 0; x
< w
; x
++)
2524 ptr2
= yarray
[y
] + xarray
[x
];
2543 val
= gdk_imlib_best_color_match(&er
, &eg
, &eb
);
2544 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2552 for (y
= 0; y
< h
; y
++)
2557 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2560 for (x
= 0; x
< w
; x
++)
2562 ptr2
= yarray
[y
] + xarray
[x
];
2581 val
= gdk_imlib_best_color_match(&er
, &eg
, &eb
);
2582 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2583 XPutPixel(xim
, x
, y
, val
);
2588 case RT_DITHER_PALETTE_FAST
:
2589 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
2591 for (y
= 0; y
< h
; y
++)
2596 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2599 for (x
= 0; x
< w
; x
++)
2601 ptr2
= yarray
[y
] + xarray
[x
];
2620 val
= INDEX_RGB(er
>> 3, eg
>> 3, eb
>> 3);
2621 er
= ERROR_RED(er
, val
);
2622 eg
= ERROR_GRN(eg
, val
);
2623 eb
= ERROR_BLU(eb
, val
);
2624 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2625 *img
++ = COLOR_INDEX(val
);
2632 for (y
= 0; y
< h
; y
++)
2637 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2640 for (x
= 0; x
< w
; x
++)
2642 ptr2
= yarray
[y
] + xarray
[x
];
2661 val
= INDEX_RGB(er
>> 3, eg
>> 3, eb
>> 3);
2662 er
= ERROR_RED(er
, val
);
2663 eg
= ERROR_GRN(eg
, val
);
2664 eb
= ERROR_BLU(eb
, val
);
2665 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2666 XPutPixel(xim
, x
, y
, COLOR_INDEX(val
));
2679 if (id
->render_type
== RT_DITHER_TRUECOL
)
2681 if (id
->ordered_dither
)
2682 grender_15_fast_dither_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2684 grender_15_fast_dither(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2687 grender_15_fast(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2690 if (id
->render_type
== RT_DITHER_TRUECOL
)
2692 if (id
->ordered_dither
)
2693 grender_16_fast_dither_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2695 grender_16_fast_dither(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2698 grender_16_fast(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2702 if (xim
->bits_per_pixel
== 24)
2703 grender_24_fast(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2705 grender_32_fast(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2718 if (id
->render_type
== RT_DITHER_TRUECOL
)
2720 if (id
->ordered_dither
)
2721 grender_15_dither_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2723 grender_15_dither(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2726 grender_15(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2729 if (id
->render_type
== RT_DITHER_TRUECOL
)
2731 if (id
->ordered_dither
)
2732 grender_16_dither_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2734 grender_16_dither(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2737 grender_16(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2740 grender_24(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2743 grender_24(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
2754 grender_shaped_15_fast_dither_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
2755 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
2756 unsigned char **yarray
)
2758 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
2759 unsigned char *ptr2
;
2760 unsigned short *img
;
2763 jmp
= (xim
->bytes_per_line
>> 1) - w
;
2764 img
= (unsigned short *)xim
->data
;
2765 for (y
= 0; y
< h
; y
++)
2770 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2773 for (x
= 0; x
< w
; x
++)
2775 ptr2
= yarray
[y
] + xarray
[x
];
2779 if ((r
== im
->shape_color
.r
) &&
2780 (g
== im
->shape_color
.g
) &&
2781 (b
== im
->shape_color
.b
))
2783 XPutPixel(sxim
, x
, y
, 0);
2792 XPutPixel(sxim
, x
, y
, 1);
2802 val
= ((er
& 0xf8) << 7) | ((eg
& 0xf8) << 2) | ((eb
& 0xf8) >> 3);
2806 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2815 grender_shaped_15_fast_dither_mod_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
2816 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
2817 unsigned char **yarray
)
2819 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
2820 unsigned char *ptr2
;
2821 unsigned short *img
;
2824 unsigned char dither
[4][4] =
2833 jmp
= (xim
->bytes_per_line
>> 1) - w
;
2834 img
= (unsigned short *)xim
->data
;
2835 for (y
= 0; y
< h
; y
++)
2838 for (x
= 0; x
< w
; x
++)
2840 ptr2
= yarray
[y
] + xarray
[x
];
2844 if ((r
== im
->shape_color
.r
) &&
2845 (g
== im
->shape_color
.g
) &&
2846 (b
== im
->shape_color
.b
))
2848 XPutPixel(sxim
, x
, y
, 0);
2856 XPutPixel(sxim
, x
, y
, 1);
2861 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
2863 if ((dither
[dithy
][dithx
] < eg
) && (g
< (256 - 8)))
2865 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
2867 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
2876 grender_15_fast_dither_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
2877 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
2878 unsigned char **yarray
)
2880 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
2881 unsigned char *ptr2
;
2882 unsigned short *img
;
2885 jmp
= (xim
->bytes_per_line
>> 1) - w
;
2886 img
= (unsigned short *)xim
->data
;
2887 for (y
= 0; y
< h
; y
++)
2892 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2895 for (x
= 0; x
< w
; x
++)
2897 ptr2
= yarray
[y
] + xarray
[x
];
2913 val
= ((er
& 0xf8) << 7) | ((eg
& 0xf8) << 2) | ((eb
& 0xf8) >> 3);
2917 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
2925 grender_15_fast_dither_mod_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
2926 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
2927 unsigned char **yarray
)
2929 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
2930 unsigned char *ptr2
;
2932 unsigned short *img
;
2935 unsigned char dither
[4][4] =
2944 jmp
= (xim
->bytes_per_line
>> 1) - w
;
2945 img
= (unsigned short *)xim
->data
;
2946 for (y
= 0; y
< h
; y
++)
2949 for (x
= 0; x
< w
; x
++)
2951 ptr2
= yarray
[y
] + xarray
[x
];
2962 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
2964 if ((dither
[dithy
][dithx
] < eg
) && (g
< (256 - 8)))
2966 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
2968 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
2976 grender_shaped_16_fast_dither_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
2977 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
2978 unsigned char **yarray
)
2980 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
2981 unsigned char *ptr2
;
2982 unsigned short *img
;
2985 jmp
= (xim
->bytes_per_line
>> 1) - w
;
2986 img
= (unsigned short *)xim
->data
;
2987 for (y
= 0; y
< h
; y
++)
2992 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
2995 for (x
= 0; x
< w
; x
++)
2997 ptr2
= yarray
[y
] + xarray
[x
];
3001 if ((r
== im
->shape_color
.r
) &&
3002 (g
== im
->shape_color
.g
) &&
3003 (b
== im
->shape_color
.b
))
3005 XPutPixel(sxim
, x
, y
, 0);
3011 XPutPixel(sxim
, x
, y
, 1);
3024 val
= ((er
& 0xf8) << 8) | ((eg
& 0xfc) << 3) | ((eb
& 0xf8) >> 3);
3028 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
3037 grender_shaped_16_fast_dither_mod_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3038 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3039 unsigned char **yarray
)
3041 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
3042 unsigned char *ptr2
;
3043 unsigned short *img
;
3046 unsigned char dither
[4][4] =
3055 jmp
= (xim
->bytes_per_line
>> 1) - w
;
3056 img
= (unsigned short *)xim
->data
;
3057 for (y
= 0; y
< h
; y
++)
3060 for (x
= 0; x
< w
; x
++)
3062 ptr2
= yarray
[y
] + xarray
[x
];
3066 if ((r
== im
->shape_color
.r
) &&
3067 (g
== im
->shape_color
.g
) &&
3068 (b
== im
->shape_color
.b
))
3070 XPutPixel(sxim
, x
, y
, 0);
3078 XPutPixel(sxim
, x
, y
, 1);
3083 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
3085 if ((dither
[dithy
][dithx
] < (eg
<< 1)) && (g
< (256 - 4)))
3087 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
3089 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
3098 grender_16_fast_dither_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3099 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3100 unsigned char **yarray
)
3102 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
3103 unsigned char *ptr2
;
3105 unsigned short *img
;
3108 jmp
= (xim
->bytes_per_line
>> 1) - w
;
3109 img
= (unsigned short *)xim
->data
;
3110 for (y
= 0; y
< h
; y
++)
3115 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
3118 for (x
= 0; x
< w
; x
++)
3120 ptr2
= yarray
[y
] + xarray
[x
];
3136 val
= ((er
& 0xf8) << 8) | ((eg
& 0xfc) << 3) | ((eb
& 0xf8) >> 3);
3140 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
3148 grender_16_fast_dither_mod_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3149 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3150 unsigned char **yarray
)
3152 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
3153 unsigned char *ptr2
;
3155 unsigned short *img
;
3158 unsigned char dither
[4][4] =
3167 jmp
= (xim
->bytes_per_line
>> 1) - w
;
3168 img
= (unsigned short *)xim
->data
;
3169 for (y
= 0; y
< h
; y
++)
3172 for (x
= 0; x
< w
; x
++)
3174 ptr2
= yarray
[y
] + xarray
[x
];
3185 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
3187 if ((dither
[dithy
][dithx
] < (eg
<< 1)) && (g
< (256 - 4)))
3189 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
3191 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
3199 grender_shaped_15_dither_mod_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3200 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3201 unsigned char **yarray
)
3203 int x
, y
, val
, r
, g
, b
, /* *ter, ex, */ er
, eg
, eb
;
3204 unsigned char *ptr2
;
3206 unsigned char dither
[4][4] =
3215 for (y
= 0; y
< h
; y
++)
3218 for (x
= 0; x
< w
; x
++)
3220 ptr2
= yarray
[y
] + xarray
[x
];
3224 if ((r
== im
->shape_color
.r
) &&
3225 (g
== im
->shape_color
.g
) &&
3226 (b
== im
->shape_color
.b
))
3228 XPutPixel(sxim
, x
, y
, 0);
3235 XPutPixel(sxim
, x
, y
, 1);
3240 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
3242 if ((dither
[dithy
][dithx
] < eg
) && (g
< (256 - 8)))
3244 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
3246 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
3247 XPutPixel(xim
, x
, y
, val
);
3254 grender_15_dither_mod_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3255 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3256 unsigned char **yarray
)
3258 int x
, y
, val
, r
, g
, b
, /* *ter, ex, */ er
, eg
, eb
;
3259 unsigned char *ptr2
;
3261 unsigned char dither
[4][4] =
3270 for (y
= 0; y
< h
; y
++)
3273 for (x
= 0; x
< w
; x
++)
3275 ptr2
= yarray
[y
] + xarray
[x
];
3286 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
3288 if ((dither
[dithy
][dithx
] < eg
) && (g
< (256 - 8)))
3290 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
3292 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
3293 XPutPixel(xim
, x
, y
, val
);
3299 grender_shaped_16_dither_mod_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3300 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3301 unsigned char **yarray
)
3303 int x
, y
, val
, r
, g
, b
, /* *ter, ex,*/ er
, eg
, eb
;
3304 unsigned char *ptr2
;
3306 unsigned char dither
[4][4] =
3315 for (y
= 0; y
< h
; y
++)
3318 for (x
= 0; x
< w
; x
++)
3320 ptr2
= yarray
[y
] + xarray
[x
];
3324 if ((r
== im
->shape_color
.r
) &&
3325 (g
== im
->shape_color
.g
) &&
3326 (b
== im
->shape_color
.b
))
3328 XPutPixel(sxim
, x
, y
, 0);
3335 XPutPixel(sxim
, x
, y
, 1);
3340 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
3342 if ((dither
[dithy
][dithx
] < (eg
<< 1)) && (g
< (256 - 4)))
3344 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
3346 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
3347 XPutPixel(xim
, x
, y
, val
);
3354 grender_16_dither_mod_ordered(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3355 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3356 unsigned char **yarray
)
3358 int x
, y
, val
, r
, g
, b
, /* *ter, ex, */ er
, eg
, eb
;
3359 unsigned char *ptr2
;
3361 unsigned char dither
[4][4] =
3370 for (y
= 0; y
< h
; y
++)
3373 for (x
= 0; x
< w
; x
++)
3375 ptr2
= yarray
[y
] + xarray
[x
];
3386 if ((dither
[dithy
][dithx
] < er
) && (r
< (256 - 8)))
3388 if ((dither
[dithy
][dithx
] < (eg
<< 1)) && (g
< (256 - 4)))
3390 if ((dither
[dithy
][dithx
] < eb
) && (b
< (256 - 8)))
3392 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
3393 XPutPixel(xim
, x
, y
, val
);
3399 grender_shaped_15_dither_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3400 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3401 unsigned char **yarray
)
3403 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
3404 unsigned char *ptr2
;
3406 for (y
= 0; y
< h
; y
++)
3411 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
3414 for (x
= 0; x
< w
; x
++)
3416 ptr2
= yarray
[y
] + xarray
[x
];
3420 if ((r
== im
->shape_color
.r
) &&
3421 (g
== im
->shape_color
.g
) &&
3422 (b
== im
->shape_color
.b
))
3424 XPutPixel(sxim
, x
, y
, 0);
3429 XPutPixel(sxim
, x
, y
, 1);
3442 val
= ((er
& 0xf8) << 7) | ((eg
& 0xf8) << 2) | ((eb
& 0xf8) >> 3);
3458 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
3462 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
3463 XPutPixel(xim
, x
, y
, val
);
3470 grender_15_dither_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3471 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3472 unsigned char **yarray
)
3474 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
3475 unsigned char *ptr2
;
3477 for (y
= 0; y
< h
; y
++)
3482 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
3485 for (x
= 0; x
< w
; x
++)
3487 ptr2
= yarray
[y
] + xarray
[x
];
3503 val
= ((er
& 0xf8) << 7) | ((eg
& 0xf8) << 2) | ((eb
& 0xf8) >> 3);
3507 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
3508 XPutPixel(xim
, x
, y
, val
);
3514 grender_shaped_16_dither_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3515 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3516 unsigned char **yarray
)
3518 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
3519 unsigned char *ptr2
;
3521 for (y
= 0; y
< h
; y
++)
3526 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
3529 for (x
= 0; x
< w
; x
++)
3531 ptr2
= yarray
[y
] + xarray
[x
];
3535 if ((r
== im
->shape_color
.r
) &&
3536 (g
== im
->shape_color
.g
) &&
3537 (b
== im
->shape_color
.b
))
3539 XPutPixel(sxim
, x
, y
, 0);
3544 XPutPixel(sxim
, x
, y
, 1);
3557 val
= ((er
& 0xf8) << 8) | ((eg
& 0xfc) << 3) | ((eb
& 0xf8) >> 3);
3561 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
3562 XPutPixel(xim
, x
, y
, val
);
3569 grender_16_dither_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3570 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3571 unsigned char **yarray
)
3573 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
3574 unsigned char *ptr2
;
3576 for (y
= 0; y
< h
; y
++)
3581 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
3584 for (x
= 0; x
< w
; x
++)
3586 ptr2
= yarray
[y
] + xarray
[x
];
3602 val
= ((er
& 0xf8) << 8) | ((eg
& 0xfc) << 3) | ((eb
& 0xf8) >> 3);
3606 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
3607 XPutPixel(xim
, x
, y
, val
);
3613 grender_shaped_15_fast_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3614 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3615 unsigned char **yarray
)
3617 int x
, y
, val
, r
, g
, b
;
3618 unsigned char *ptr2
;
3619 unsigned short *img
;
3622 jmp
= (xim
->bytes_per_line
>> 1) - w
;
3623 img
= (unsigned short *)xim
->data
;
3624 for (y
= 0; y
< h
; y
++)
3626 for (x
= 0; x
< w
; x
++)
3628 ptr2
= yarray
[y
] + xarray
[x
];
3632 if ((r
== im
->shape_color
.r
) &&
3633 (g
== im
->shape_color
.g
) &&
3634 (b
== im
->shape_color
.b
))
3636 XPutPixel(sxim
, x
, y
, 0);
3641 XPutPixel(sxim
, x
, y
, 1);
3645 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
3654 grender_15_fast_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3655 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3656 unsigned char **yarray
)
3658 int x
, y
, val
, r
, g
, b
;
3659 unsigned char *ptr2
;
3660 unsigned short *img
;
3663 jmp
= (xim
->bytes_per_line
>> 1) - w
;
3664 img
= (unsigned short *)xim
->data
;
3665 for (y
= 0; y
< h
; y
++)
3667 for (x
= 0; x
< w
; x
++)
3669 ptr2
= yarray
[y
] + xarray
[x
];
3676 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
3684 grender_shaped_16_fast_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3685 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3686 unsigned char **yarray
)
3688 int x
, y
, val
, r
, g
, b
;
3689 unsigned char *ptr2
;
3690 unsigned short *img
;
3693 jmp
= (xim
->bytes_per_line
>> 1) - w
;
3694 img
= (unsigned short *)xim
->data
;
3695 for (y
= 0; y
< h
; y
++)
3697 for (x
= 0; x
< w
; x
++)
3699 ptr2
= yarray
[y
] + xarray
[x
];
3703 if ((r
== im
->shape_color
.r
) &&
3704 (g
== im
->shape_color
.g
) &&
3705 (b
== im
->shape_color
.b
))
3707 XPutPixel(sxim
, x
, y
, 0);
3712 XPutPixel(sxim
, x
, y
, 1);
3716 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
3725 grender_16_fast_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3726 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3727 unsigned char **yarray
)
3729 int x
, y
, val
, r
, g
, b
;
3730 unsigned char *ptr2
;
3732 unsigned short *img
;
3735 jmp
= (xim
->bytes_per_line
>> 1) - w
;
3736 img
= (unsigned short *)xim
->data
;
3737 for (y
= 0; y
< h
; y
++)
3739 for (x
= 0; x
< w
; x
++)
3741 ptr2
= yarray
[y
] + xarray
[x
];
3748 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
3756 grender_shaped_24_fast_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3757 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3758 unsigned char **yarray
)
3761 unsigned char *ptr2
;
3765 jmp
= (xim
->bytes_per_line
) - w
;
3766 img
= (unsigned char *)xim
->data
;
3767 if (id
->byte_order
== BYTE_ORD_24_RGB
)
3769 for (y
= 0; y
< h
; y
++)
3771 for (x
= 0; x
< w
; x
++)
3773 ptr2
= yarray
[y
] + xarray
[x
];
3777 if ((r
== im
->shape_color
.r
) &&
3778 (g
== im
->shape_color
.g
) &&
3779 (b
== im
->shape_color
.b
))
3781 XPutPixel(sxim
, x
, y
, 0);
3786 XPutPixel(sxim
, x
, y
, 1);
3798 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
3800 for (y
= 0; y
< h
; y
++)
3802 for (x
= 0; x
< w
; x
++)
3804 ptr2
= yarray
[y
] + xarray
[x
];
3808 if ((r
== im
->shape_color
.r
) &&
3809 (g
== im
->shape_color
.g
) &&
3810 (b
== im
->shape_color
.b
))
3812 XPutPixel(sxim
, x
, y
, 0);
3817 XPutPixel(sxim
, x
, y
, 1);
3829 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
3831 for (y
= 0; y
< h
; y
++)
3833 for (x
= 0; x
< w
; x
++)
3835 ptr2
= yarray
[y
] + xarray
[x
];
3839 if ((r
== im
->shape_color
.r
) &&
3840 (g
== im
->shape_color
.g
) &&
3841 (b
== im
->shape_color
.b
))
3843 XPutPixel(sxim
, x
, y
, 0);
3848 XPutPixel(sxim
, x
, y
, 1);
3860 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
3862 for (y
= 0; y
< h
; y
++)
3864 for (x
= 0; x
< w
; x
++)
3866 ptr2
= yarray
[y
] + xarray
[x
];
3870 if ((r
== im
->shape_color
.r
) &&
3871 (g
== im
->shape_color
.g
) &&
3872 (b
== im
->shape_color
.b
))
3874 XPutPixel(sxim
, x
, y
, 0);
3879 XPutPixel(sxim
, x
, y
, 1);
3891 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
3893 for (y
= 0; y
< h
; y
++)
3895 for (x
= 0; x
< w
; x
++)
3897 ptr2
= yarray
[y
] + xarray
[x
];
3901 if ((r
== im
->shape_color
.r
) &&
3902 (g
== im
->shape_color
.g
) &&
3903 (b
== im
->shape_color
.b
))
3905 XPutPixel(sxim
, x
, y
, 0);
3910 XPutPixel(sxim
, x
, y
, 1);
3922 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
3924 for (y
= 0; y
< h
; y
++)
3926 for (x
= 0; x
< w
; x
++)
3928 ptr2
= yarray
[y
] + xarray
[x
];
3932 if ((r
== im
->shape_color
.r
) &&
3933 (g
== im
->shape_color
.g
) &&
3934 (b
== im
->shape_color
.b
))
3936 XPutPixel(sxim
, x
, y
, 0);
3941 XPutPixel(sxim
, x
, y
, 1);
3956 grender_24_fast_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
3957 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
3958 unsigned char **yarray
)
3961 unsigned char *ptr2
;
3965 jmp
= (xim
->bytes_per_line
) - w
;
3966 img
= (unsigned char *)xim
->data
;
3967 if (id
->byte_order
== BYTE_ORD_24_RGB
)
3969 for (y
= 0; y
< h
; y
++)
3971 for (x
= 0; x
< w
; x
++)
3973 ptr2
= yarray
[y
] + xarray
[x
];
3987 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
3989 for (y
= 0; y
< h
; y
++)
3991 for (x
= 0; x
< w
; x
++)
3993 ptr2
= yarray
[y
] + xarray
[x
];
4007 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
4009 for (y
= 0; y
< h
; y
++)
4011 for (x
= 0; x
< w
; x
++)
4013 ptr2
= yarray
[y
] + xarray
[x
];
4027 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
4029 for (y
= 0; y
< h
; y
++)
4031 for (x
= 0; x
< w
; x
++)
4033 ptr2
= yarray
[y
] + xarray
[x
];
4047 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
4049 for (y
= 0; y
< h
; y
++)
4051 for (x
= 0; x
< w
; x
++)
4053 ptr2
= yarray
[y
] + xarray
[x
];
4067 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
4069 for (y
= 0; y
< h
; y
++)
4071 for (x
= 0; x
< w
; x
++)
4073 ptr2
= yarray
[y
] + xarray
[x
];
4090 grender_shaped_32_fast_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4091 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4092 unsigned char **yarray
)
4094 int x
, y
, val
, r
, g
, b
;
4095 unsigned char *ptr2
;
4099 jmp
= (xim
->bytes_per_line
>> 2) - w
;
4100 img
= (unsigned int *)xim
->data
;
4101 if (id
->byte_order
== BYTE_ORD_24_RGB
)
4103 for (y
= 0; y
< h
; y
++)
4105 for (x
= 0; x
< w
; x
++)
4107 ptr2
= yarray
[y
] + xarray
[x
];
4111 if ((r
== im
->shape_color
.r
) &&
4112 (g
== im
->shape_color
.g
) &&
4113 (b
== im
->shape_color
.b
))
4115 XPutPixel(sxim
, x
, y
, 0);
4120 XPutPixel(sxim
, x
, y
, 1);
4124 val
= (r
<< 16) | (g
<< 8) | b
;
4131 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
4133 for (y
= 0; y
< h
; y
++)
4135 for (x
= 0; x
< w
; x
++)
4137 ptr2
= yarray
[y
] + xarray
[x
];
4141 if ((r
== im
->shape_color
.r
) &&
4142 (g
== im
->shape_color
.g
) &&
4143 (b
== im
->shape_color
.b
))
4145 XPutPixel(sxim
, x
, y
, 0);
4150 XPutPixel(sxim
, x
, y
, 1);
4154 val
= (r
<< 16) | (b
<< 8) | g
;
4161 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
4163 for (y
= 0; y
< h
; y
++)
4165 for (x
= 0; x
< w
; x
++)
4167 ptr2
= yarray
[y
] + xarray
[x
];
4171 if ((r
== im
->shape_color
.r
) &&
4172 (g
== im
->shape_color
.g
) &&
4173 (b
== im
->shape_color
.b
))
4175 XPutPixel(sxim
, x
, y
, 0);
4180 XPutPixel(sxim
, x
, y
, 1);
4184 val
= (b
<< 16) | (r
<< 8) | g
;
4191 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
4193 for (y
= 0; y
< h
; y
++)
4195 for (x
= 0; x
< w
; x
++)
4197 ptr2
= yarray
[y
] + xarray
[x
];
4201 if ((r
== im
->shape_color
.r
) &&
4202 (g
== im
->shape_color
.g
) &&
4203 (b
== im
->shape_color
.b
))
4205 XPutPixel(sxim
, x
, y
, 0);
4210 XPutPixel(sxim
, x
, y
, 1);
4214 val
= (b
<< 16) | (g
<< 8) | r
;
4221 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
4223 for (y
= 0; y
< h
; y
++)
4225 for (x
= 0; x
< w
; x
++)
4227 ptr2
= yarray
[y
] + xarray
[x
];
4231 if ((r
== im
->shape_color
.r
) &&
4232 (g
== im
->shape_color
.g
) &&
4233 (b
== im
->shape_color
.b
))
4235 XPutPixel(sxim
, x
, y
, 0);
4240 XPutPixel(sxim
, x
, y
, 1);
4244 val
= (g
<< 16) | (r
<< 8) | b
;
4251 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
4253 for (y
= 0; y
< h
; y
++)
4255 for (x
= 0; x
< w
; x
++)
4257 ptr2
= yarray
[y
] + xarray
[x
];
4261 if ((r
== im
->shape_color
.r
) &&
4262 (g
== im
->shape_color
.g
) &&
4263 (b
== im
->shape_color
.b
))
4265 XPutPixel(sxim
, x
, y
, 0);
4270 XPutPixel(sxim
, x
, y
, 1);
4274 val
= (g
<< 16) | (b
<< 8) | r
;
4284 grender_32_fast_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4285 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4286 unsigned char **yarray
)
4288 int x
, y
, val
, r
, g
, b
;
4289 unsigned char *ptr2
;
4293 jmp
= (xim
->bytes_per_line
>> 2) - w
;
4294 img
= (unsigned int *)xim
->data
;
4295 if (id
->byte_order
== BYTE_ORD_24_RGB
)
4297 for (y
= 0; y
< h
; y
++)
4299 for (x
= 0; x
< w
; x
++)
4301 ptr2
= yarray
[y
] + xarray
[x
];
4308 val
= (r
<< 16) | (g
<< 8) | b
;
4314 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
4316 for (y
= 0; y
< h
; y
++)
4318 for (x
= 0; x
< w
; x
++)
4320 ptr2
= yarray
[y
] + xarray
[x
];
4327 val
= (r
<< 16) | (b
<< 8) | g
;
4333 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
4335 for (y
= 0; y
< h
; y
++)
4337 for (x
= 0; x
< w
; x
++)
4339 ptr2
= yarray
[y
] + xarray
[x
];
4346 val
= (b
<< 16) | (r
<< 8) | g
;
4352 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
4354 for (y
= 0; y
< h
; y
++)
4356 for (x
= 0; x
< w
; x
++)
4358 ptr2
= yarray
[y
] + xarray
[x
];
4365 val
= (b
<< 16) | (g
<< 8) | r
;
4371 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
4373 for (y
= 0; y
< h
; y
++)
4375 for (x
= 0; x
< w
; x
++)
4377 ptr2
= yarray
[y
] + xarray
[x
];
4384 val
= (g
<< 16) | (r
<< 8) | b
;
4390 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
4392 for (y
= 0; y
< h
; y
++)
4394 for (x
= 0; x
< w
; x
++)
4396 ptr2
= yarray
[y
] + xarray
[x
];
4403 val
= (g
<< 16) | (b
<< 8) | r
;
4412 grender_shaped_15_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4413 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4414 unsigned char **yarray
)
4416 int x
, y
, val
, r
, g
, b
;
4417 unsigned char *ptr2
;
4419 for (y
= 0; y
< h
; y
++)
4421 for (x
= 0; x
< w
; x
++)
4423 ptr2
= yarray
[y
] + xarray
[x
];
4427 if ((r
== im
->shape_color
.r
) &&
4428 (g
== im
->shape_color
.g
) &&
4429 (b
== im
->shape_color
.b
))
4430 XPutPixel(sxim
, x
, y
, 0);
4433 XPutPixel(sxim
, x
, y
, 1);
4437 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
4438 XPutPixel(xim
, x
, y
, val
);
4445 grender_15_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4446 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4447 unsigned char **yarray
)
4449 int x
, y
, val
, r
, g
, b
;
4450 unsigned char *ptr2
;
4452 for (y
= 0; y
< h
; y
++)
4454 for (x
= 0; x
< w
; x
++)
4456 ptr2
= yarray
[y
] + xarray
[x
];
4463 val
= ((r
& 0xf8) << 7) | ((g
& 0xf8) << 2) | ((b
& 0xf8) >> 3);
4464 XPutPixel(xim
, x
, y
, val
);
4470 grender_shaped_16_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4471 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4472 unsigned char **yarray
)
4474 int x
, y
, val
, r
, g
, b
;
4475 unsigned char *ptr2
;
4477 for (y
= 0; y
< h
; y
++)
4479 for (x
= 0; x
< w
; x
++)
4481 ptr2
= yarray
[y
] + xarray
[x
];
4485 if ((r
== im
->shape_color
.r
) &&
4486 (g
== im
->shape_color
.g
) &&
4487 (b
== im
->shape_color
.b
))
4488 XPutPixel(sxim
, x
, y
, 0);
4491 XPutPixel(sxim
, x
, y
, 1);
4495 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
4496 XPutPixel(xim
, x
, y
, val
);
4503 grender_16_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4504 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4505 unsigned char **yarray
)
4507 int x
, y
, val
, r
, g
, b
;
4508 unsigned char *ptr2
;
4510 for (y
= 0; y
< h
; y
++)
4512 for (x
= 0; x
< w
; x
++)
4514 ptr2
= yarray
[y
] + xarray
[x
];
4521 val
= ((r
& 0xf8) << 8) | ((g
& 0xfc) << 3) | ((b
& 0xf8) >> 3);
4522 XPutPixel(xim
, x
, y
, val
);
4528 grender_shaped_24_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4529 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4530 unsigned char **yarray
)
4532 int x
, y
, val
, r
, g
, b
;
4533 unsigned char *ptr2
;
4535 if (id
->byte_order
== BYTE_ORD_24_RGB
)
4537 for (y
= 0; y
< h
; y
++)
4539 for (x
= 0; x
< w
; x
++)
4541 ptr2
= yarray
[y
] + xarray
[x
];
4545 if ((r
== im
->shape_color
.r
) &&
4546 (g
== im
->shape_color
.g
) &&
4547 (b
== im
->shape_color
.b
))
4548 XPutPixel(sxim
, x
, y
, 0);
4551 XPutPixel(sxim
, x
, y
, 1);
4555 val
= (r
<< 16) | (g
<< 8) | b
;
4556 XPutPixel(xim
, x
, y
, val
);
4561 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
4563 for (y
= 0; y
< h
; y
++)
4565 for (x
= 0; x
< w
; x
++)
4567 ptr2
= yarray
[y
] + xarray
[x
];
4571 if ((r
== im
->shape_color
.r
) &&
4572 (g
== im
->shape_color
.g
) &&
4573 (b
== im
->shape_color
.b
))
4574 XPutPixel(sxim
, x
, y
, 0);
4577 XPutPixel(sxim
, x
, y
, 1);
4581 val
= (r
<< 16) | (b
<< 8) | g
;
4582 XPutPixel(xim
, x
, y
, val
);
4587 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
4589 for (y
= 0; y
< h
; y
++)
4591 for (x
= 0; x
< w
; x
++)
4593 ptr2
= yarray
[y
] + xarray
[x
];
4597 if ((r
== im
->shape_color
.r
) &&
4598 (g
== im
->shape_color
.g
) &&
4599 (b
== im
->shape_color
.b
))
4600 XPutPixel(sxim
, x
, y
, 0);
4603 XPutPixel(sxim
, x
, y
, 1);
4607 val
= (b
<< 16) | (r
<< 8) | g
;
4608 XPutPixel(xim
, x
, y
, val
);
4613 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
4615 for (y
= 0; y
< h
; y
++)
4617 for (x
= 0; x
< w
; x
++)
4619 ptr2
= yarray
[y
] + xarray
[x
];
4623 if ((r
== im
->shape_color
.r
) &&
4624 (g
== im
->shape_color
.g
) &&
4625 (b
== im
->shape_color
.b
))
4626 XPutPixel(sxim
, x
, y
, 0);
4629 XPutPixel(sxim
, x
, y
, 1);
4633 val
= (b
<< 16) | (g
<< 8) | r
;
4634 XPutPixel(xim
, x
, y
, val
);
4639 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
4641 for (y
= 0; y
< h
; y
++)
4643 for (x
= 0; x
< w
; x
++)
4645 ptr2
= yarray
[y
] + xarray
[x
];
4649 if ((r
== im
->shape_color
.r
) &&
4650 (g
== im
->shape_color
.g
) &&
4651 (b
== im
->shape_color
.b
))
4652 XPutPixel(sxim
, x
, y
, 0);
4655 XPutPixel(sxim
, x
, y
, 1);
4659 val
= (g
<< 16) | (r
<< 8) | b
;
4660 XPutPixel(xim
, x
, y
, val
);
4665 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
4667 for (y
= 0; y
< h
; y
++)
4669 for (x
= 0; x
< w
; x
++)
4671 ptr2
= yarray
[y
] + xarray
[x
];
4675 if ((r
== im
->shape_color
.r
) &&
4676 (g
== im
->shape_color
.g
) &&
4677 (b
== im
->shape_color
.b
))
4678 XPutPixel(sxim
, x
, y
, 0);
4681 XPutPixel(sxim
, x
, y
, 1);
4685 val
= (g
<< 16) | (b
<< 8) | r
;
4686 XPutPixel(xim
, x
, y
, val
);
4694 grender_24_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4695 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4696 unsigned char **yarray
)
4698 int x
, y
, val
, r
, g
, b
;
4699 unsigned char *ptr2
;
4701 if (id
->byte_order
== BYTE_ORD_24_RGB
)
4703 for (y
= 0; y
< h
; y
++)
4705 for (x
= 0; x
< w
; x
++)
4707 ptr2
= yarray
[y
] + xarray
[x
];
4714 val
= (r
<< 16) | (g
<< 8) | b
;
4715 XPutPixel(xim
, x
, y
, val
);
4719 else if (id
->byte_order
== BYTE_ORD_24_RBG
)
4721 for (y
= 0; y
< h
; y
++)
4723 for (x
= 0; x
< w
; x
++)
4725 ptr2
= yarray
[y
] + xarray
[x
];
4732 val
= (r
<< 16) | (b
<< 8) | g
;
4733 XPutPixel(xim
, x
, y
, val
);
4737 else if (id
->byte_order
== BYTE_ORD_24_BRG
)
4739 for (y
= 0; y
< h
; y
++)
4741 for (x
= 0; x
< w
; x
++)
4743 ptr2
= yarray
[y
] + xarray
[x
];
4750 val
= (b
<< 16) | (r
<< 8) | g
;
4751 XPutPixel(xim
, x
, y
, val
);
4755 else if (id
->byte_order
== BYTE_ORD_24_BGR
)
4757 for (y
= 0; y
< h
; y
++)
4759 for (x
= 0; x
< w
; x
++)
4761 ptr2
= yarray
[y
] + xarray
[x
];
4768 val
= (b
<< 16) | (g
<< 8) | r
;
4769 XPutPixel(xim
, x
, y
, val
);
4773 else if (id
->byte_order
== BYTE_ORD_24_GRB
)
4775 for (y
= 0; y
< h
; y
++)
4777 for (x
= 0; x
< w
; x
++)
4779 ptr2
= yarray
[y
] + xarray
[x
];
4786 val
= (g
<< 16) | (r
<< 8) | b
;
4787 XPutPixel(xim
, x
, y
, val
);
4791 else if (id
->byte_order
== BYTE_ORD_24_GBR
)
4793 for (y
= 0; y
< h
; y
++)
4795 for (x
= 0; x
< w
; x
++)
4797 ptr2
= yarray
[y
] + xarray
[x
];
4804 val
= (g
<< 16) | (b
<< 8) | r
;
4805 XPutPixel(xim
, x
, y
, val
);
4812 grender_shaped_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
4813 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
4814 unsigned char **yarray
, int bpp
)
4816 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
4817 unsigned char *ptr2
;
4821 jmp
= (xim
->bytes_per_line
) - w
;
4822 img
= (unsigned char *)xim
->data
;
4823 switch (id
->render_type
)
4825 case RT_PLAIN_PALETTE
:
4826 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
4828 for (y
= 0; y
< h
; y
++)
4830 for (x
= 0; x
< w
; x
++)
4832 ptr2
= yarray
[y
] + xarray
[x
];
4836 if ((r
== im
->shape_color
.r
) &&
4837 (g
== im
->shape_color
.g
) &&
4838 (b
== im
->shape_color
.b
))
4840 XPutPixel(sxim
, x
, y
, 0);
4845 XPutPixel(sxim
, x
, y
, 1);
4849 val
= gdk_imlib_best_color_match(&r
, &g
, &b
);
4858 for (y
= 0; y
< h
; y
++)
4860 for (x
= 0; x
< w
; x
++)
4862 ptr2
= yarray
[y
] + xarray
[x
];
4866 if ((r
== im
->shape_color
.r
) &&
4867 (g
== im
->shape_color
.g
) &&
4868 (b
== im
->shape_color
.b
))
4869 XPutPixel(sxim
, x
, y
, 0);
4872 XPutPixel(sxim
, x
, y
, 1);
4876 val
= gdk_imlib_best_color_match(&r
, &g
, &b
);
4877 XPutPixel(xim
, x
, y
, val
);
4883 case RT_PLAIN_PALETTE_FAST
:
4884 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
4886 for (y
= 0; y
< h
; y
++)
4888 for (x
= 0; x
< w
; x
++)
4890 ptr2
= yarray
[y
] + xarray
[x
];
4894 if ((r
== im
->shape_color
.r
) &&
4895 (g
== im
->shape_color
.g
) &&
4896 (b
== im
->shape_color
.b
))
4898 XPutPixel(sxim
, x
, y
, 0);
4903 XPutPixel(sxim
, x
, y
, 1);
4907 val
= COLOR_RGB(r
>> 3, g
>> 3, b
>> 3);
4916 for (y
= 0; y
< h
; y
++)
4918 for (x
= 0; x
< w
; x
++)
4920 ptr2
= yarray
[y
] + xarray
[x
];
4924 if ((r
== im
->shape_color
.r
) &&
4925 (g
== im
->shape_color
.g
) &&
4926 (b
== im
->shape_color
.b
))
4927 XPutPixel(sxim
, x
, y
, 0);
4930 XPutPixel(sxim
, x
, y
, 1);
4934 val
= COLOR_RGB(r
>> 3, g
>> 3, b
>> 3);
4935 XPutPixel(xim
, x
, y
, val
);
4941 case RT_DITHER_PALETTE
:
4942 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
4944 for (y
= 0; y
< h
; y
++)
4949 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
4952 for (x
= 0; x
< w
; x
++)
4954 ptr2
= yarray
[y
] + xarray
[x
];
4958 if ((r
== im
->shape_color
.r
) &&
4959 (g
== im
->shape_color
.g
) &&
4960 (b
== im
->shape_color
.b
))
4963 XPutPixel(sxim
, x
, y
, 0);
4970 XPutPixel(sxim
, x
, y
, 1);
4989 val
= gdk_imlib_best_color_match(&er
, &eg
, &eb
);
4990 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
4999 for (y
= 0; y
< h
; y
++)
5004 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
5007 for (x
= 0; x
< w
; x
++)
5009 ptr2
= yarray
[y
] + xarray
[x
];
5013 if ((r
== im
->shape_color
.r
) &&
5014 (g
== im
->shape_color
.g
) &&
5015 (b
== im
->shape_color
.b
))
5017 XPutPixel(sxim
, x
, y
, 0);
5022 XPutPixel(sxim
, x
, y
, 1);
5041 val
= gdk_imlib_best_color_match(&er
, &eg
, &eb
);
5042 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
5043 XPutPixel(xim
, x
, y
, val
);
5049 case RT_DITHER_PALETTE_FAST
:
5050 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
5052 for (y
= 0; y
< h
; y
++)
5057 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
5060 for (x
= 0; x
< w
; x
++)
5062 ptr2
= yarray
[y
] + xarray
[x
];
5066 if ((r
== im
->shape_color
.r
) &&
5067 (g
== im
->shape_color
.g
) &&
5068 (b
== im
->shape_color
.b
))
5071 XPutPixel(sxim
, x
, y
, 0);
5078 XPutPixel(sxim
, x
, y
, 1);
5097 val
= INDEX_RGB(er
>> 3, eg
>> 3, eb
>> 3);
5098 er
= ERROR_RED(er
, val
);
5099 eg
= ERROR_GRN(eg
, val
);
5100 eb
= ERROR_BLU(eb
, val
);
5101 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
5102 *img
++ = COLOR_INDEX(val
);
5110 for (y
= 0; y
< h
; y
++)
5115 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
5118 for (x
= 0; x
< w
; x
++)
5120 ptr2
= yarray
[y
] + xarray
[x
];
5124 if ((r
== im
->shape_color
.r
) &&
5125 (g
== im
->shape_color
.g
) &&
5126 (b
== im
->shape_color
.b
))
5128 XPutPixel(sxim
, x
, y
, 0);
5133 XPutPixel(sxim
, x
, y
, 1);
5152 val
= INDEX_RGB(er
>> 3, eg
>> 3, eb
>> 3);
5153 er
= ERROR_RED(er
, val
);
5154 eg
= ERROR_GRN(eg
, val
);
5155 eb
= ERROR_BLU(eb
, val
);
5156 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
5157 XPutPixel(xim
, x
, y
, COLOR_INDEX(val
));
5171 if (id
->render_type
== RT_DITHER_TRUECOL
)
5173 if (id
->ordered_dither
)
5174 grender_shaped_15_fast_dither_mod_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5176 grender_shaped_15_fast_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5179 grender_shaped_15_fast_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5182 if (id
->render_type
== RT_DITHER_TRUECOL
)
5184 if (id
->ordered_dither
)
5185 grender_shaped_16_fast_dither_mod_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5187 grender_shaped_16_fast_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5190 grender_shaped_16_fast_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5194 if (xim
->bits_per_pixel
== 24)
5195 grender_shaped_24_fast_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5197 grender_shaped_32_fast_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5210 if (id
->render_type
== RT_DITHER_TRUECOL
)
5212 if (id
->ordered_dither
)
5213 grender_shaped_15_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5214 grender_shaped_15_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5217 grender_shaped_15_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5220 if (id
->render_type
== RT_DITHER_TRUECOL
)
5222 if (id
->ordered_dither
)
5223 grender_shaped_16_dither_mod_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5225 grender_shaped_16_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5228 grender_shaped_16_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5231 grender_shaped_24_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5233 grender_shaped_24_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5244 grender_mod(GdkImlibImage
* im
, int w
, int h
, XImage
* xim
,
5245 XImage
* sxim
, int *er1
, int *er2
, int *xarray
,
5246 unsigned char **yarray
, int bpp
)
5248 int x
, y
, val
, r
, g
, b
, *ter
, ex
, er
, eg
, eb
;
5249 unsigned char *ptr2
;
5253 jmp
= (xim
->bytes_per_line
) - w
;
5254 img
= (unsigned char *)xim
->data
;
5255 switch (id
->render_type
)
5257 case RT_PLAIN_PALETTE
:
5258 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
5260 for (y
= 0; y
< h
; y
++)
5262 for (x
= 0; x
< w
; x
++)
5264 ptr2
= yarray
[y
] + xarray
[x
];
5271 val
= gdk_imlib_best_color_match(&r
, &g
, &b
);
5279 for (y
= 0; y
< h
; y
++)
5281 for (x
= 0; x
< w
; x
++)
5283 ptr2
= yarray
[y
] + xarray
[x
];
5290 val
= gdk_imlib_best_color_match(&r
, &g
, &b
);
5291 XPutPixel(xim
, x
, y
, val
);
5296 case RT_PLAIN_PALETTE_FAST
:
5297 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
5299 for (y
= 0; y
< h
; y
++)
5301 for (x
= 0; x
< w
; x
++)
5303 ptr2
= yarray
[y
] + xarray
[x
];
5310 val
= COLOR_RGB(r
>> 3, g
>> 3, b
>> 3);
5318 for (y
= 0; y
< h
; y
++)
5320 for (x
= 0; x
< w
; x
++)
5322 ptr2
= yarray
[y
] + xarray
[x
];
5329 val
= COLOR_RGB(r
>> 3, g
>> 3, b
>> 3);
5330 XPutPixel(xim
, x
, y
, val
);
5335 case RT_DITHER_PALETTE
:
5336 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
5338 for (y
= 0; y
< h
; y
++)
5343 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
5346 for (x
= 0; x
< w
; x
++)
5348 ptr2
= yarray
[y
] + xarray
[x
];
5370 val
= gdk_imlib_best_color_match(&er
, &eg
, &eb
);
5371 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
5379 for (y
= 0; y
< h
; y
++)
5384 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
5387 for (x
= 0; x
< w
; x
++)
5389 ptr2
= yarray
[y
] + xarray
[x
];
5411 val
= gdk_imlib_best_color_match(&er
, &eg
, &eb
);
5412 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
5413 XPutPixel(xim
, x
, y
, val
);
5418 case RT_DITHER_PALETTE_FAST
:
5419 if ((id
->fastrend
) && (xim
->bits_per_pixel
== 8))
5421 for (y
= 0; y
< h
; y
++)
5426 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
5429 for (x
= 0; x
< w
; x
++)
5431 ptr2
= yarray
[y
] + xarray
[x
];
5453 val
= INDEX_RGB(er
>> 3, eg
>> 3, eb
>> 3);
5454 er
= ERROR_RED(er
, val
);
5455 eg
= ERROR_GRN(eg
, val
);
5456 eb
= ERROR_BLU(eb
, val
);
5457 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
5458 *img
++ = COLOR_INDEX(val
);
5465 for (y
= 0; y
< h
; y
++)
5470 for (ex
= 0; ex
< (w
+ 2) * 3; ex
++)
5473 for (x
= 0; x
< w
; x
++)
5475 ptr2
= yarray
[y
] + xarray
[x
];
5497 val
= INDEX_RGB(er
>> 3, eg
>> 3, eb
>> 3);
5498 er
= ERROR_RED(er
, val
);
5499 eg
= ERROR_GRN(eg
, val
);
5500 eb
= ERROR_BLU(eb
, val
);
5501 DITHER_ERROR(er1
, er2
, ex
, er
, eg
, eb
);
5502 XPutPixel(xim
, x
, y
, COLOR_INDEX(val
));
5515 if (id
->render_type
== RT_DITHER_TRUECOL
)
5517 if (id
->ordered_dither
)
5518 grender_15_fast_dither_mod_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5520 grender_15_fast_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5523 grender_15_fast_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5526 if (id
->render_type
== RT_DITHER_TRUECOL
)
5528 if (id
->ordered_dither
)
5529 grender_16_fast_dither_mod_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5531 grender_16_fast_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5534 grender_16_fast_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5538 if (xim
->bits_per_pixel
== 24)
5539 grender_24_fast_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5541 grender_32_fast_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5554 if (id
->render_type
== RT_DITHER_TRUECOL
)
5556 if (id
->ordered_dither
)
5557 grender_15_dither_mod_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5559 grender_15_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5562 grender_15_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5565 if (id
->render_type
== RT_DITHER_TRUECOL
)
5567 if (id
->ordered_dither
)
5568 grender_16_dither_mod_ordered(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5570 grender_16_dither_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5573 grender_16_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5576 grender_24_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5579 grender_24_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
);
5590 gdk_imlib_render(GdkImlibImage
* im
, gint w
, gint h
)
5595 unsigned char *tmp
, *stmp
, **yarray
, *ptr22
;
5596 int w3
, x
, inc
, pos
, *error
, *er1
, *er2
, *xarray
, ex
,
5600 int shared_pixmap
, shared_image
, ok
;
5617 gcv
.graphics_exposures
= False
;
5619 /* look for the pixmap in cache first */
5620 if (id
->cache
.on_pixmap
)
5623 gfind_pixmap(im
, w
, h
, &pm
, &mm
);
5630 im
->shape_mask
= mm
;
5632 im
->shape_mask
= NULL
;
5638 gfree_pixmappmap(im
->pixmap
);
5640 im
->shape_mask
= NULL
;
5643 if (id
->x
.depth
<= 8)
5645 else if (id
->x
.depth
<= 16)
5649 if ((id
->max_shm
) && ((bpp
* w
* h
) > id
->max_shm
))
5654 /* dithering array */
5655 error
= (int *)malloc(sizeof(int) * (w
+ 2) * 2 * 3);
5659 fprintf(stderr
, "ERROR: Cannot allocate RAM for image dither buffer\n");
5663 /* setup pointers to point right */
5665 er2
= error
+ ((w
+ 2) * 3);
5666 w3
= im
->rgb_width
* 3;
5667 ptr22
= im
->rgb_data
;
5669 /* setup coord-mapping array (specially for border scaling) */
5670 xarray
= malloc(sizeof(int) * w
);
5674 fprintf(stderr
, "ERROR: Cannot allocate X co-ord buffer\n");
5678 yarray
= malloc(sizeof(unsigned char *) * h
);
5682 fprintf(stderr
, "ERROR: Cannot allocate Y co-ord buffer\n");
5687 for (ex
= 0; ex
< ((w
+ 2) * 3 * 2); ex
++)
5692 if (w
< im
->border
.left
+ im
->border
.right
)
5700 l
= im
->border
.left
;
5701 r
= im
->border
.right
;
5705 inc
= ((im
->rgb_width
- im
->border
.left
- im
->border
.right
) << 16) / m
;
5708 for (x
= 0; x
< l
; x
++)
5710 xarray
[x
] = (pos
>> 16) + (pos
>> 16) + (pos
>> 16);
5715 for (x
= l
; x
< l
+ m
; x
++)
5717 xarray
[x
] = (pos
>> 16) + (pos
>> 16) + (pos
>> 16);
5721 pos
= (im
->rgb_width
- r
) << 16;
5722 for (x
= w
- r
; x
< w
; x
++)
5724 xarray
[x
] = (pos
>> 16) + (pos
>> 16) + (pos
>> 16);
5728 if (h
< im
->border
.top
+ im
->border
.bottom
)
5737 r
= im
->border
.bottom
;
5741 inc
= ((im
->rgb_height
- im
->border
.top
- im
->border
.bottom
) << 16) / m
;
5743 for (x
= 0; x
< l
; x
++)
5745 yarray
[x
] = ptr22
+ ((pos
>> 16) * w3
);
5750 for (x
= l
; x
< l
+ m
; x
++)
5752 yarray
[x
] = ptr22
+ ((pos
>> 16) * w3
);
5756 pos
= (im
->rgb_height
- r
) << 16;
5757 for (x
= h
- r
; x
< h
; x
++)
5759 yarray
[x
] = ptr22
+ ((pos
>> 16) * w3
);
5764 /* work out if we should use shared pixmap. images etc */
5767 if ((id
->x
.shmp
) && (id
->x
.shm
) && (!huge
))
5772 else if ((id
->x
.shm
) && (!huge
))
5781 /* init images and pixmaps */
5785 xim
= XShmCreateImage(id
->x
.disp
, id
->x
.visual
, id
->x
.depth
, ZPixmap
, NULL
, &id
->x
.last_shminfo
, w
, h
);
5788 fprintf(stderr
, "IMLIB ERROR: Mit-SHM can't create XImage for Shared Pixmap Wrapper\n");
5789 fprintf(stderr
, " Falling back on Shared XImages\n");
5796 id
->x
.last_shminfo
.shmid
= shmget(IPC_PRIVATE
, xim
->bytes_per_line
* xim
->height
, IPC_CREAT
| 0777);
5797 if (id
->x
.last_shminfo
.shmid
== -1)
5799 fprintf(stderr
, "IMLIB ERROR: SHM can't get SHM Identifier for Shared Pixmap Wrapper\n");
5800 fprintf(stderr
, " Falling back on Shared XImages\n");
5808 id
->x
.last_shminfo
.shmaddr
= xim
->data
= shmat(id
->x
.last_shminfo
.shmid
, 0, 0);
5809 id
->x
.last_shminfo
.readOnly
= False
;
5810 XShmAttach(id
->x
.disp
, &id
->x
.last_shminfo
);
5811 tmp
= (unsigned char *)xim
->data
;
5812 id
->x
.last_xim
= xim
;
5813 pmap
= XShmCreatePixmap(id
->x
.disp
, id
->x
.base_window
,
5814 id
->x
.last_shminfo
.shmaddr
,
5815 &id
->x
.last_shminfo
, w
, h
, id
->x
.depth
);
5816 tgc
= XCreateGC(id
->x
.disp
, pmap
, GCGraphicsExposures
, &gcv
);
5817 if ((im
->shape_color
.r
>= 0) && (im
->shape_color
.g
>= 0) && (im
->shape_color
.b
>= 0))
5819 sxim
= XShmCreateImage(id
->x
.disp
, id
->x
.visual
, 1, ZPixmap
, NULL
, &id
->x
.last_sshminfo
, w
, h
);
5822 fprintf(stderr
, "IMLIB ERROR: Mit-SHM can't create XImage for Shared Pixmap mask Wrapper\n");
5823 fprintf(stderr
, " Falling back on Shared XImages\n");
5824 XShmDetach(id
->x
.disp
, &id
->x
.last_shminfo
);
5826 shmdt(id
->x
.last_shminfo
.shmaddr
);
5827 shmctl(id
->x
.last_shminfo
.shmid
, IPC_RMID
, 0);
5834 id
->x
.last_sshminfo
.shmid
= shmget(IPC_PRIVATE
, sxim
->bytes_per_line
* sxim
->height
, IPC_CREAT
| 0777);
5835 if (id
->x
.last_sshminfo
.shmid
== -1)
5837 fprintf(stderr
, "IMLIB ERROR: SHM can't get SHM Identifier for Shared Pixmap mask Wrapper\n");
5838 fprintf(stderr
, " Falling back on Shared XImages\n");
5839 XShmDetach(id
->x
.disp
, &id
->x
.last_shminfo
);
5841 shmdt(id
->x
.last_shminfo
.shmaddr
);
5842 shmctl(id
->x
.last_shminfo
.shmid
, IPC_RMID
, 0);
5843 XDestroyImage(sxim
);
5848 id
->x
.last_sshminfo
.shmaddr
= sxim
->data
= shmat(id
->x
.last_sshminfo
.shmid
, 0, 0);
5849 id
->x
.last_sshminfo
.readOnly
= False
;
5850 XShmAttach(id
->x
.disp
, &id
->x
.last_sshminfo
);
5851 stmp
= (unsigned char *)sxim
->data
;
5852 id
->x
.last_sxim
= sxim
;
5853 mask
= XShmCreatePixmap(id
->x
.disp
, id
->x
.base_window
,
5854 id
->x
.last_sshminfo
.shmaddr
,
5855 &id
->x
.last_sshminfo
, w
, h
, 1);
5856 stgc
= XCreateGC(id
->x
.disp
, mask
, GCGraphicsExposures
, &gcv
);
5865 xim
= XShmCreateImage(id
->x
.disp
, id
->x
.visual
, id
->x
.depth
, ZPixmap
, NULL
, &id
->x
.last_shminfo
, w
, h
);
5868 fprintf(stderr
, "IMLIB ERROR: Mit-SHM can't create Shared XImage\n");
5869 fprintf(stderr
, " Falling back on XImages\n");
5876 id
->x
.last_shminfo
.shmid
= shmget(IPC_PRIVATE
, xim
->bytes_per_line
* xim
->height
, IPC_CREAT
| 0777);
5877 if (id
->x
.last_shminfo
.shmid
== -1)
5879 fprintf(stderr
, "IMLIB ERROR: SHM can't get SHM Identifier for Shared XImage\n");
5880 fprintf(stderr
, " Falling back on XImages\n");
5888 id
->x
.last_shminfo
.shmaddr
= xim
->data
= shmat(id
->x
.last_shminfo
.shmid
, 0, 0);
5889 id
->x
.last_shminfo
.readOnly
= False
;
5890 XShmAttach(id
->x
.disp
, &id
->x
.last_shminfo
);
5891 tmp
= (unsigned char *)xim
->data
;
5892 id
->x
.last_xim
= xim
;
5893 pmap
= XCreatePixmap(id
->x
.disp
, id
->x
.base_window
, w
, h
, id
->x
.depth
);
5894 tgc
= XCreateGC(id
->x
.disp
, pmap
, GCGraphicsExposures
, &gcv
);
5895 if ((im
->shape_color
.r
>= 0) && (im
->shape_color
.g
>= 0) && (im
->shape_color
.b
>= 0))
5897 sxim
= XShmCreateImage(id
->x
.disp
, id
->x
.visual
, 1, ZPixmap
, NULL
, &id
->x
.last_sshminfo
, w
, h
);
5900 fprintf(stderr
, "IMLIB ERROR: Mit-SHM can't create Shared XImage mask\n");
5901 fprintf(stderr
, " Falling back on XImages\n");
5902 XShmDetach(id
->x
.disp
, &id
->x
.last_shminfo
);
5904 shmdt(id
->x
.last_shminfo
.shmaddr
);
5905 shmctl(id
->x
.last_shminfo
.shmid
, IPC_RMID
, 0);
5912 id
->x
.last_sshminfo
.shmid
= shmget(IPC_PRIVATE
, sxim
->bytes_per_line
* sxim
->height
, IPC_CREAT
| 0777);
5913 if (id
->x
.last_sshminfo
.shmid
== -1)
5915 fprintf(stderr
, "Imlib ERROR: SHM can't get SHM Identifierfor Shared XImage mask\n");
5916 fprintf(stderr
, " Falling back on XImages\n");
5917 XShmDetach(id
->x
.disp
, &id
->x
.last_shminfo
);
5919 shmdt(id
->x
.last_shminfo
.shmaddr
);
5920 shmctl(id
->x
.last_shminfo
.shmid
, IPC_RMID
, 0);
5921 XDestroyImage(sxim
);
5928 id
->x
.last_sshminfo
.shmaddr
= sxim
->data
= shmat(id
->x
.last_sshminfo
.shmid
, 0, 0);
5929 id
->x
.last_sshminfo
.readOnly
= False
;
5930 XShmAttach(id
->x
.disp
, &id
->x
.last_sshminfo
);
5931 stmp
= (unsigned char *)sxim
->data
;
5932 id
->x
.last_sxim
= sxim
;
5933 mask
= XCreatePixmap(id
->x
.disp
, id
->x
.base_window
, w
, h
, 1);
5934 stgc
= XCreateGC(id
->x
.disp
, mask
, GCGraphicsExposures
, &gcv
);
5942 if ((!shared_pixmap
) && (!shared_image
))
5944 tmp
= (unsigned char *)malloc(w
* h
* bpp
);
5947 fprintf(stderr
, "IMLIB ERROR: Cannot allocate RAM for XImage data\n");
5953 xim
= XCreateImage(id
->x
.disp
, id
->x
.visual
, id
->x
.depth
, ZPixmap
, 0, (char *)tmp
, w
, h
, 8, 0);
5956 fprintf(stderr
, "IMLIB ERROR: Cannot allocate XImage buffer\n");
5963 pmap
= XCreatePixmap(id
->x
.disp
, id
->x
.base_window
, w
, h
, id
->x
.depth
);
5966 fprintf(stderr
, "IMLIB ERROR: Cannot create pixmap\n");
5973 tgc
= XCreateGC(id
->x
.disp
, pmap
, GCGraphicsExposures
, &gcv
);
5974 if ((im
->shape_color
.r
>= 0) && (im
->shape_color
.g
>= 0) && (im
->shape_color
.b
>= 0))
5976 stmp
= (unsigned char *)malloc(((w
>> 3) + 8) * h
);
5979 fprintf(stderr
, "IMLIB ERROR: Cannot allocate RAM for shape XImage data\n");
5986 sxim
= XCreateImage(id
->x
.disp
, id
->x
.visual
, 1, ZPixmap
, 0, (char *)stmp
, w
, h
, 8, 0);
5989 fprintf(stderr
, "IMLIB ERROR: Cannot allocate XImage shape buffer\n");
5997 mask
= XCreatePixmap(id
->x
.disp
, id
->x
.base_window
, w
, h
, 1);
6000 fprintf(stderr
, "IMLIB ERROR: Cannot create shape pixmap\n");
6004 XDestroyImage(sxim
);
6008 stgc
= XCreateGC(id
->x
.disp
, mask
, GCGraphicsExposures
, &gcv
);
6012 /* copy XImage to the pixmap, if not a shared pixmap */
6013 if ((im
->shape_color
.r
>= 0) && (im
->shape_color
.g
>= 0) && (im
->shape_color
.b
>= 0))
6015 if ((im
->mod
.gamma
== 256) && (im
->mod
.brightness
== 256) && (im
->mod
.contrast
== 256) &&
6016 (im
->rmod
.gamma
== 256) && (im
->rmod
.brightness
== 256) && (im
->rmod
.contrast
== 256) &&
6017 (im
->gmod
.gamma
== 256) && (im
->gmod
.brightness
== 256) && (im
->gmod
.contrast
== 256) &&
6018 (im
->bmod
.gamma
== 256) && (im
->bmod
.brightness
== 256) && (im
->bmod
.contrast
== 256))
6020 if (id
->x
.depth
<= 8)
6021 grender_shaped(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
, 8);
6023 grender_shaped(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
, id
->x
.render_depth
);
6027 if (id
->x
.depth
<= 8)
6028 grender_shaped_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
, 8);
6030 grender_shaped_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
, id
->x
.render_depth
);
6034 XShmPutImage(id
->x
.disp
, pmap
, tgc
, xim
, 0, 0, 0, 0, w
, h
, False
);
6035 XShmPutImage(id
->x
.disp
, mask
, stgc
, sxim
, 0, 0, 0, 0, w
, h
, False
);
6036 XSync(id
->x
.disp
, False
);
6037 im
->pixmap
= gdk_imlib_pixmap_foreign_new(w
, h
, id
->x
.depth
, pmap
);
6038 im
->shape_mask
= gdk_imlib_pixmap_foreign_new(w
, h
, 1, mask
);
6039 XShmDetach(id
->x
.disp
, &id
->x
.last_shminfo
);
6041 shmdt(id
->x
.last_shminfo
.shmaddr
);
6042 shmctl(id
->x
.last_shminfo
.shmid
, IPC_RMID
, 0);
6043 XShmDetach(id
->x
.disp
, &id
->x
.last_sshminfo
);
6044 XDestroyImage(sxim
);
6045 shmdt(id
->x
.last_sshminfo
.shmaddr
);
6046 shmctl(id
->x
.last_sshminfo
.shmid
, IPC_RMID
, 0);
6047 id
->x
.last_xim
= NULL
;
6048 id
->x
.last_sxim
= NULL
;
6051 XFreeGC(id
->x
.disp
, tgc
);
6052 XFreeGC(id
->x
.disp
, stgc
);
6054 else if (shared_pixmap
)
6058 p2
= XCreatePixmap(id
->x
.disp
, id
->x
.base_window
, w
, h
, id
->x
.depth
);
6059 m2
= XCreatePixmap(id
->x
.disp
, id
->x
.base_window
, w
, h
, 1);
6060 XCopyArea(id
->x
.disp
, pmap
, p2
, tgc
, 0, 0, w
, h
, 0, 0);
6061 XCopyArea(id
->x
.disp
, mask
, m2
, stgc
, 0, 0, w
, h
, 0, 0);
6062 im
->pixmap
= gdk_imlib_pixmap_foreign_new(w
, h
, id
->x
.depth
, p2
);
6063 im
->shape_mask
= gdk_imlib_pixmap_foreign_new(w
, h
, 1, m2
);
6064 XFreeGC(id
->x
.disp
, tgc
);
6065 XFreeGC(id
->x
.disp
, stgc
);
6066 XFreePixmap(id
->x
.disp
, pmap
);
6067 XFreePixmap(id
->x
.disp
, mask
);
6068 XSync(id
->x
.disp
, False
);
6069 XShmDetach(id
->x
.disp
, &id
->x
.last_shminfo
);
6071 shmdt(id
->x
.last_shminfo
.shmaddr
);
6072 shmctl(id
->x
.last_shminfo
.shmid
, IPC_RMID
, 0);
6073 XShmDetach(id
->x
.disp
, &id
->x
.last_sshminfo
);
6074 XDestroyImage(sxim
);
6075 shmdt(id
->x
.last_sshminfo
.shmaddr
);
6076 shmctl(id
->x
.last_sshminfo
.shmid
, IPC_RMID
, 0);
6077 id
->x
.last_xim
= NULL
;
6078 id
->x
.last_sxim
= NULL
;
6084 XPutImage(id
->x
.disp
, pmap
, tgc
, xim
, 0, 0, 0, 0, w
, h
);
6085 XPutImage(id
->x
.disp
, mask
, stgc
, sxim
, 0, 0, 0, 0, w
, h
);
6086 im
->pixmap
= gdk_imlib_pixmap_foreign_new(w
, h
, id
->x
.depth
, pmap
);
6087 im
->shape_mask
= gdk_imlib_pixmap_foreign_new(w
, h
, 1, mask
);
6089 XDestroyImage(sxim
);
6092 XFreeGC(id
->x
.disp
, tgc
);
6093 XFreeGC(id
->x
.disp
, stgc
);
6098 if ((im
->mod
.gamma
== 256) && (im
->mod
.brightness
== 256) && (im
->mod
.contrast
== 256) &&
6099 (im
->rmod
.gamma
== 256) && (im
->rmod
.brightness
== 256) && (im
->rmod
.contrast
== 256) &&
6100 (im
->gmod
.gamma
== 256) && (im
->gmod
.brightness
== 256) && (im
->gmod
.contrast
== 256) &&
6101 (im
->bmod
.gamma
== 256) && (im
->bmod
.brightness
== 256) && (im
->bmod
.contrast
== 256))
6103 if (id
->x
.depth
<= 8)
6104 grender(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
, 8);
6106 grender(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
, id
->x
.render_depth
);
6110 if (id
->x
.depth
<= 8)
6111 grender_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
, 8);
6113 grender_mod(im
, w
, h
, xim
, sxim
, er1
, er2
, xarray
, yarray
, id
->x
.render_depth
);
6117 XShmPutImage(id
->x
.disp
, pmap
, tgc
, xim
, 0, 0, 0, 0, w
, h
, False
);
6118 im
->pixmap
= gdk_imlib_pixmap_foreign_new(w
, h
, id
->x
.depth
, pmap
);
6119 im
->shape_mask
= NULL
;
6120 XSync(id
->x
.disp
, False
);
6121 XShmDetach(id
->x
.disp
, &id
->x
.last_shminfo
);
6123 shmdt(id
->x
.last_shminfo
.shmaddr
);
6124 shmctl(id
->x
.last_shminfo
.shmid
, IPC_RMID
, 0);
6125 id
->x
.last_xim
= NULL
;
6128 XFreeGC(id
->x
.disp
, tgc
);
6130 else if (shared_pixmap
)
6134 p2
= XCreatePixmap(id
->x
.disp
, id
->x
.base_window
, w
, h
, id
->x
.depth
);
6135 XCopyArea(id
->x
.disp
, pmap
, p2
, tgc
, 0, 0, w
, h
, 0, 0);
6136 im
->pixmap
= gdk_imlib_pixmap_foreign_new(w
, h
, id
->x
.depth
, p2
);
6137 im
->shape_mask
= NULL
;
6138 XFreeGC(id
->x
.disp
, tgc
);
6139 XFreePixmap(id
->x
.disp
, pmap
);
6140 XSync(id
->x
.disp
, False
);
6141 XShmDetach(id
->x
.disp
, &id
->x
.last_shminfo
);
6143 shmdt(id
->x
.last_shminfo
.shmaddr
);
6144 shmctl(id
->x
.last_shminfo
.shmid
, IPC_RMID
, 0);
6145 id
->x
.last_xim
= NULL
;
6151 XPutImage(id
->x
.disp
, pmap
, tgc
, xim
, 0, 0, 0, 0, w
, h
);
6152 im
->pixmap
= gdk_imlib_pixmap_foreign_new(w
, h
, id
->x
.depth
, pmap
);
6153 im
->shape_mask
= NULL
;
6157 XFreeGC(id
->x
.disp
, tgc
);
6162 XSync(id
->x
.disp
, False
);
6167 /* add this pixmap to the cache */
6168 gadd_pixmap(im
, w
, h
, xim
, sxim
);