lots more work on mr imlib2 :)

SVN revision: 203
This commit is contained in:
Carsten Haitzler 1999-09-08 17:27:40 +00:00
parent bc6a4e6343
commit 273f057f52
12 changed files with 459 additions and 221 deletions

75
api.c
View File

@ -286,16 +286,20 @@ imlib_render_image_on_drawable(Imlib_Image image, Display *display,
Colormap colormap, int depth,
char dithered_rendering,
char alpha_blending,
int x, int y)
int x, int y,
Imlib_Color_Modifier color_modifier)
{
ImlibImage *im;
ImlibColorModifier *cm;
CAST_IMAGE(im, image);
cm = (ImlibColorModifier *)color_modifier;
__imlib_RenderImage(display, im, drawable, 0, visual, colormap, depth,
0, 0, im->w, im->h, x, y, im->w, im->h,
0,
dithered_rendering,
alpha_blending, 0);
alpha_blending, 0,
cm);
}
void
@ -305,16 +309,20 @@ imlib_render_image_on_drawable_at_size(Imlib_Image image, Display *display,
char anti_aliased_scaling,
char dithered_rendering,
char alpha_blending,
int x, int y, int width, int height)
int x, int y, int width, int height,
Imlib_Color_Modifier color_modifier)
{
ImlibImage *im;
ImlibColorModifier *cm;
CAST_IMAGE(im, image);
cm = (ImlibColorModifier *)color_modifier;
__imlib_RenderImage(display, im, drawable, 0, visual, colormap, depth,
0, 0, width, height, x, y, width, height,
0, 0, im->w, im->h, x, y, width, height,
anti_aliased_scaling,
dithered_rendering,
alpha_blending, 0);
alpha_blending, 0,
cm);
}
void
@ -331,8 +339,12 @@ imlib_blend_image_onto_image(Imlib_Image source_image,
CAST_IMAGE(im_dst, destination_image);
/* FIXME: doesnt do clipping in any way or form - must fix */
__imlib_BlendRGBAToRGBA(im_src->data, 0, im_dst->data, 0,
source_width, source_height);
if (IMAGE_HAS_ALPHA(im_src))
__imlib_BlendRGBAToRGBA(im_src->data, 0, im_dst->data, 0,
source_width, source_height);
else
__imlib_BlendRGBAToRGB(im_src->data, 0, im_dst->data, 0,
source_width, source_height);
}
Imlib_Image
@ -382,7 +394,7 @@ imlib_create_image_from_drawable(Display *display,
Pixmap mask, Visual *visual,
Colormap colormap, int depth,
int x, int y,
int width, int height)
int width, int height, char need_to_grab_x)
{
ImlibImage *im;
char domask = 0;
@ -390,12 +402,51 @@ imlib_create_image_from_drawable(Display *display,
if (mask)
domask = 1;
im = __imlib_CreateImage(width, height, NULL);
im->data = __imlib_GrabDrawableToRGBA(display, drawable, mask, visual,
colormap, depth, x, y, width, height,
domask);
im->data = malloc(width * height * sizeof(DATA32));
__imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height,
display, drawable, mask, visual,
colormap, depth, x, y, width, height,
domask, need_to_grab_x);
return (Imlib_Image)im;
}
char
imlib_copy_drawable_to_image(Imlib_Image image, Display *display,
Drawable drawable, Pixmap mask, Visual *visual,
Colormap colormap, int depth, int x, int y,
int width, int height,
int destination_x, int destination_y,
char need_to_grab_x)
{
ImlibImage *im;
char domask = 0;
if (mask)
domask = 1;
CAST_IMAGE(im, image);
if (destination_x < 0)
{
width += destination_x;
destination_x = 0;
}
else if (destination_x >= im->w)
return 0;
if (destination_y < 0)
{
height += destination_y;
destination_y = 0;
}
else if (destination_y >= im->h)
return 0;
if ((width <= 0) || (height <= 0))
return 0;
return __imlib_GrabDrawableToRGBA(im->data, destination_x, destination_y,
im->w, im->h, display, drawable,
mask, visual, colormap, depth,
x, y, width, height,
domask, need_to_grab_x);
}
Imlib_Image
imlib_clone_image(Imlib_Image image)
{

28
api.h
View File

@ -82,14 +82,16 @@ void imlib_render_image_on_drawable(Imlib_Image image, Display *display,
Colormap colormap, int depth,
char dithered_rendering,
char alpha_blending,
int x, int y);
int x, int y,
Imlib_Color_Modifier color_modifier);
void imlib_render_image_on_drawable_at_size(Imlib_Image image, Display *display,
Drawable drawable, Visual *visual,
Colormap colormap, int depth,
char anti_aliased_scaling,
char dithered_rendering,
char alpha_blending,
int x, int y, int width, int height);
int x, int y, int width, int height,
Imlib_Color_Modifier color_modifier);
/* rgba space ops */
void imlib_blend_image_onto_image(Imlib_Image source_image,
Imlib_Image destination_image,
@ -103,6 +105,17 @@ void imlib_blend_image_onto_image(Imlib_Image source_image,
/* FIXME: */
/* draw line, polygon, rect - with option of drawing in rgb or alpha or both */
/* apply alpha of one image to another */
void imlib_image_updates_reset(Imlib_Image image);
void imlib_image_updates_flush_to_drawable(Imlib_Image image, Display *display,
Drawable drawable, Visual *visual,
Colormap colormap, int depth,
char dithered_rendering,
char alpha_blending,
int x, int y,
int width, int height,
Imlib_Color_Modifier color_modifier);
void imlibimage_updates_add(Imlib_Image image, int x, int y,
int width, int height);
#endif
@ -117,8 +130,17 @@ Imlib_Image imlib_create_image_from_drawable(Display *display,
Pixmap mask, Visual *visual,
Colormap colormap, int depth,
int x, int y,
int width, int height);
int width, int height,
char need_to_grab_x);
Imlib_Image imlib_clone_image(Imlib_Image image);
char imlib_copy_drawable_to_image(Imlib_Image image, Display *display,
Drawable drawable,
Pixmap mask, Visual *visual,
Colormap colormap, int depth,
int x, int y,
int width, int height,
int destination_x, int destination_y,
char need_to_grab_x);
#if 0
Imlib_image imlib_create_cropped_image(Imlib_Image image,

59
blend.c
View File

@ -2,7 +2,7 @@
#include "blend.h"
void
__imlib_BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
__imlib_BlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
int w, int h)
{
int x, y;
@ -29,13 +29,13 @@ __imlib_BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
((((*p2 & 0x00ff00ff) * r) >> 8) & 0x00ff00ff) +
((((*p2 >> 8) & 0x00ff00ff) * r) & 0xff00ff00);
#else
r = (*p1 ) & 0xff;
b = (*p1 ) & 0xff;
g = (*p1 >> 8 ) & 0xff;
b = (*p1 >> 16) & 0xff;
r = (*p1 >> 16) & 0xff;
rr = (*p2 ) & 0xff;
bb = (*p2 ) & 0xff;
gg = (*p2 >> 8 ) & 0xff;
bb = (*p2 >> 16) & 0xff;
rr = (*p2 >> 16) & 0xff;
tmp = (r - rr) * a;
nr = rr + ((tmp + (tmp >> 8) + 0x80) >> 8);
@ -43,7 +43,7 @@ __imlib_BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
ng = gg + ((tmp + (tmp >> 8) + 0x80) >> 8);
tmp = (b - bb) * a;
nb = bb + ((tmp + (tmp >> 8) + 0x80) >> 8);
*p2 = ((nb & 0xff) << 16) | ((ng & 0xff) << 8) | (nr & 0xff);
*p2 = ((nr & 0xff) << 16) | ((ng & 0xff) << 8) | (nb & 0xff);
#endif
}
else
@ -53,3 +53,50 @@ __imlib_BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
}
}
}
void
__imlib_BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
int w, int h)
{
int x, y;
DATA32 *p1, *p2;
for (y = 0; y < h; y++)
{
DATA8 a, nr, ng, nb, r, g, b, rr, gg, bb, aa, na;
int tmp;
p1 = src + (y * (w + src_jump));
p2 = dst + (y * (w + dst_jump));
for (x = 0; x < w; x++)
{
a = (*p1 >> 24) & 0xff;
if (a < 255)
{
b = (*p1 ) & 0xff;
g = (*p1 >> 8 ) & 0xff;
r = (*p1 >> 16) & 0xff;
bb = (*p2 ) & 0xff;
gg = (*p2 >> 8 ) & 0xff;
rr = (*p2 >> 16) & 0xff;
aa = (*p2 >> 24) & 0xff;
tmp = (r - rr) * a;
nr = rr + ((tmp + (tmp >> 8) + 0x80) >> 8);
tmp = (g - gg) * a;
ng = gg + ((tmp + (tmp >> 8) + 0x80) >> 8);
tmp = (b - bb) * a;
nb = bb + ((tmp + (tmp >> 8) + 0x80) >> 8);
tmp = a + aa;
na = (tmp | ((tmp & 256) - ((tmp & 256) >> 8)));
*p2 = ((na & 0xff) << 24) | ((nr & 0xff) << 16) |
((ng & 0xff) << 8) | (nb & 0xff);
}
else
*p2 = *p1;
p1++;
p2++;
}
}
}

View File

@ -1,6 +1,9 @@
#ifndef __BLEND
#define __BLEND 1
void
__imlib_BlendRGBAToRGB(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
int w, int h);
void
__imlib_BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
int w, int h);
#endif

2
draw.c
View File

@ -43,7 +43,7 @@ __imlib_CreatePixmapsForImage(Display *d, Drawable w, Visual *v, int depth,
*m = mask;
}
__imlib_RenderImage(d, im, pmap, mask, v, cm, depth, sx, sy, sw, sh, 0, 0,
dw, dh, anitalias, hiq, 0, dither_mask);
dw, dh, anitalias, hiq, 0, dither_mask, cmod);
return 1;
}

235
grab.c
View File

@ -17,29 +17,32 @@ Tmp_HandleXError(Display * d, XErrorEvent * ev)
_x_err = 1;
}
DATA32 *
__imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap cm,
int depth, int x, int y, int w, int h, char domask)
char
__imlib_GrabDrawableToRGBA(DATA32 *data, int ox, int oy, int ow, int oh,
Display *d, Drawable p, Pixmap m, Visual *v,
Colormap cm, int depth, int x, int y,
int w, int h, char domask, char grab)
{
XErrorHandler prev_erh = NULL;
XWindowAttributes xatt, ratt;
char is_pixmap = 0, created_mask = 0, is_shm = 0, is_mshm = 0;
int i, pixel, mpixel;
int src_x, src_y, src_w, src_h, ow, oh, ox, oy;
int src_x, src_y, src_w, src_h, origx, origy, origw, origh;
int width, height, clipx, clipy, inx, iny;
XShmSegmentInfo shminfo, mshminfo;
XImage *xim = NULL, *mxim = NULL;
static char x_does_shm = -1;
DATA32 *data, *ptr;
DATA32 *ptr;
DATA8 rtab[256], gtab[256], btab[256];
XColor cols[256];
ox = x;
oy = y;
ow = w;
oh = h;
origx = x;
origy = y;
origw = w;
origh = h;
/* FIXME: hmm - need to co-ordinate this with the app */
XGrabServer(d);
if (grab)
XGrabServer(d);
prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
_x_err = 0;
/* lets see if its a pixmap or not */
@ -69,8 +72,9 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
if ((xatt.map_state != IsViewable) &&
(xatt.backing_store == NotUseful))
{
XUngrabServer(d);
return NULL;
if (grab)
XUngrabServer(d);
return 0;
}
}
@ -120,8 +124,9 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
}
if ((width <= 0) || (height <= 0))
{
XUngrabServer(d);
return NULL;
if (grab)
XUngrabServer(d);
return 0;
}
w = width;
h = height;
@ -303,12 +308,13 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
if ((is_shm) || (is_mshm))
{
XSync(d, False);
XUngrabServer(d);
if (grab)
XUngrabServer(d);
XSync(d, False);
}
else
else if (grab)
XUngrabServer(d);
if ((xatt.depth == 1) && (!cm) && (is_pixmap))
{
rtab[0] = 0;
@ -342,12 +348,21 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
btab[i] = cols[i].blue >> 8;
}
}
data = malloc(ow * oh * sizeof(DATA32));
if (data)
{
inx = x - ox;
iny = y - oy;
DATA32 *src;
if (origx < 0)
inx = -origx;
else
inx = ox;
if (origy < 0)
iny = -origy;
else
iny = oy;
/* go thru the XImage and convert */
if (xim->bits_per_pixel == 32)
depth = 32;
switch (depth)
{
case 0:
@ -369,9 +384,9 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
pixel = XGetPixel(xim, x, y);
mpixel = XGetPixel(mxim, x, y);
*ptr++ = (0xff000000 >> (mpixel << 31)) |
(btab[pixel & 0xff] << 16) |
(btab[pixel & 0xff]) |
(gtab[pixel & 0xff] << 8) |
(rtab[pixel & 0xff]);
(rtab[pixel & 0xff] << 16);
}
}
@ -385,101 +400,146 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
{
pixel = XGetPixel(xim, x, y);
*ptr++ = 0xff000000 |
(btab[pixel & 0xff] << 16) |
(btab[pixel & 0xff]) |
(gtab[pixel & 0xff] << 8) |
(rtab[pixel & 0xff]);
(rtab[pixel & 0xff] << 16);
}
}
}
break;
case 16:
#undef MP
#undef RMSK
#undef GMSK
#undef BMSK
#undef R1SH
#undef G1SH
#undef B1SH
#undef R2SH
#undef G2SH
#undef B2SH
#undef P1
#undef P2
#define MP(x, y) (0xff000000 >> (XGetPixel(mxim, (x), (y)) << 31))
#define RMSK 0xf80000
#define GMSK 0x00fc00
#define BMSK 0x0000f8
#define R1SH(p) ((p) << 8)
#define G1SH(p) ((p) << 5)
#define B1SH(p) ((p) << 3)
#define R2SH(p) ((p) >> 8)
#define G2SH(p) ((p) >> 11)
#define B2SH(p) ((p) >> 13)
#define P1(p) (R1SH(p) & RMSK) | (G1SH(p) & GMSK) | (B1SH(p) & BMSK)
#define P2(p) (R2SH(p) & RMSK) | (G2SH(p) & GMSK) | (B2SH(p) & BMSK)
if (mxim)
{
for (y = 0; y < h; y++)
{
DATA8 r, g, b;
src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
for (x = 0; x < (w - 1); x += 2)
{
*ptr++ = MP(x, y) | P1(*src);
*ptr++ = MP(x + 1, y) | P2(*src);
src++;
}
if (x == (w - 1))
{
pixel = XGetPixel(xim, x, y);
r = (pixel >> 8) & 0xf8;
g = (pixel >> 3) & 0xfc;
b = (pixel << 3) & 0xf8;
mpixel = XGetPixel(mxim, x, y);
*ptr++ = (0xff000000 >> (mpixel << 31)) |
(b << 16) |
(g << 8) |
(r);
*ptr++ = MP(x, y) | P1(pixel);
}
}
}
#undef MP
#define MP(x, y) (0xff000000)
else
{
for (y = 0; y < h; y++)
{
DATA8 r, g, b;
src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
for (x = 0; x < (w - 1); x += 2)
{
*ptr++ = MP(x, y) | P1(*src);
*ptr++ = MP(x + 1, y) | P2(*src);
src++;
}
if (x == (w - 1))
{
pixel = XGetPixel(xim, x, y);
r = (pixel >> 8) & 0xf8;
g = (pixel >> 3) & 0xfc;
b = (pixel << 3) & 0xf8;
*ptr++ = 0xff000000 |
(b << 16) |
(g << 8) |
(r);
*ptr++ = MP(x, y) | P1(pixel);
}
}
}
break;
case 15:
#undef MP
#undef RMSK
#undef GMSK
#undef BMSK
#undef R1SH
#undef G1SH
#undef B1SH
#undef R2SH
#undef G2SH
#undef B2SH
#undef P1
#undef P2
#define MP(x, y) (0xff000000 >> (XGetPixel(mxim, (x), (y)) << 31))
#define RMSK 0xf80000
#define GMSK 0x00f800
#define BMSK 0x0000f8
#define R1SH(p) ((p) << 9)
#define G1SH(p) ((p) << 6)
#define B1SH(p) ((p) << 3)
#define R2SH(p) ((p) >> 7)
#define G2SH(p) ((p) >> 10)
#define B2SH(p) ((p) >> 13)
#define P1(p) (R1SH(p) & RMSK) | (G1SH(p) & GMSK) | (B1SH(p) & BMSK)
#define P2(p) (R2SH(p) & RMSK) | (G2SH(p) & GMSK) | (B2SH(p) & BMSK)
if (mxim)
{
for (y = 0; y < h; y++)
{
DATA8 r, g, b;
src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
for (x = 0; x < (w - 1); x += 2)
{
*ptr++ = MP(x, y) | P1(*src);
*ptr++ = MP(x + 1, y) | P2(*src);
src++;
}
if (x == (w - 1))
{
pixel = XGetPixel(xim, x, y);
r = (pixel >> 7) & 0xf8;
g = (pixel >> 2) & 0xf8;
b = (pixel << 3) & 0xf8;
mpixel = XGetPixel(mxim, x, y);
*ptr++ = (0xff000000 >> (mpixel << 31)) |
(b << 16) |
(g << 8) |
(r);
*ptr++ = MP(x, y) | P1(pixel);
}
}
}
#undef MP
#define MP(x, y) (0xff000000)
else
{
for (y = 0; y < h; y++)
{
DATA8 r, g, b;
src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
for (x = 0; x < (w - 1); x += 2)
{
*ptr++ = MP(x, y) | P1(*src);
*ptr++ = MP(x + 1, y) | P2(*src);
src++;
}
if (x == (w - 1))
{
pixel = XGetPixel(xim, x, y);
r = (pixel >> 7) & 0xf8;
g = (pixel >> 2) & 0xf8;
b = (pixel << 3) & 0xf8;
*ptr++ = 0xff000000 |
(b << 16) |
(g << 8) |
(r);
*ptr++ = MP(x, y) | P1(pixel);
}
}
}
break;
case 24:
case 32:
if (mxim)
{
for (y = 0; y < h; y++)
@ -490,9 +550,7 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
pixel = XGetPixel(xim, x, y);
mpixel = XGetPixel(mxim, x, y);
*ptr++ = (0xff000000 >> (mpixel << 31)) |
((pixel & 0x000000ff) << 16) |
((pixel & 0x0000ff00)) |
((pixel & 0x00ff0000) >> 16);
(pixel & 0x00ffffff);
}
}
}
@ -505,9 +563,38 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
{
pixel = XGetPixel(xim, x, y);
*ptr++ = 0xff000000 |
((pixel & 0x000000ff) << 16) |
((pixel & 0x0000ff00)) |
((pixel & 0x00ff0000) >> 16);
(pixel & 0x00ffffff);
}
}
}
break;
case 32:
if (mxim)
{
for (y = 0; y < h; y++)
{
src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
{
mpixel = XGetPixel(mxim, x, y);
*ptr++ = (0xff000000 >> (mpixel << 31)) |
((*src) & 0x00ffffff);
src++;
}
}
}
else
{
for (y = 0; y < h; y++)
{
src = (DATA32 *)(xim->data + (xim->bytes_per_line * y));
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
{
*ptr++ = 0xff000000 |
((*src) & 0x00ffffff);
src++;
}
}
}
@ -535,5 +622,5 @@ __imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap
XFreePixmap(d, m);
if (mxim)
XDestroyImage(mxim);
return data;
return 1;
}

8
grab.h
View File

@ -1,6 +1,8 @@
#ifndef __GRAB
#define __GRAB 1
DATA32 *
__imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap cm,
int depth, int x, int y, int w, int h, char domask);
char
__imlib_GrabDrawableToRGBA(DATA32 *data, int ox, int oy, int ow, int oh,
Display *d, Drawable p, Pixmap m, Visual *v,
Colormap cm, int depth, int x, int y,
int w, int h, char domask, char grab);
#endif

View File

@ -66,7 +66,9 @@ _load_PNG (int *ww, int *hh, FILE *f)
/* Palette -> RGB */
if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_expand(png_ptr);
/* 16bit color -> 8bit color */
/* we want ARGB */
png_set_bgr(png_ptr);
/* 16bit color -> 8bit color */
png_set_strip_16(png_ptr);
/* pack all pixels to byte boundaires */
png_set_packing(png_ptr);

99
main.c
View File

@ -21,12 +21,12 @@
Display *disp;
#if 0
#if 1
int main (int argc, char **argv)
{
Window win;
int i, j;
ImlibImage *im;
Imlib_Image *im;
Visual *vis;
int depth;
int sec1, usec1, sec2, usec2;
@ -43,6 +43,7 @@ int main (int argc, char **argv)
int dith = 0;
int loop = 1;
int blend = 0;
int interactive = 0;
for (i = 1; i < argc; i++)
{
@ -50,6 +51,11 @@ int main (int argc, char **argv)
root = 1;
else if (!strcmp(argv[i], "-smooth"))
aa = 1;
else if (!strcmp(argv[i], "-interactive"))
{
interactive = 1;
loop = 0;
}
else if (!strcmp(argv[i], "-blend"))
blend = 1;
else if (!strcmp(argv[i], "-dither"))
@ -70,13 +76,16 @@ int main (int argc, char **argv)
printf("init\n");
disp = XOpenDisplay(NULL);
printf("load\n");
im = __imlib_LoadImage(file, NULL, 0, 0, 0);
im = imlib_load_image(file);
if (!im)
printf("load fialed\n");
{
printf("load fialed\n");
exit(0);
}
if (w < 0)
{
w = im->w;
h = im->h;
w = imlib_image_get_width(im);
h = imlib_image_get_height(im);
}
if (root)
win = DefaultRootWindow(disp);
@ -99,47 +108,54 @@ int main (int argc, char **argv)
gettimeofday(&timev,NULL);
sec1=(int)timev.tv_sec; /* and stores it so we can time outselves */
usec1=(int)timev.tv_usec; /* we will use this to vary speed of rot */
__imlib_SetMaxXImageCount(disp, 5);
__imlib_SetMaxXImageCount(disp, 0);
if (loop)
{
for (i = 0; i < w; i++)
{
static Pixmap m = 0;
if (m)
XFreePixmap(disp, m);
m = 0;
/*
if (((w - i) > 0) && ((((w - i) * h) / w) > 0))
m = XCreatePixmap(disp, win, (w - i), ((w - i) * h) / w, 1);
*/ __imlib_RenderImage(disp, im,
win, m,
vis,
DefaultColormap(disp, DefaultScreen(disp)),
depth,
0, 0, im->w, im->h,
0, 0, w - i, ((w - i) * h) / w,
(char)aa, (char)dith, (char)blend, 0
);
if (m)
{
XShapeCombineMask(disp, win, ShapeBounding, 0, 0, m, ShapeSet);
}
imlib_render_image_on_drawable_at_size(im, disp, win, vis,
DefaultColormap(disp, DefaultScreen(disp)),
depth,
aa, dith, blend,
0, 0,
w - i, (((w - i) * h) / w),
NULL);
pixels += (w - i) * (((w - i) * h) / w);
}
}
else if (interactive)
{
while (1)
{
int x, y, dum;
unsigned int dui;
Window rt;
Imlib_Image im2;
XQueryPointer(disp, win, &rt, &rt, &x, &y,
&dum, &dum, &dui);
im2 = imlib_create_image_from_drawable(disp, win, 0, vis,
DefaultColormap(disp, DefaultScreen(disp)),
depth, x - (w / 2), y - (h / 2), w, h, 0);
imlib_render_image_on_drawable(im2, disp, win, vis,
DefaultColormap(disp, DefaultScreen(disp)),
depth, dith, 0, 32, 32, NULL);
imlib_free_image_and_decache(im2);
}
}
else
{
__imlib_RenderImage(disp, im,
win, 0,
vis,
DefaultColormap(disp, DefaultScreen(disp)),
depth,
0, 0, im->w, im->h,
0, 0, w, h,
(char)aa, (char)dith, (char)blend, 0
);
pixels += (w) * (h);
for (i = 0; i < w; i++)
{
imlib_render_image_on_drawable_at_size(im, disp, win, vis,
DefaultColormap(disp, DefaultScreen(disp)),
depth,
aa, dith, blend,
0, 0,
w, h,
NULL);
pixels += w * h;
}
}
gettimeofday(&timev,NULL);
sec2=(int)timev.tv_sec; /* and stores it so we can time outselves */
@ -157,7 +173,7 @@ int main (int argc, char **argv)
printf("%3.3f Mpixels / sec\n", (double)(pixels) / (sec * 1000000));
return 0;
}
#endif
#else
int main (int argc, char **argv)
{
Window win;
@ -229,8 +245,8 @@ int main (int argc, char **argv)
{
for (i = 0; i < (argc - start); i++)
{
imlib_blend_image_onto_image(im[i], tmp, 0, 0, w, h, 0, 0, w, h);
imlib_render_image_on_drawable(tmp, disp, win, vis, cm, depth,
/* imlib_blend_image_onto_image(im[i], tmp, 0, 0, w, h, 0, 0, w, h);*/
imlib_render_image_on_drawable(im[i], disp, win, vis, cm, depth,
dith, 0,
x, y);
memcpy(data2, data1, w * h *sizeof(DATA32));
@ -238,3 +254,4 @@ int main (int argc, char **argv)
}
return 0;
}
#endif

12
rend.c
View File

@ -27,7 +27,8 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
Visual *v, Colormap cm, int depth,
int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh,
char anitalias, char hiq, char blend, char dither_mask)
char anitalias, char hiq, char blend, char dither_mask,
ImlibColorModifier *cmod)
{
XImage *xim, *mxim;
Context *ct;
@ -118,7 +119,14 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
ct = __imlib_GetContext(d, v, cm, depth);
__imlib_RGBASetupContext(ct);
if ((blend) && (IMAGE_HAS_ALPHA(im)))
back = __imlib_GrabDrawableToRGBA(d, w, 0, v, cm, depth, dx, dy, dw, dh, 0);
{
back = malloc(dw *dh *sizeof(DATA32));
if (!__imlib_GrabDrawableToRGBA(back, 0, 0, dw, dh, d, w, 0, v, cm, depth, dx, dy, dw, dh, 0, 1))
{
free(back);
back = NULL;
}
}
/* get a new XImage - or get one from the cached list */
xim = __imlib_ProduceXImage(d, v, depth, dw, dh, &shm);
if (!xim)

3
rend.h
View File

@ -6,5 +6,6 @@ __imlib_RenderImage(Display *d, ImlibImage *im,
Visual *v, Colormap cm, int depth,
int sx, int sy, int sw, int sh,
int dx, int dy, int dw, int dh,
char anitalias, char hiq, char blend, char dither_mask);
char anitalias, char hiq, char blend, char dither_mask,
ImlibColorModifier *cmod);
#endif

152
rgba.c
View File

@ -39,40 +39,40 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB565 conversion */
#define WRITE1_RGBA_RGB565(src, dest) \
*dest = ((*src << 8) & 0xf800) | \
*dest = ((*src >> 8) & 0xf800) | \
((*src >> 5) & 0x7e0) | \
((*src >> 19) & 0x1f); dest++; src++
((*src >> 3) & 0x1f); dest++; src++
#ifdef __BIG_ENDIAN__
#define WRITE2_RGBA_RGB565(src, dest) \
{ \
*((DATA32 *)dest) = ((src[1] << 8) & 0xf800) | \
*((DATA32 *)dest) = ((src[1] >> 8) & 0xf800) | \
((src[1] >> 5) & 0x7e0) | \
((src[1] >> 19) & 0x1f) | \
((src[0] << 24) & 0xf8000000) | \
((src[1] >> 3) & 0x1f) | \
((src[0] << 8) & 0xf8000000) | \
((src[0] << 11) & 0x7e00000) | \
((src[0] >> 3) & 0x1f0000); \
((src[0] << 13) & 0x1f0000); \
dest += 2; src += 2; \
}
#else
#define WRITE2_RGBA_RGB565(src, dest) \
{ \
*((DATA32 *)dest) = ((src[0] << 8) & 0xf800) | \
*((DATA32 *)dest) = ((src[0] >> 8) & 0xf800) | \
((src[0] >> 5) & 0x7e0) | \
((src[0] >> 19) & 0x1f) | \
((src[1] << 24) & 0xf8000000) | \
((src[0] >> 3) & 0x1f) | \
((src[1] << 8) & 0xf8000000) | \
((src[1] << 11) & 0x7e00000) | \
((src[1] >> 3) & 0x1f0000); \
((src[1] << 13) & 0x1f0000); \
dest += 2; src += 2; \
}
#endif
/*****************************************************************************/
/* MACROS for dithered RGBA -> RGB565 conversion */
#define DITHER_RGBA_565_LUT_R(num) \
(_dither_r16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 0 ) & 0xff)])
(_dither_r16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 16 ) & 0xff)])
#define DITHER_RGBA_565_LUT_G(num) \
(_dither_g16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 8 ) & 0xff)])
#define DITHER_RGBA_565_LUT_B(num) \
(_dither_b16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 16 ) & 0xff)])
(_dither_b16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 0 ) & 0xff)])
#define WRITE1_RGBA_RGB565_DITHER(src, dest) \
*dest = (DITHER_RGBA_565_LUT_R(0)) | \
@ -110,40 +110,40 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB555 conversion */
#define WRITE1_RGBA_RGB555(src, dest) \
*dest = ((*src << 7) & 0x7c00) | \
*dest = ((*src >> 9) & 0x7c00) | \
((*src >> 6) & 0x3e0) | \
((*src >> 19) & 0x1f); dest++; src++
((*src >> 3) & 0x1f); dest++; src++
#ifdef __BIG_ENDIAN__
#define WRITE2_RGBA_RGB555(src, dest) \
{ \
*((DATA32 *)dest) = ((src[1] << 7) & 0x7c00) | \
*((DATA32 *)dest) = ((src[1] >> 9) & 0x7c00) | \
((src[1] >> 6) & 0x3e0) | \
((src[1] >> 19) & 0x1f) | \
((src[0] << 23) & 0x7c000000) | \
((src[1] >> 3) & 0x1f) | \
((src[0] << 7) & 0x7c000000) | \
((src[0] << 10) & 0x3e00000) | \
((src[0] >> 3) & 0x1f0000); \
((src[0] << 13) & 0x1f0000); \
dest += 2; src += 2; \
}
#else
#define WRITE2_RGBA_RGB555(src, dest) \
{ \
*((DATA32 *)dest) = ((src[0] << 7) & 0x7c00) | \
*((DATA32 *)dest) = ((src[0] >> 9) & 0x7c00) | \
((src[0] >> 6) & 0x3e0) | \
((src[0] >> 19) & 0x1f) | \
((src[1] << 23) & 0x7c000000) | \
((src[0] >> 3) & 0x1f) | \
((src[1] << 7) & 0x7c000000) | \
((src[1] << 10) & 0x3e00000) | \
((src[1] >> 3) & 0x1f0000); \
((src[1] << 13) & 0x1f0000); \
dest += 2; src += 2; \
}
#endif
/*****************************************************************************/
/* MACROS for dithered RGBA -> RGB555 conversion */
#define DITHER_RGBA_555_LUT_R(num) \
(_dither_r16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 0 ) & 0xff)])
(_dither_r16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 16 ) & 0xff)])
#define DITHER_RGBA_555_LUT_G(num) \
(_dither_g16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 8 ) & 0xff)])
#define DITHER_RGBA_555_LUT_B(num) \
(_dither_b16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 16 ) & 0xff)])
(_dither_b16[(((x + num) & 0x3) << 10) | ((y & 0x3) << 8) | ((src[num] >> 0 ) & 0xff)])
#define WRITE1_RGBA_RGB555_DITHER(src, dest) \
*dest = (DITHER_RGBA_555_LUT_R(0)) | \
@ -181,72 +181,72 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB332 conversion */
#define WRITE1_RGBA_RGB332(src, dest) \
*dest = _dither_color_lut[((*src >> 22) & 0x03) | \
*dest = _dither_color_lut[((*src >> 6) & 0x03) | \
((*src >> 11) & 0x1c) | \
((*src) & 0xe0)]; dest++; src++
((*src >> 16) & 0xe0)]; dest++; src++
#ifdef __BIG_ENDIAN__
#define WRITE2_RGBA_RGB332(src, dest) \
{ \
*((DATA16 *)dest) = (_dither_color_lut[((src[1] >> 22) & 0x03) | \
*((DATA16 *)dest) = (_dither_color_lut[((src[1] >> 6) & 0x03) | \
((src[1] >> 11) & 0x1c) | \
((src[1]) & 0xe0)]) | \
(_dither_color_lut[((src[0] >> 22) & 0x03) | \
((src[1] >> 16) & 0xe0)]) | \
(_dither_color_lut[((src[0] >> 6) & 0x03) | \
((src[0] >> 11) & 0x1c) | \
((src[0] & 0xe0)] << 8); \
((src[0] >> 16) & 0xe0)] << 8); \
dest += 2; src += 2; \
}
#define WRITE4_RGBA_RGB332(src, dest) \
{ \
*((DATA32 *)dest) = (_dither_color_lut[((src[3] >> 22) & 0x03) | \
*((DATA32 *)dest) = (_dither_color_lut[((src[3] >> 6) & 0x03) | \
((src[3] >> 11) & 0x1c) | \
((src[3]) & 0xe0)]) | \
(_dither_color_lut[((src[2] >> 22) & 0x03) | \
((src[3] >> 16) & 0xe0)]) | \
(_dither_color_lut[((src[2] >> 6) & 0x03) | \
((src[2] >> 11) & 0x1c) | \
((src[2]) & 0xe0)] << 8) | \
(_dither_color_lut[((src[1] >> 22) & 0x03) | \
((src[2] >> 16) & 0xe0)] << 8) | \
(_dither_color_lut[((src[1] >> 6) & 0x03) | \
((src[1] >> 11) & 0x1c) | \
((src[1]) & 0xe0)] << 16) | \
(_dither_color_lut[((src[0] >> 22) & 0x03) | \
((src[1] >> 16) & 0xe0)] << 16) | \
(_dither_color_lut[((src[0] >> 6) & 0x03) | \
((src[0] >> 11) & 0x1c) | \
((src[0]) & 0xe0)] << 24); \
((src[0] >> 16) & 0xe0)] << 24); \
dest += 4; src += 4; \
}
#else
#define WRITE2_RGBA_RGB332(src, dest) \
{ \
*((DATA16 *)dest) = (_dither_color_lut[((src[0] >> 22) & 0x03) | \
*((DATA16 *)dest) = (_dither_color_lut[((src[0] >> 6) & 0x03) | \
((src[0] >> 11) & 0x1c) | \
((src[0]) & 0xe0)]) | \
(_dither_color_lut[((src[1] >> 22) & 0x03) | \
((src[0] >> 16) & 0xe0)]) | \
(_dither_color_lut[((src[1] >> 6) & 0x03) | \
((src[1] >> 11) & 0x1c) | \
((src[1]) & 0xe0)] << 8); \
((src[1] >> 16) & 0xe0)] << 8); \
dest += 2; src += 2; \
}
#define WRITE4_RGBA_RGB332(src, dest) \
{ \
*((DATA32 *)dest) = (_dither_color_lut[((src[0] >> 22) & 0x03) | \
*((DATA32 *)dest) = (_dither_color_lut[((src[0] >> 6) & 0x03) | \
((src[0] >> 11) & 0x1c) | \
((src[0]) & 0xe0)]) | \
(_dither_color_lut[((src[1] >> 22) & 0x03) | \
((src[0] >> 16) & 0xe0)]) | \
(_dither_color_lut[((src[1] >> 6) & 0x03) | \
((src[1] >> 11) & 0x1c) | \
((src[1]) & 0xe0)] << 8) | \
(_dither_color_lut[((src[2] >> 22) & 0x03) | \
((src[1] >> 16) & 0xe0)] << 8) | \
(_dither_color_lut[((src[2] >> 6) & 0x03) | \
((src[2] >> 11) & 0x1c) | \
((src[2]) & 0xe0)] << 16) | \
(_dither_color_lut[((src[3] >> 22) & 0x03) | \
((src[2] >> 16) & 0xe0)] << 16) | \
(_dither_color_lut[((src[3] >> 6) & 0x03) | \
((src[3] >> 11) & 0x1c) | \
((src[3]) & 0xe0)] << 24); \
((src[3] >> 16) & 0xe0)] << 24); \
dest += 4; src += 4; \
}
#endif
/*****************************************************************************/
/* MACROS for dithered RGBA -> RGB332 conversion */
#define DITHER_RGBA_332_LUT_R(num) \
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0 ) & 0xff)])
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
#define DITHER_RGBA_332_LUT_G(num) \
(_dither_g8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 8) & 0xff)])
#define DITHER_RGBA_332_LUT_B(num) \
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0) & 0xff)])
#define WRITE1_RGBA_RGB332_DITHER(src, dest) \
*dest = _dither_color_lut[(DITHER_RGBA_332_LUT_R(0)) | \
@ -315,9 +315,9 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB232 conversion */
#define RGB232_BSHIFT >> 22
#define RGB232_BSHIFT >> 6
#define RGB232_GSHIFT >> 11
#define RGB232_RSHIFT >> 1
#define RGB232_RSHIFT >> 17
#define RGB232_BMASK & 0x03
#define RGB232_GMASK & 0x1c
#define RGB232_RMASK & 0x60
@ -384,11 +384,11 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for dithered RGBA -> RGB232 conversion */
#define DITHER_RGBA_232_LUT_R(num) \
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0 ) & 0xff)])
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
#define DITHER_RGBA_232_LUT_G(num) \
(_dither_g8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 8) & 0xff)])
#define DITHER_RGBA_232_LUT_B(num) \
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0) & 0xff)])
#define WRITE1_RGBA_RGB232_DITHER(src, dest) \
*dest = _dither_color_lut[(DITHER_RGBA_232_LUT_R(0)) | \
@ -457,9 +457,9 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB222 conversion */
#define RGB222_BSHIFT >> 22
#define RGB222_BSHIFT >> 6
#define RGB222_GSHIFT >> 12
#define RGB222_RSHIFT >> 2
#define RGB222_RSHIFT >> 18
#define RGB222_BMASK & 0x03
#define RGB222_GMASK & 0x0c
#define RGB222_RMASK & 0x30
@ -526,11 +526,11 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for dithered RGBA -> RGB222 conversion */
#define DITHER_RGBA_222_LUT_R(num) \
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0 ) & 0xff)])
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
#define DITHER_RGBA_222_LUT_G(num) \
(_dither_g8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 8) & 0xff)])
#define DITHER_RGBA_222_LUT_B(num) \
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0) & 0xff)])
#define WRITE1_RGBA_RGB222_DITHER(src, dest) \
*dest = _dither_color_lut[(DITHER_RGBA_222_LUT_R(0)) | \
@ -599,9 +599,9 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB221 conversion */
#define RGB221_BSHIFT >> 23
#define RGB221_BSHIFT >> 7
#define RGB221_GSHIFT >> 13
#define RGB221_RSHIFT >> 3
#define RGB221_RSHIFT >> 19
#define RGB221_BMASK & 0x01
#define RGB221_GMASK & 0x06
#define RGB221_RMASK & 0x18
@ -668,11 +668,11 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for dithered RGBA -> RGB221 conversion */
#define DITHER_RGBA_221_LUT_R(num) \
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0 ) & 0xff)])
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
#define DITHER_RGBA_221_LUT_G(num) \
(_dither_g8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 8) & 0xff)])
#define DITHER_RGBA_221_LUT_B(num) \
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0) & 0xff)])
#define WRITE1_RGBA_RGB221_DITHER(src, dest) \
*dest = _dither_color_lut[(DITHER_RGBA_221_LUT_R(0)) | \
@ -741,9 +741,9 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB121 conversion */
#define RGB121_BSHIFT >> 23
#define RGB121_BSHIFT >> 7
#define RGB121_GSHIFT >> 13
#define RGB121_RSHIFT >> 4
#define RGB121_RSHIFT >> 20
#define RGB121_BMASK & 0x01
#define RGB121_GMASK & 0x06
#define RGB121_RMASK & 0x08
@ -810,11 +810,11 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for dithered RGBA -> RGB121 conversion */
#define DITHER_RGBA_121_LUT_R(num) \
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0 ) & 0xff)])
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
#define DITHER_RGBA_121_LUT_G(num) \
(_dither_g8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 8) & 0xff)])
#define DITHER_RGBA_121_LUT_B(num) \
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0) & 0xff)])
#define WRITE1_RGBA_RGB121_DITHER(src, dest) \
*dest = _dither_color_lut[(DITHER_RGBA_121_LUT_R(0)) | \
@ -883,9 +883,9 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB111 conversion */
#define RGB111_BSHIFT >> 23
#define RGB111_BSHIFT >> 7
#define RGB111_GSHIFT >> 14
#define RGB111_RSHIFT >> 5
#define RGB111_RSHIFT >> 21
#define RGB111_BMASK & 0x01
#define RGB111_GMASK & 0x02
#define RGB111_RMASK & 0x30
@ -952,11 +952,11 @@ static DATA8 *_dither_b8;
/*****************************************************************************/
/* MACROS for dithered RGBA -> RGB111 conversion */
#define DITHER_RGBA_111_LUT_R(num) \
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0 ) & 0xff)])
(_dither_r8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
#define DITHER_RGBA_111_LUT_G(num) \
(_dither_g8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 8) & 0xff)])
#define DITHER_RGBA_111_LUT_B(num) \
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 16) & 0xff)])
(_dither_b8[(((x + num) & 0x7) << 11) | ((y & 0x7) << 8) | ((src[num] >> 0) & 0xff)])
#define WRITE1_RGBA_RGB111_DITHER(src, dest) \
*dest = _dither_color_lut[(DITHER_RGBA_111_LUT_R(0)) | \
@ -1073,9 +1073,7 @@ src++;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB8888 conversion */
#define WRITE1_RGBA_RGB8888(src, dest) \
*dest = ((*src >> 16) & 0x0000ff) | \
((*src << 0) & 0x00ff00) | \
((*src << 16) & 0xff0000); dest++; src++;
*dest = *src; dest++; src++;
/*****************************************************************************/
/* Actual rendering routines */
@ -1085,9 +1083,9 @@ src++;
/*****************************************************************************/
/* MACROS for plain RGBA -> RGB888 conversion */
#define WRITE1_RGBA_RGB888(src, dest) \
*dest = ((*src >> 16) & 0xff); dest++; \
*dest = ((*src >> 0) & 0xff); dest++; \
*dest = ((*src >> 8) & 0xff); dest++; \
*dest = ((*src >> 0) & 0xff); dest++; src++;
*dest = ((*src >> 16) & 0xff); dest++; src++;
void
__imlib_RGBASetupContext(Context *ct)