adding the start of an actual aip layer... if you have any comments about

this api - speak up now - because once it's final - that's it - thats the
final api for imlib - anythig api.c calls etdc. can be changed - unless
its the loader/saver api. that can't be changed either once its all final.
:)


SVN revision: 30
This commit is contained in:
Carsten Haitzler 1999-08-04 23:36:07 +00:00
parent c8356b7790
commit 2553ba9c0d
26 changed files with 881 additions and 563 deletions

View File

@ -1,7 +1,7 @@
INSTALL = install
SRCS = rend.c ximage.c scale.c main.c rgba.c image.c color.c grab.c \
blend.c file.c
blend.c file.c draw.c rgbadraw.c api.c
OBJS = $(SRCS:.c=.o)
BINDIR = /usr/local/bin
BIN = imlib2

181
api.c Normal file
View File

@ -0,0 +1,181 @@
#include <X11/Xlib.h>
#include "common.h"
#include "scale.h"
#include "image.h"
#include "rend.h"
#include "rgba.h"
#include "color.h"
#include "file.h"
#include "grab.h"
#include "blend.h"
#include "draw.h"
#include "api.h"
#define CAST_IMAGE(im, image) (im) = (ImlibImage *)(image);
typedef void (*Imlib_Internal_Progress_Function)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h);
char
imlib_init(void)
{
__imlib_RGBA_init();
}
int
imlib_get_cache_size(void)
{
return __imlib_GetCacheSize();
}
void
imlib_set_cache_size(int bytes)
{
__imlib_SetCacheSize(bytes);
}
void
imlib_set_color_usage(int max)
{
if (max < 2)
max = 2;
else if (max > 256)
max = 256;
_max_colors = max;
}
Imlib_Image
imlib_load_image(char *file)
{
return (Imlib_Image)
__imlib_LoadImage(file, NULL, 0, 0, 0);
}
Imlib_Image
imlib_load_image_with_progress_callback(char *file,
Imlib_Progress_Function progress_function,
char progress_granulatiy)
{
return (Imlib_Image)
__imlib_LoadImage(file, (Imlib_Internal_Progress_Function)progress_function, progress_granulatiy, 0, 0);
}
Imlib_Image
imlib_load_image_immediately(char *file)
{
return (Imlib_Image)
__imlib_LoadImage(file, NULL, 0, 1, 0);
}
Imlib_Image imlib_load_image_without_cache(char *file)
{
return (Imlib_Image)
__imlib_LoadImage(file, NULL, 0, 0, 1);
}
Imlib_Image imlib_load_image_with_progress_callback_without_cache (char *file,
Imlib_Progress_Function progress_function,
char progress_granulatiy)
{
return (Imlib_Image)
__imlib_LoadImage(file, (Imlib_Internal_Progress_Function)progress_function, progress_granulatiy, 0, 1);
}
Imlib_Image imlib_load_image_immediately_without_cache(char *file)
{
return (Imlib_Image)
__imlib_LoadImage(file, NULL, 0, 1, 1);
}
int imlib_get_image_width(Imlib_Image image)
{
ImlibImage *im;
CAST_IMAGE(im, image);
return im->w;
}
int imlib_get_image_height(Imlib_Image image)
{
ImlibImage *im;
CAST_IMAGE(im, image);
return im->h;
}
DATA32 *imlib_get_image_data(Imlib_Image image)
{
ImlibImage *im;
CAST_IMAGE(im, image);
if (!(im->data))
im->loader->load(im, NULL, 0, 1);
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
return im->data;
}
void imlib_put_back_image_data(Imlib_Image image)
{
ImlibImage *im;
CAST_IMAGE(im, image);
__imlib_DirtyImage(im);
__imlib_DirtyPixmapsForImage(im);
}
char imlib_image_has_alpha(Imlib_Image image)
{
ImlibImage *im;
CAST_IMAGE(im, image);
if (IMAGE_HAS_ALPHA(im))
return 1;
return 0;
}
void imlib_set_image_never_changes_on_disk(Imlib_Image image)
{
ImlibImage *im;
CAST_IMAGE(im, image);
UNSET_FLAG(im->flags, F_ALWAYS_CHECK_DISK);
}
void imlib_image_get_border(Imlib_Image image, Imlib_Border *border)
{
ImlibImage *im;
CAST_IMAGE(im, image);
border->left = im->border.left;
border->right = im->border.right;
border->top = im->border.top;
border->bottom = im->border.bottom;
}
void imlib_image_set_border(Imlib_Image image, Imlib_Border *border)
{
ImlibImage *im;
CAST_IMAGE(im, image);
if ((im->border.left == border->left) &&
(im->border.right == border->right) &&
(im->border.top == border->top) &&
(im->border.bottom == border->bottom))
return;
im->border.left = border->left;
im->border.right = border->right;
im->border.top = border->top;
im->border.bottom = border->bottom;
__imlib_DirtyPixmapsForImage(im);
}
char *imlib_image_format(Imlib_Image image)
{
ImlibImage *im;
CAST_IMAGE(im, image);
return im->format;
}

54
api.h Normal file
View File

@ -0,0 +1,54 @@
#ifndef __IMLIB_API_H
#define __IMLIB_API_H 1
#ifndef DATA64
#define DATA64 unsigned long long
#define DATA32 unsigned int
#define DATA16 unsigned short
#define DATA8 unsigned char
#endif
/* data types - guess what - no transparent datatypes - all hidden */
typedef void * Imlib_Image;
typedef struct _imlib_border Imlib_Border;
struct _imlib_border
{
int left, right, top, bottom;
};
typedef void (*Imlib_Progress_Function)(Imlib_Image *im, char percent,
int update_x, int update_y,
int update_w, int update_h);
/* init and setup functions */
char imlib_init(void);
int imlib_get_cache_size(void);
void imlib_set_cache_size(int bytes);
void imlib_set_color_usage(int max);
/* image loading functions */
Imlib_Image imlib_load_image(char *file);
Imlib_Image imlib_load_image_with_progress_callback(char *file,
Imlib_Progress_Function progress_function,
char progress_granulatiy);
Imlib_Image imlib_load_image_immediately(char *file);
Imlib_Image imlib_load_image_without_cache(char *file);
Imlib_Image imlib_load_image_with_progress_callback_without_cache (char *file,
Imlib_Progress_Function progress_function,
char progress_granulatiy);
Imlib_Image imlib_load_image_immediately_without_cache(char *file);
/* image information retrieval and basic manipulation functions */
int imlib_get_image_width(Imlib_Image image);
int imlib_get_image_height(Imlib_Image image);
DATA32 *imlib_get_image_data(Imlib_Image image);
void imlib_put_back_image_data(Imlib_Image image);
char imlib_image_has_alpha(Imlib_Image image);
void imlib_set_image_never_changes_on_disk(Imlib_Image image);
void imlib_image_get_border(Imlib_Image image, Imlib_Border *border);
void imlib_image_set_border(Imlib_Image image, Imlib_Border *border);
char *imlib_image_format(Imlib_Image image);
/* image drawing/rendering functions */
#endif

22
blend.c
View File

@ -2,8 +2,8 @@
#include "blend.h"
void
BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
int w, int h)
__imlib_BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
int w, int h)
{
int x, y;
DATA32 *p1, *p2;
@ -20,30 +20,12 @@ BlendRGBAToRGBA(DATA32 *src, int src_jump, DATA32 *dst, int dst_jump,
a = (*p1 >> 24) & 0xff;
if (a < 255)
{
#if 1
r = 255 - a;
*p2 =
((((*p1 & 0x00ff00ff) * a) >> 8) & 0x00ff00ff) +
((((*p1 >> 8) & 0x00ff00ff) * a) & 0xff00ff00) +
((((*p2 & 0x00ff00ff) * r) >> 8) & 0x00ff00ff) +
((((*p2 >> 8) & 0x00ff00ff) * r) & 0xff00ff00);
#else
r = (*p1 ) & 0xff;
g = (*p1 >> 8 ) & 0xff;
b = (*p1 >> 16) & 0xff;
rr = (*p2 ) & 0xff;
gg = (*p2 >> 8 ) & 0xff;
bb = (*p2 >> 16) & 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);
*p2 = ((nb & 0xff) << 16) | ((ng & 0xff) << 8) | (nr & 0xff);
#endif
}
else
*p2 = *p1;

View File

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

485
color.c
View File

@ -3,296 +3,295 @@
#include "common.h"
#include "color.h"
/* FIXME: DATA32 must become DATA8 */
DATA8 _dither_color_lut[256];
DATA8 _pal_type = 0;
DATA8 _dither_color_lut[256];
DATA8 _pal_type = 0;
DATA16 _max_colors = 256;
void
AllocColorTable(Display *d, Colormap cmap)
__imlib_AllocColorTable(Display *d, Colormap cmap)
{
if (AllocColors332(d, cmap))
return;
if (AllocColors232(d, cmap))
return;
if (AllocColors222(d, cmap))
return;
if (AllocColors221(d, cmap))
return;
if (AllocColors121(d, cmap))
return;
if (AllocColors111(d, cmap))
return;
if (AllocColors1(d, cmap))
return;
if ((_max_colors >= 256) && (__imlib_AllocColors332(d, cmap)))
return;
if ((_max_colors >= 128) &&(__imlib_AllocColors232(d, cmap)))
return;
if ((_max_colors >= 64) &&(__imlib_AllocColors222(d, cmap)))
return;
if ((_max_colors >= 32) &&(__imlib_AllocColors221(d, cmap)))
return;
if ((_max_colors >= 16) &&(__imlib_AllocColors121(d, cmap)))
return;
if ((_max_colors >= 8) &&(__imlib_AllocColors111(d, cmap)))
return;
__imlib_AllocColors1(d, cmap);
}
char
AllocColors332(Display *d, Colormap cmap)
__imlib_AllocColors332(Display *d, Colormap cmap)
{
int r, g, b, i = 0;
for (r = 0; r < 8; r++)
{
for (g = 0; g < 8; g++)
{
for (b = 0; b < 4; b++)
{
XColor xcl;
int val;
val = (r << 5) | (r << 2) | (r >> 1);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 5) | (g << 2) | (g >> 1);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
unsigned long pixels[256];
int j;
int r, g, b, i = 0;
for (r = 0; r < 8; r++)
{
for (g = 0; g < 8; g++)
{
for (b = 0; b < 4; b++)
{
XColor xcl;
int val;
if (i > 0)
val = (r << 5) | (r << 2) | (r >> 1);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 5) | (g << 2) | (g >> 1);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
unsigned long pixels[256];
int j;
if (i > 0)
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
}
return 0;
}
return 0;
}
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 0;
return 1;
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 0;
return 1;
}
char
AllocColors232(Display *d, Colormap cmap)
__imlib_AllocColors232(Display *d, Colormap cmap)
{
int r, g, b, i = 0;
for (r = 0; r < 4; r++)
{
for (g = 0; g < 8; g++)
{
for (b = 0; b < 4; b++)
{
XColor xcl;
int val;
val = (r << 6) | (r << 4) | (r << 2) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 5) | (g << 2) | (g >> 1);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
unsigned long pixels[256];
int j;
int r, g, b, i = 0;
for (r = 0; r < 4; r++)
{
for (g = 0; g < 8; g++)
{
for (b = 0; b < 4; b++)
{
XColor xcl;
int val;
if (i > 0)
val = (r << 6) | (r << 4) | (r << 2) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 5) | (g << 2) | (g >> 1);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
unsigned long pixels[256];
int j;
if (i > 0)
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
}
return 0;
}
return 0;
}
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 1;
return 1;
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 1;
return 1;
}
char
AllocColors222(Display *d, Colormap cmap)
__imlib_AllocColors222(Display *d, Colormap cmap)
{
int r, g, b, i = 0;
for (r = 0; r < 4; r++)
{
for (g = 0; g < 4; g++)
{
for (b = 0; b < 4; b++)
{
XColor xcl;
int val;
val = (r << 6) | (r << 4) | (r << 2) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 6) | (g << 4) | (g << 2) | (g);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
unsigned long pixels[256];
int j;
int r, g, b, i = 0;
for (r = 0; r < 4; r++)
{
for (g = 0; g < 4; g++)
{
for (b = 0; b < 4; b++)
{
XColor xcl;
int val;
if (i > 0)
val = (r << 6) | (r << 4) | (r << 2) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 6) | (g << 4) | (g << 2) | (g);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
unsigned long pixels[256];
int j;
if (i > 0)
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
}
return 0;
}
return 0;
}
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 2;
return 1;
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 2;
return 1;
}
char
AllocColors221(Display *d, Colormap cmap)
__imlib_AllocColors221(Display *d, Colormap cmap)
{
int r, g, b, i = 0;
for (r = 0; r < 4; r++)
{
for (g = 0; g < 4; g++)
{
for (b = 0; b < 2; b++)
{
XColor xcl;
int val;
val = (r << 6) | (r << 4) | (r << 2) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 6) | (g << 4) | (g << 2) | (g);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
unsigned long pixels[256];
int j;
int r, g, b, i = 0;
for (r = 0; r < 4; r++)
{
for (g = 0; g < 4; g++)
{
for (b = 0; b < 2; b++)
{
XColor xcl;
int val;
if (i > 0)
val = (r << 6) | (r << 4) | (r << 2) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 6) | (g << 4) | (g << 2) | (g);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
unsigned long pixels[256];
int j;
if (i > 0)
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
}
return 0;
}
return 0;
}
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 3;
return 1;
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 3;
return 1;
}
char
AllocColors121(Display *d, Colormap cmap)
__imlib_AllocColors121(Display *d, Colormap cmap)
{
int r, g, b, i = 0;
for (r = 0; r < 2; r++)
{
for (g = 0; g < 4; g++)
{
for (b = 0; b < 2; b++)
{
XColor xcl;
int val;
val = (r << 7) | (r << 6) | (r << 5) | (r << 4) | (r << 3) | (r << 2) | (r << 1) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 6) | (g << 4) | (g << 2) | (g);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
unsigned long pixels[256];
int j;
int r, g, b, i = 0;
for (r = 0; r < 2; r++)
{
for (g = 0; g < 4; g++)
{
for (b = 0; b < 2; b++)
{
XColor xcl;
int val;
if (i > 0)
val = (r << 7) | (r << 6) | (r << 5) | (r << 4) | (r << 3) | (r << 2) | (r << 1) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 6) | (g << 4) | (g << 2) | (g);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
unsigned long pixels[256];
int j;
if (i > 0)
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
}
return 0;
}
return 0;
}
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 4;
return 1;
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 4;
return 1;
}
char
AllocColors111(Display *d, Colormap cmap)
__imlib_AllocColors111(Display *d, Colormap cmap)
{
int r, g, b, i = 0;
for (r = 0; r < 2; r++)
{
for (g = 0; g < 2; g++)
{
for (b = 0; b < 2; b++)
{
XColor xcl;
int val;
val = (r << 7) | (r << 6) | (r << 5) | (r << 4) | (r << 3) | (r << 2) | (r << 1) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 7) | (g << 6) | (g << 5) | (g << 4) | (g << 3) | (g << 2) | (g << 1) | (g);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
unsigned long pixels[256];
int j;
int r, g, b, i = 0;
for (r = 0; r < 2; r++)
{
for (g = 0; g < 2; g++)
{
for (b = 0; b < 2; b++)
{
XColor xcl;
int val;
if (i > 0)
val = (r << 7) | (r << 6) | (r << 5) | (r << 4) | (r << 3) | (r << 2) | (r << 1) | (r);
xcl.red = (unsigned short)((val << 8) | (val));
val = (g << 7) | (g << 6) | (g << 5) | (g << 4) | (g << 3) | (g << 2) | (g << 1) | (g);
xcl.green = (unsigned short)((val << 8) | (val));
val = (b << 7) | (b << 6) | (b << 5) | (b << 4) | (b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
if (!XAllocColor(d, cmap, &xcl))
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
unsigned long pixels[256];
int j;
if (i > 0)
{
for(j = 0; j < i; j++)
pixels[j] = (unsigned long) _dither_color_lut[j];
XFreeColors(d, cmap, pixels, i, 0);
}
return 0;
}
return 0;
}
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 5;
return 1;
_dither_color_lut[i] = xcl.pixel;
i++;
}
}
}
_pal_type = 5;
return 1;
}
char
AllocColors1(Display *d, Colormap cmap)
__imlib_AllocColors1(Display *d, Colormap cmap)
{
XColor xcl;
xcl.red = (unsigned short)(0x0000);
xcl.green = (unsigned short)(0x0000);
xcl.blue = (unsigned short)(0x0000);
XAllocColor(d, cmap, &xcl);
_dither_color_lut[0] = xcl.pixel;
xcl.red = (unsigned short)(0xffff);
xcl.green = (unsigned short)(0xffff);
xcl.blue = (unsigned short)(0xffff);
XAllocColor(d, cmap, &xcl);
_dither_color_lut[1] = xcl.pixel;
_pal_type = 6;
return 1;
XColor xcl;
xcl.red = (unsigned short)(0x0000);
xcl.green = (unsigned short)(0x0000);
xcl.blue = (unsigned short)(0x0000);
XAllocColor(d, cmap, &xcl);
_dither_color_lut[0] = xcl.pixel;
xcl.red = (unsigned short)(0xffff);
xcl.green = (unsigned short)(0xffff);
xcl.blue = (unsigned short)(0xffff);
XAllocColor(d, cmap, &xcl);
_dither_color_lut[1] = xcl.pixel;
_pal_type = 6;
return 1;
}

19
color.h
View File

@ -1,23 +1,24 @@
#ifndef __COLOR
#define __COLOR 1
/* FIXME: DATA32 must become DATA8 */
extern DATA8 _dither_color_lut[256];
extern DATA8 _dither_color_lut[256];
extern DATA8 _pal_type;
extern DATA16 _max_colors;
void
AllocColorTable(Display *d, Colormap cmap);
__imlib_AllocColorTable(Display *d, Colormap cmap);
char
AllocColors332(Display *d, Colormap cmap);
__imlib_AllocColors332(Display *d, Colormap cmap);
char
AllocColors232(Display *d, Colormap cmap);
__imlib_AllocColors232(Display *d, Colormap cmap);
char
AllocColors222(Display *d, Colormap cmap);
__imlib_AllocColors222(Display *d, Colormap cmap);
char
AllocColors221(Display *d, Colormap cmap);
__imlib_AllocColors221(Display *d, Colormap cmap);
char
AllocColors121(Display *d, Colormap cmap);
__imlib_AllocColors121(Display *d, Colormap cmap);
char
AllocColors111(Display *d, Colormap cmap);
__imlib_AllocColors111(Display *d, Colormap cmap);
char
AllocColors1(Display *d, Colormap cmap);
__imlib_AllocColors1(Display *d, Colormap cmap);
#endif

44
draw.c Normal file
View File

@ -0,0 +1,44 @@
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include "common.h"
#include "image.h"
#include "rend.h"
#include "draw.h"
char
__imlib_CreatePixmapsForImage(Display *d, Drawable w, Visual *v, int depth,
Colormap cm, ImlibImage *im, Pixmap *p, Mask *m,
int sx, int sy, int sw, int sh,
int dw, int dh,
char anitalias, char hiq, char dither_mask)
{
ImlibImagePixmap *ip = NULL;
Pixmap pmap = 0;
Pixmap mask = 0;
ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy, sw, sh, cm,
anitalias, hiq, dither_mask);
if (ip)
{
if (p)
*p = ip->pixmap;
if (m)
*m = ip->mask;
return 2;
}
if (p)
{
pmap = XCreatePixmap(d, w, dw, dh, depth);
*p = pmap;
}
if (m)
{
if (IMAGE_HAS_ALPHA(im))
mask = XCreatePixmap(d, w, dw, dh, 1);
*m = mask;
}
__imlib_RenderImage(d, im, pmap, mask, v, cm, depth, sx, sy, sw, sh, 0, 0,
dw, dh, anitalias, hiq, 0, dither_mask);
return 1;
}

9
draw.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef __DRAW
#define __DRAW 1
char
__imlib_CreatePixmapsForImage(Display *d, Drawable w, Visual *v, int depth,
Colormap cm, ImlibImage *im, Pixmap *p, Mask *m,
int sx, int sy, int sw, int sh,
int dw, int dh,
char anitalias, char hiq, char dither_mask);
#endif

26
file.c
View File

@ -8,10 +8,10 @@
#include <pwd.h>
#include "file.h"
static void FileFieldWord(char *s, int num, char *wd);
static void __imlib_FileFieldWord(char *s, int num, char *wd);
char *
FileExtension(char *file)
__imlib_FileExtension(char *file)
{
char *p;
@ -22,7 +22,7 @@ FileExtension(char *file)
}
int
FileExists(char *s)
__imlib_FileExists(char *s)
{
struct stat st;
@ -34,7 +34,7 @@ FileExists(char *s)
}
int
FileIsFile(char *s)
__imlib_FileIsFile(char *s)
{
struct stat st;
@ -48,7 +48,7 @@ FileIsFile(char *s)
}
int
FileIsDir(char *s)
__imlib_FileIsDir(char *s)
{
struct stat st;
@ -62,7 +62,7 @@ FileIsDir(char *s)
}
char **
FileDir(char *dir, int *num)
__imlib_FileDir(char *dir, int *num)
{
int i, dirlen;
int done = 0;
@ -129,7 +129,7 @@ FileDir(char *dir, int *num)
}
void
FileFreeDirList(char **l, int num)
__imlib_FileFreeDirList(char **l, int num)
{
if (!l)
return;
@ -141,7 +141,7 @@ FileFreeDirList(char **l, int num)
}
void
FileDel(char *s)
__imlib_FileDel(char *s)
{
if ((!s) || (!*s))
return;
@ -150,7 +150,7 @@ FileDel(char *s)
}
time_t
FileModDate(char *s)
__imlib_FileModDate(char *s)
{
struct stat st;
@ -168,7 +168,7 @@ FileModDate(char *s)
}
char *
FileHomeDir(int uid)
__imlib_FileHomeDir(int uid)
{
static int usr_uid = -1;
static char *usr_s = NULL;
@ -206,12 +206,12 @@ FileHomeDir(int uid)
/* word 5 = Foo */
char *
FileField(char *s, int field)
__imlib_FileField(char *s, int field)
{
char buf[4096];
buf[0] = 0;
FileFieldWord(s, field + 1, buf);
__imlib_FileFieldWord(s, field + 1, buf);
if (buf[0])
{
if ((!strcmp(buf, "NULL")) ||
@ -232,7 +232,7 @@ FileField(char *s, int field)
static void
FileFieldWord(char *s, int num, char *wd)
__imlib_FileFieldWord(char *s, int num, char *wd)
{
char *cur, *start, *end;
int count, inword, inquote, len;

20
file.h
View File

@ -1,13 +1,13 @@
#ifndef __FILE
#define __FILE 1
char *FileExtension(char *file);
int FileExists(char *s);
int FileIsFile(char *s);
int FileIsDir(char *s);
char **FileDir(char *dir, int *num);
void FileFreeDirList(char **l, int num);
void FileDel(char *s);
time_t FileModDate(char *s);
char *FileHomeDir(int uid);
char *FileField(char *s, int field);
char *__imlib_FileExtension(char *file);
int __imlib_FileExists(char *s);
int __imlib_FileIsFile(char *s);
int __imlib_FileIsDir(char *s);
char **__imlib_FileDir(char *dir, int *num);
void __imlib_FileFreeDirList(char **l, int num);
void __imlib_FileDel(char *s);
time_t __imlib_FileModDate(char *s);
char *__imlib_FileHomeDir(int uid);
char *__imlib_FileField(char *s, int field);
#endif

4
grab.c
View File

@ -18,8 +18,8 @@ Tmp_HandleXError(Display * d, XErrorEvent * ev)
}
DATA32 *
GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap cm,
int depth, int x, int y, int w, int h, char domask)
__imlib_GrabDrawableToRGBA(Display *d, Drawable p, Pixmap m, Visual *v, Colormap cm,
int depth, int x, int y, int w, int h, char domask)
{
XErrorHandler prev_erh = NULL;
XWindowAttributes xatt, ratt;

4
grab.h
View File

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

216
image.c
View File

@ -3,8 +3,6 @@
#include <string.h>
#include <dlfcn.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <X11/Xutil.h>
#include "image.h"
#include "file.h"
@ -14,43 +12,36 @@ static ImlibLoader *loaders = NULL;
static int cache_size = 4096 * 1024;
void
SetCacheSize(int size)
__imlib_SetCacheSize(int size)
{
cache_size = size;
CleanupImageCache();
CleanupImagePixmapCache();
__imlib_CleanupImageCache();
__imlib_CleanupImagePixmapCache();
}
int
GetCacheSize(void)
__imlib_GetCacheSize(void)
{
return cache_size;
}
ImlibImage *
ProduceImage(void)
__imlib_ProduceImage(void)
{
ImlibImage *im;
im = malloc(sizeof(ImlibImage));
memset(im, 0, sizeof(ImlibImage));
im->data = NULL;
im->file = NULL;
im->moddate = 0;
im->flags = F_NONE;
im->border.left = 0;
im->border.right = 0;
im->border.top = 0;
im->border.bottom = 0;
im->references = 0;
im->w = 0;
im->h = 0;
im->loader = NULL;
im->next = NULL;
return im;
}
void
ConsumeImage(ImlibImage *im)
__imlib_ConsumeImage(ImlibImage *im)
{
if (im->file)
free(im->file);
@ -62,7 +53,7 @@ ConsumeImage(ImlibImage *im)
}
ImlibImage *
FindCachedImage(char *file)
__imlib_FindCachedImage(char *file)
{
ImlibImage *im, *previous_im;
@ -71,8 +62,8 @@ FindCachedImage(char *file)
/* go through the images list */
while (im)
{
/* if the filenames match */
if (!strcmp(file, im->file))
/* if the filenames match and it's valid */
if ((!strcmp(file, im->file)) && (IMAGE_IS_VALID(im)))
{
/* move the image to the head of the pixmap list */
if (previous_im)
@ -91,14 +82,14 @@ FindCachedImage(char *file)
}
void
AddImageToCache(ImlibImage *im)
__imlib_AddImageToCache(ImlibImage *im)
{
im->next = images;
images = im;
}
void
RemoveImageFromCache(ImlibImage *im)
__imlib_RemoveImageFromCache(ImlibImage *im)
{
ImlibImage *current_im, *previous_im;
@ -119,7 +110,7 @@ RemoveImageFromCache(ImlibImage *im)
}
int
CurrentCacheSize(void)
__imlib_CurrentCacheSize(void)
{
ImlibImage *im;
ImlibImagePixmap *ip;
@ -132,8 +123,8 @@ CurrentCacheSize(void)
{
if (!(IMAGE_IS_VALID(im)))
{
RemoveImageFromCache(im);
ConsumeImage(im);
__imlib_RemoveImageFromCache(im);
__imlib_ConsumeImage(im);
}
else
current_cache += im->w * im->h * sizeof(DATA32);
@ -147,8 +138,8 @@ CurrentCacheSize(void)
{
if (!(IMAGE_IS_VALID(ip->image)))
{
RemoveImagePixmapFromCache(ip);
ConsumeImagePixmap(ip);
__imlib_RemoveImagePixmapFromCache(ip);
__imlib_ConsumeImagePixmap(ip);
}
else
{
@ -172,13 +163,13 @@ CurrentCacheSize(void)
}
void
CleanupImageCache(void)
__imlib_CleanupImageCache(void)
{
ImlibImage *im, *im_last;
int current_cache;
char operation = 1;
current_cache = CurrentCacheSize();
current_cache = __imlib_CurrentCacheSize();
while ((current_cache > cache_size) || (operation));
{
im_last = NULL;
@ -192,36 +183,30 @@ CleanupImageCache(void)
}
if (im_last)
{
RemoveImageFromCache(im_last);
ConsumeImage(im_last);
__imlib_RemoveImageFromCache(im_last);
__imlib_ConsumeImage(im_last);
operation = 1;
}
current_cache = CurrentCacheSize();
current_cache = __imlib_CurrentCacheSize();
}
}
ImlibImagePixmap *
ProduceImagePixmap(void)
__imlib_ProduceImagePixmap(void)
{
ImlibImagePixmap *ip;
ip = malloc(sizeof(ImlibImagePixmap));
ip->w = 0;
ip->h = 0;
ip->pixmap = 0;
ip->mask = 0;
memset(ip, 0, sizeof(ImlibImagePixmap));
ip->display = NULL;
ip->visual = NULL;
ip->depth = 0;
ip->mode_count = 0;
ip->image = NULL;
ip->references = 0;
ip->next = NULL;
return ip;
}
void
ConsumeImagePixmap(ImlibImagePixmap *ip)
__imlib_ConsumeImagePixmap(ImlibImagePixmap *ip)
{
if (ip->pixmap)
XFreePixmap(ip->display, ip->pixmap);
@ -231,8 +216,9 @@ ConsumeImagePixmap(ImlibImagePixmap *ip)
}
ImlibImagePixmap *
FindCachedImagePixmap(ImlibImage *im, int w, int h, Display *d, Visual *v,
int depth, int mode_count)
__imlib_FindCachedImagePixmap(ImlibImage *im, int w, int h, Display *d, Visual *v,
int depth, int sx, int sy, int sw, int sh, Colormap cm,
char aa, char hiq, char dmask)
{
ImlibImagePixmap *ip, *previous_ip;
@ -243,8 +229,17 @@ FindCachedImagePixmap(ImlibImage *im, int w, int h, Display *d, Visual *v,
{
/* if all the pixmap attributes match */
if ((ip->w == w) && (ip->h == h) && (ip->depth == depth) &&
(!ip->dirty) &&
(ip->visual == v) && (ip->display == d) &&
(ip->mode_count == mode_count))
(ip->source_x == sx) && (ip->source_x == sy) &&
(ip->source_w == sw) && (ip->source_h == sh) &&
(ip->colormap == cm) && (ip->antialias == aa) &&
(ip->dither_mask == dmask) &&
(ip->border.left == im->border.left) &&
(ip->border.right == im->border.right) &&
(ip->border.top == im->border.top) &&
(ip->border.bottom == im->border.bottom)
)
{
/* move the pixmap to the head of the pixmap list */
if (previous_ip)
@ -263,14 +258,14 @@ FindCachedImagePixmap(ImlibImage *im, int w, int h, Display *d, Visual *v,
}
void
AddImagePixmapToCache(ImlibImagePixmap *ip)
__imlib_AddImagePixmapToCache(ImlibImagePixmap *ip)
{
ip->next = pixmaps;
pixmaps = ip;
}
void
RemoveImagePixmapFromCache(ImlibImagePixmap *ip)
__imlib_RemoveImagePixmapFromCache(ImlibImagePixmap *ip)
{
ImlibImagePixmap *current_ip, *previous_ip;
@ -291,13 +286,13 @@ RemoveImagePixmapFromCache(ImlibImagePixmap *ip)
}
void
CleanupImagePixmapCache()
__imlib_CleanupImagePixmapCache()
{
ImlibImagePixmap *ip, *ip_last;
int current_cache;
char operation = 1;
current_cache = CurrentCacheSize();
current_cache = __imlib_CurrentCacheSize();
while ((current_cache > cache_size) || (operation));
{
ip_last = NULL;
@ -311,16 +306,16 @@ CleanupImagePixmapCache()
}
if (ip_last)
{
RemoveImagePixmapFromCache(ip_last);
ConsumeImagePixmap(ip_last);
__imlib_RemoveImagePixmapFromCache(ip_last);
__imlib_ConsumeImagePixmap(ip_last);
operation = 1;
}
current_cache = CurrentCacheSize();
current_cache = __imlib_CurrentCacheSize();
}
}
ImlibLoader *
ProduceLoader(char *file)
__imlib_ProduceLoader(char *file)
{
ImlibLoader *l;
void (*l_formats)(ImlibLoader *l) ;
@ -350,15 +345,15 @@ ProduceLoader(char *file)
}
char **
ListLoaders(int *num_ret)
__imlib_ListLoaders(int *num_ret)
{
char **list = NULL, **l, s[4096], *home;
int num, i, pi = 0;
*num_ret = 0;
home = FileHomeDir(getuid());
home = __imlib_FileHomeDir(getuid());
sprintf(s, "%s/.loaders/image/", home);
l = FileDir(s, &num);
l = __imlib_FileDir(s, &num);
if (num > 0)
{
*num_ret += num;
@ -369,10 +364,10 @@ ListLoaders(int *num_ret)
list[i] = strdup(s);
}
pi = i;
FileFreeDirList(l, num);
__imlib_FileFreeDirList(l, num);
}
sprintf(s, "/usr/lib/loaders/image/");
l = FileDir(s, &num);
l = __imlib_FileDir(s, &num);
if (num > 0)
{
*num_ret += num;
@ -382,14 +377,14 @@ ListLoaders(int *num_ret)
sprintf(s, "/usr/lib/loaders/image/%s", l[i]);
list[pi + i] = strdup(s);
}
FileFreeDirList(l, num);
__imlib_FileFreeDirList(l, num);
free(home);
}
return list;
}
void
ConsumeLoader(ImlibLoader *l)
__imlib_ConsumeLoader(ImlibLoader *l)
{
if (l->file)
free(l->file);
@ -407,7 +402,7 @@ ConsumeLoader(ImlibLoader *l)
}
void
RescanLoaders(void)
__imlib_RescanLoaders(void)
{
static time_t last_scan_time = 0;
static time_t last_modified_home_time = 0;
@ -422,9 +417,9 @@ RescanLoaders(void)
return;
/* ok - was the system loaders dir contents modified ? */
last_scan_time = current_time;
if (FileIsDir("/usr/lib/loaders/image/"))
if (__imlib_FileIsDir("/usr/lib/loaders/image/"))
{
current_time = FileModDate("/usr/lib/loaders/image/");
current_time = __imlib_FileModDate("/usr/lib/loaders/image/");
if (current_time > last_modified_system_time)
{
/* yup - set the "do_reload" flag */
@ -433,12 +428,12 @@ RescanLoaders(void)
}
}
/* ok - was the users own loaders dir contents modified ? */
home = FileHomeDir(getuid());
home = __imlib_FileHomeDir(getuid());
sprintf(s, "%s/.loaders/image/", home);
free(home);
if (FileIsDir(s))
if (__imlib_FileIsDir(s))
{
current_time = FileModDate(s);
current_time = __imlib_FileModDate(s);
if (current_time > last_modified_home_time)
{
/* yup - set the "do_reload" flag */
@ -449,12 +444,12 @@ RescanLoaders(void)
/* if we dont ned to reload the loaders - get out now */
if (!do_reload)
return;
RemoveAllLoaders();
LoadAllLoaders();
__imlib_RemoveAllLoaders();
__imlib_LoadAllLoaders();
}
void
RemoveAllLoaders(void)
__imlib_RemoveAllLoaders(void)
{
ImlibLoader *l, *il;
@ -463,18 +458,18 @@ RemoveAllLoaders(void)
{
il = l;
l = l->next;
ConsumeLoader(il);
__imlib_ConsumeLoader(il);
}
loaders = NULL;
}
void
LoadAllLoaders(void)
__imlib_LoadAllLoaders(void)
{
int i, num;
char **list;
list = ListLoaders(&num);
list = __imlib_ListLoaders(&num);
if (!list)
return;
@ -482,7 +477,7 @@ LoadAllLoaders(void)
{
ImlibLoader *l;
l = ProduceLoader(list[i]);
l = __imlib_ProduceLoader(list[i]);
if (l)
{
l->next = loaders;
@ -495,14 +490,14 @@ LoadAllLoaders(void)
}
ImlibLoader *
FindBestLoaderForFile(char *file)
__imlib_FindBestLoaderForFile(char *file)
{
char *extension, *lower;
ImlibLoader *l = NULL;
/* use the file extension for a "best guess" as to what loader to try */
/* first at any rate */
extension = strdup(FileExtension(file));
extension = strdup(__imlib_FileExtension(file));
/* change the extensiont o all lwoer case as all "types" are listed as */
/* lower case strings fromt he loader that represent all the possible */
/* extensions that file format could have */
@ -544,17 +539,17 @@ FindBestLoaderForFile(char *file)
}
ImlibImage *
LoadImage(char *file,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
char progress_granularity, char immediate_load, char dont_cache)
__imlib_LoadImage(char *file,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
char progress_granularity, char immediate_load, char dont_cache)
{
ImlibImage *im;
ImlibLoader *best_loader;
/* see if we alreayd have the image cached */
im = FindCachedImage(file);
im = __imlib_FindCachedImage(file);
/* if we found a cached image and we shoudl always check that it is */
/* accurate to the disk conents if they changed since we last loaded */
/* and that it is still a valid image */
@ -562,7 +557,7 @@ LoadImage(char *file,
{
time_t current_modified_time;
current_modified_time = FileModDate(file);
current_modified_time = __imlib_FileModDate(file);
/* if the file on disk is newer than the cached one */
if (current_modified_time > im->moddate)
{
@ -579,13 +574,13 @@ LoadImage(char *file,
}
/* either image in cache is invalid or we dont even have it in cache */
/* so produce a new one and load an image into that */
im = ProduceImage();
im = __imlib_ProduceImage();
im->file = strdup(file);
im->moddate = FileModDate(file);
im->moddate = __imlib_FileModDate(file);
/* ok - just check all our loaders are up to date */
RescanLoaders();
__imlib_RescanLoaders();
/* take a guess by extension on the best loader to use */
best_loader = FindBestLoaderForFile(file);
best_loader = __imlib_FindBestLoaderForFile(file);
if (best_loader)
best_loader->load(im, progress, progress_granularity, immediate_load);
/* width is still 0 - the laoder didnt manage to do anything */
@ -623,7 +618,7 @@ LoadImage(char *file,
/* image struct we had and return NULL */
if (im->w == 0)
{
ConsumeImage(im);
__imlib_ConsumeImage(im);
return NULL;
}
@ -631,14 +626,14 @@ LoadImage(char *file,
/* it to our cache if dont_cache isnt set */
im->references = 1;
if (!dont_cache)
AddImageToCache(im);
__imlib_AddImageToCache(im);
else
SET_FLAG(im->flags, F_UNCACHEABLE);
return im;
}
ImlibImagePixmap *
FindImlibImagePixmapByID(Display *d, Pixmap p)
__imlib_FindImlibImagePixmapByID(Display *d, Pixmap p)
{
ImlibImagePixmap *ip;
@ -655,24 +650,59 @@ FindImlibImagePixmapByID(Display *d, Pixmap p)
}
void
FreeImage(ImlibImage *im)
__imlib_FreeImage(ImlibImage *im)
{
if (im->references > 0)
{
im->references--;
CleanupImageCache();
__imlib_CleanupImageCache();
}
}
void
FreePixmap(Display *d, Pixmap p)
__imlib_FreePixmap(Display *d, Pixmap p)
{
ImlibImagePixmap *ip;
ip = FindImlibImagePixmapByID(d, p);
ip = __imlib_FindImlibImagePixmapByID(d, p);
if (ip->references > 0)
{
ip->references--;
CleanupImagePixmapCache();
__imlib_CleanupImagePixmapCache();
}
}
void
__imlib_FlushCache(void)
{
int previous_size;
previous_size = __imlib_GetCacheSize();
__imlib_SetCacheSize(0);
__imlib_SetCacheSize(previous_size);
}
void
__imlib_DirtyPixmapsForImage(ImlibImage *im)
{
ImlibImagePixmap *ip;
ip = pixmaps;
/* go through the pixmap list */
while (ip)
{
/* if image matches */
if (ip->image == im)
ip->dirty = 1;
ip = ip->next;
}
__imlib_CleanupImagePixmapCache();
}
void
__imlib_DirtyImage(ImlibImage *im)
{
SET_FLAG(im->flags, F_INVALID);
__imlib_DirtyPixmapsForImage(im);
}

79
image.h
View File

@ -32,8 +32,8 @@ struct _imlibimage
ImlibBorder border;
int references;
ImlibLoader *loader;
ImlibImage *next;
char *format;
ImlibImage *next;
};
struct _imlibimagepixmap
@ -43,8 +43,12 @@ struct _imlibimagepixmap
Display *display;
Visual *visual;
int depth;
int mode_count;
int source_x, source_y, source_w, source_h;
Colormap colormap;
char antialias, hi_quality, dither_mask;
ImlibBorder border;
ImlibImage *image;
char dirty;
int references;
ImlibImagePixmap *next;
};
@ -68,46 +72,51 @@ struct _imlibloader
ImlibLoader *next;
};
void SetCacheSize(int size);
int GetCacheSize(void);
ImlibImage *ProduceImage(void);
void ConsumeImage(ImlibImage *im);
ImlibImage *FindCachedImage(char *file);
void AddImageToCache(ImlibImage *im);
void RemoveImageFromCache(ImlibImage *im);
void CleanupImageCache(void);
ImlibImagePixmap *ProduceImagePixmap(void);
void ConsumeImagePixmap(ImlibImagePixmap *ip);
ImlibImagePixmap *FindCachedImagePixmap(ImlibImage *im, int w, int h,
void __imlib_SetCacheSize(int size);
int __imlib_GetCacheSize(void);
ImlibImage *__imlib_ProduceImage(void);
void __imlib_ConsumeImage(ImlibImage *im);
ImlibImage *__imlib_FindCachedImage(char *file);
void __imlib_AddImageToCache(ImlibImage *im);
void __imlib_RemoveImageFromCache(ImlibImage *im);
void __imlib_CleanupImageCache(void);
ImlibImagePixmap *__imlib_ProduceImagePixmap(void);
void __imlib_ConsumeImagePixmap(ImlibImagePixmap *ip);
ImlibImagePixmap *__imlib_FindCachedImagePixmap(ImlibImage *im, int w, int h,
Display *d, Visual *v,
int depth, int mode_count);
void AddImagePixmapToCache(ImlibImagePixmap *ip);
void RemoveImagePixmapFromCache(ImlibImagePixmap *ip);
void CleanupImagePixmapCache();
ImlibLoader *ProduceLoader(char *file);
char **ListLoaders(int *num_ret);
void ConsumeLoader(ImlibLoader *l);
void RescanLoaders(void);
void RemoveAllLoaders(void);
void LoadAllLoaders(void);
ImlibLoader *FindBestLoaderForFile(char *file);
ImlibImage *LoadImage(char *file,
int depth, int sx, int sy,
int sw, int sh, Colormap cm,
char aa, char hiq, char dmask);
void __imlib_AddImagePixmapToCache(ImlibImagePixmap *ip);
void __imlib_RemoveImagePixmapFromCache(ImlibImagePixmap *ip);
void __imlib_CleanupImagePixmapCache();
ImlibLoader *__imlib_ProduceLoader(char *file);
char **__imlib_ListLoaders(int *num_ret);
void __imlib_ConsumeLoader(ImlibLoader *l);
void __imlib_RescanLoaders(void);
void __imlib_RemoveAllLoaders(void);
void __imlib_LoadAllLoaders(void);
ImlibLoader *__imlib_FindBestLoaderForFile(char *file);
ImlibImage *__imlib_LoadImage(char *file,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
char progress_granularity, char immediate_load,
char dont_cache);
ImlibImagePixmap *FindImlibImagePixmapByID(Display *d, Pixmap p);
void FreeImage(ImlibImage *im);
void FreePixmap(Display *d, Pixmap p);
ImlibImagePixmap *__imlib_FindImlibImagePixmapByID(Display *d, Pixmap p);
void __imlib_FreeImage(ImlibImage *im);
void __imlib_FreePixmap(Display *d, Pixmap p);
void __imlib_FlushCache(void);
void __imlib_DirtyPixmapsForImage(ImlibImage *im);
void __imlib_DirtyImage(ImlibImage *im);
# define IMAGE_HAS_ALPHA(im) (im->flags & F_HAS_ALPHA)
# define IMAGE_IS_UNLOADED(im) (im->flags & F_UNLOADED)
# define IMAGE_IS_UNCACHEABLE(im) (im->flags & F_UNCACHEABLE)
# define IMAGE_ALWAYS_CHECK_DISK(im) (im->flags & F_ALWAYS_CHECK_DISK)
# define IMAGE_IS_VALID(im) (!(im->flags & F_INVALID))
# define IMAGE_HAS_ALPHA(im) ((im)->flags & F_HAS_ALPHA)
# define IMAGE_IS_UNLOADED(im) ((im)->flags & F_UNLOADED)
# define IMAGE_IS_UNCACHEABLE(im) ((im)->flags & F_UNCACHEABLE)
# define IMAGE_ALWAYS_CHECK_DISK(im) ((im)->flags & F_ALWAYS_CHECK_DISK)
# define IMAGE_IS_VALID(im) (!((im)->flags & F_INVALID))
# define SET_FLAG(flags, f) (flags |= f)
# define UNSET_FLAG(flags, f) (flags &= (~f))
# define SET_FLAG(flags, f) ((flags) |= (f))
# define UNSET_FLAG(flags, f) ((flags) &= (~f))
#endif

12
main.c
View File

@ -59,10 +59,10 @@ int main (int argc, char **argv)
file = argv[i];
}
printf("init\n");
RGBA_init();
__imlib_RGBA_init();
disp = XOpenDisplay(NULL);
printf("load\n");
im = LoadImage(file, NULL, 0, 0, 0);
im = __imlib_LoadImage(file, NULL, 0, 0, 0);
if (!im)
printf("load fialed\n");
if (w < 0)
@ -87,13 +87,13 @@ int main (int argc, char **argv)
vis = DefaultVisual(disp, DefaultScreen(disp));
depth = DefaultDepth(disp, DefaultScreen(disp));
if (depth == 8)
AllocColorTable(disp, DefaultColormap(disp, DefaultScreen(disp)));
__imlib_AllocColorTable(disp, DefaultColormap(disp, DefaultScreen(disp)));
XSync(disp, False);
printf("rend\n");
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 */
SetMaxXImageCount(disp, 5);
__imlib_SetMaxXImageCount(disp, 5);
if (loop)
{
for (i = 0; i < w; i++)
@ -106,7 +106,7 @@ int main (int argc, char **argv)
/*
if (((w - i) > 0) && ((((w - i) * h) / w) > 0))
m = XCreatePixmap(disp, win, (w - i), ((w - i) * h) / w, 1);
*/ RenderImage(disp, im,
*/ __imlib_RenderImage(disp, im,
win, m,
vis,
DefaultColormap(disp, DefaultScreen(disp)),
@ -124,7 +124,7 @@ int main (int argc, char **argv)
}
else
{
RenderImage(disp, im,
__imlib_RenderImage(disp, im,
win, 0,
vis,
DefaultColormap(disp, DefaultScreen(disp)),

89
rend.c
View File

@ -6,7 +6,6 @@
#include "ximage.h"
#include "rend.h"
#include "rgba.h"
#include "image.h"
#include "color.h"
#include "grab.h"
#include "blend.h"
@ -22,12 +21,12 @@ if ((x + w) > ww) {w = ww - x;} \
if ((y + h) > hh) {h = hh - y;}
void
RenderImage(Display *d, ImlibImage *im,
Drawable w, Drawable m,
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)
__imlib_RenderImage(Display *d, ImlibImage *im,
Drawable w, Drawable m,
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)
{
XImage *xim, *mxim;
DATA32 *buf = NULL, *pointer, *back = NULL;
@ -85,10 +84,10 @@ RenderImage(Display *d, ImlibImage *im,
if (!((sw == dw) && (sh == dh)))
{
/* need to calculate ypoitns and xpoints array */
ypoints = CalcYPoints(im->data, im->w, im->h, sch, im->border.top, im->border.bottom);
ypoints = __imlib_CalcYPoints(im->data, im->w, im->h, sch, im->border.top, im->border.bottom);
if (!ypoints)
return;
xpoints = CalcXPoints(im->w, scw, im->border.left, im->border.right);
xpoints = __imlib_CalcXPoints(im->w, scw, im->border.left, im->border.right);
if (!xpoints)
{
free(ypoints);
@ -97,14 +96,14 @@ RenderImage(Display *d, ImlibImage *im,
/* calculate aliasing counts */
if (anitalias)
{
yapoints = CalcApoints(im->h, sch, im->border.top, im->border.bottom);
yapoints = __imlib_CalcApoints(im->h, sch, im->border.top, im->border.bottom);
if (!yapoints)
{
free(ypoints);
free(xpoints);
return;
}
xapoints = CalcApoints(im->w, scw, im->border.left, im->border.right);
xapoints = __imlib_CalcApoints(im->w, scw, im->border.left, im->border.right);
if (!xapoints)
{
free(yapoints);
@ -115,9 +114,9 @@ RenderImage(Display *d, ImlibImage *im,
}
}
if ((blend) && (IMAGE_HAS_ALPHA(im)))
back = GrabDrawableToRGBA(d, w, 0, v, cm, depth, dx, dy, dw, dh, 0);
back = __imlib_GrabDrawableToRGBA(d, w, 0, v, cm, depth, dx, dy, dw, dh, 0);
/* get a new XImage - or get one from the cached list */
xim = ProduceXImage(d, v, depth, dw, dh, &shm);
xim = __imlib_ProduceXImage(d, v, depth, dw, dh, &shm);
if (!xim)
{
if (anitalias)
@ -136,10 +135,10 @@ RenderImage(Display *d, ImlibImage *im,
depth = 32;
if (m)
{
mxim = ProduceXImage(d, v, 1, dw, dh, &shm);
mxim = __imlib_ProduceXImage(d, v, 1, dw, dh, &shm);
if (!mxim)
{
ConsumeXImage(d, xim);
__imlib_ConsumeXImage(d, xim);
if (anitalias)
{
free(xapoints);
@ -159,9 +158,9 @@ RenderImage(Display *d, ImlibImage *im,
buf = malloc(dw * LINESIZE * sizeof(int));
if (!buf)
{
ConsumeXImage(d, xim);
__imlib_ConsumeXImage(d, xim);
if (m)
ConsumeXImage(d, mxim);
__imlib_ConsumeXImage(d, mxim);
if (anitalias)
{
free(xapoints);
@ -194,12 +193,12 @@ RenderImage(Display *d, ImlibImage *im,
if (anitalias)
{
if (IMAGE_HAS_ALPHA(im))
ScaleAARGBA(ypoints, xpoints, buf, xapoints, yapoints, xup, yup, dx, dy + y, 0, 0, dw, hh, dw, im->w);
__imlib_ScaleAARGBA(ypoints, xpoints, buf, xapoints, yapoints, xup, yup, dx, dy + y, 0, 0, dw, hh, dw, im->w);
else
ScaleAARGB(ypoints, xpoints, buf, xapoints, yapoints, xup, yup, dx, dy + y, 0, 0, dw, hh, dw, im->w);
__imlib_ScaleAARGB(ypoints, xpoints, buf, xapoints, yapoints, xup, yup, dx, dy + y, 0, 0, dw, hh, dw, im->w);
}
else
ScaleSampleRGBA(ypoints, xpoints, buf, dx, dy + y, 0, 0, dw, hh, dw);
__imlib_ScaleSampleRGBA(ypoints, xpoints, buf, dx, dy + y, 0, 0, dw, hh, dw);
jump = 0;
pointer = buf;
}
@ -211,7 +210,7 @@ RenderImage(Display *d, ImlibImage *im,
/* if we have a back buffer - we're blending to the bg */
if (back)
{
BlendRGBAToRGBA(pointer, jump, back + (y * dw), 0, dw, hh);
__imlib_BlendRGBAToRGBA(pointer, jump, back + (y * dw), 0, dw, hh);
pointer = back + (y * dw);
jump = 0;
}
@ -221,12 +220,12 @@ RenderImage(Display *d, ImlibImage *im,
if (depth == 16)
{
if (hiq)
RGBA_to_RGB565_dither(pointer, jump,
__imlib_RGBA_to_RGB565_dither(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB565_fast(pointer, jump,
__imlib_RGBA_to_RGB565_fast(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
@ -234,14 +233,14 @@ RenderImage(Display *d, ImlibImage *im,
/* FIXME: need to handle different RGB ordering */
else if (depth == 24)
{
RGBA_to_RGB888_fast(pointer, jump,
__imlib_RGBA_to_RGB888_fast(pointer, jump,
((DATA8 *)xim->data) + (y * xim->bytes_per_line),
xim->bytes_per_line - (dw * 3),
dw, hh, dx, dy + y);
}
else if (depth == 32)
{
RGBA_to_RGB8888_fast(pointer, jump,
__imlib_RGBA_to_RGB8888_fast(pointer, jump,
((DATA32 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA32))),
(xim->bytes_per_line / sizeof(DATA32)) - dw,
dw, hh, dx, dy + y);
@ -251,12 +250,12 @@ RenderImage(Display *d, ImlibImage *im,
if (_pal_type == 0)
{
if (hiq)
RGBA_to_RGB332_dither(pointer, jump,
__imlib_RGBA_to_RGB332_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB332_fast(pointer, jump,
__imlib_RGBA_to_RGB332_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
@ -264,12 +263,12 @@ RenderImage(Display *d, ImlibImage *im,
else if (_pal_type == 1)
{
if (hiq)
RGBA_to_RGB232_dither(pointer, jump,
__imlib_RGBA_to_RGB232_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB232_fast(pointer, jump,
__imlib_RGBA_to_RGB232_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
@ -277,12 +276,12 @@ RenderImage(Display *d, ImlibImage *im,
else if (_pal_type == 2)
{
if (hiq)
RGBA_to_RGB222_dither(pointer, jump,
__imlib_RGBA_to_RGB222_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB222_fast(pointer, jump,
__imlib_RGBA_to_RGB222_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
@ -290,12 +289,12 @@ RenderImage(Display *d, ImlibImage *im,
else if (_pal_type == 3)
{
if (hiq)
RGBA_to_RGB221_dither(pointer, jump,
__imlib_RGBA_to_RGB221_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB221_fast(pointer, jump,
__imlib_RGBA_to_RGB221_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
@ -303,12 +302,12 @@ RenderImage(Display *d, ImlibImage *im,
else if (_pal_type == 4)
{
if (hiq)
RGBA_to_RGB121_dither(pointer, jump,
__imlib_RGBA_to_RGB121_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB121_fast(pointer, jump,
__imlib_RGBA_to_RGB121_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
@ -316,12 +315,12 @@ RenderImage(Display *d, ImlibImage *im,
else if (_pal_type == 5)
{
if (hiq)
RGBA_to_RGB111_dither(pointer, jump,
__imlib_RGBA_to_RGB111_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB111_fast(pointer, jump,
__imlib_RGBA_to_RGB111_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
@ -329,12 +328,12 @@ RenderImage(Display *d, ImlibImage *im,
else if (_pal_type == 6)
{
if (hiq)
RGBA_to_RGB1_dither(pointer, jump,
__imlib_RGBA_to_RGB1_dither(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB1_fast(pointer, jump,
__imlib_RGBA_to_RGB1_fast(pointer, jump,
((DATA8 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA8))),
(xim->bytes_per_line / sizeof(DATA8)) - dw,
dw, hh, dx, dy + y);
@ -343,12 +342,12 @@ RenderImage(Display *d, ImlibImage *im,
else if (depth == 15)
{
if (hiq)
RGBA_to_RGB555_dither(pointer, jump,
__imlib_RGBA_to_RGB555_dither(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
else
RGBA_to_RGB555_fast(pointer, jump,
__imlib_RGBA_to_RGB555_fast(pointer, jump,
((DATA16 *)xim->data) + (y * (xim->bytes_per_line / sizeof(DATA16))),
(xim->bytes_per_line / sizeof(DATA16)) - dw,
dw, hh, dx, dy + y);
@ -358,12 +357,12 @@ RenderImage(Display *d, ImlibImage *im,
memset(((DATA8 *)mxim->data) + (y * (mxim->bytes_per_line)),
0x0, mxim->bytes_per_line * hh);
if (dither_mask)
RGBA_to_A1_dither(pointer, jump,
__imlib_RGBA_to_A1_dither(pointer, jump,
((DATA8 *)mxim->data) + (y * (mxim->bytes_per_line)),
(mxim->bytes_per_line) - (dw >> 3),
dw, hh, dx, dy + y);
else
RGBA_to_A1_fast(pointer, jump,
__imlib_RGBA_to_A1_fast(pointer, jump,
((DATA8 *)mxim->data) + (y * (mxim->bytes_per_line)),
(mxim->bytes_per_line) - (dw >> 3),
dw, hh, dx, dy + y);
@ -417,8 +416,8 @@ RenderImage(Display *d, ImlibImage *im,
/* wait for the write to be done */
if (shm)
XSync(d, False);
ConsumeXImage(d, xim);
__imlib_ConsumeXImage(d, xim);
if (m)
ConsumeXImage(d, mxim);
__imlib_ConsumeXImage(d, mxim);
}

12
rend.h
View File

@ -1,10 +1,10 @@
#ifndef __REND
#define __REND 1
void
RenderImage(Display *d, ImlibImage *im,
Drawable w, Drawable m,
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);
__imlib_RenderImage(Display *d, ImlibImage *im,
Drawable w, Drawable m,
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);
#endif

46
rgba.c
View File

@ -1117,7 +1117,7 @@ src++;
/* Palette mode stuff */
void
RGBA_init(void)
__imlib_RGBA_init(void)
{
/* the famous dither matrix */
DATA8 _dither_44[4][4] =
@ -1332,7 +1332,7 @@ RGBA_init(void)
}
void
RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -1400,7 +1400,7 @@ RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -1470,7 +1470,7 @@ RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -1538,7 +1538,7 @@ RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -1608,7 +1608,7 @@ RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -1704,7 +1704,7 @@ RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -1782,7 +1782,7 @@ RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -1878,7 +1878,7 @@ RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -1956,7 +1956,7 @@ RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2052,7 +2052,7 @@ RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2130,7 +2130,7 @@ RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2226,7 +2226,7 @@ RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2304,7 +2304,7 @@ RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2400,7 +2400,7 @@ RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2478,7 +2478,7 @@ RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2574,7 +2574,7 @@ RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2652,7 +2652,7 @@ RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2676,7 +2676,7 @@ RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2700,7 +2700,7 @@ RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_A1_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_A1_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2724,7 +2724,7 @@ RGBA_to_A1_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_A1_dither(DATA32 *src , int src_jump,
__imlib_RGBA_to_A1_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2748,7 +2748,7 @@ RGBA_to_A1_dither(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
DATA32 *dest, int dest_jump,
int width, int height, int dx, int dy)
{
@ -2772,7 +2772,7 @@ RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
}
void
RGBA_to_RGB888_fast(DATA32 *src , int src_jump,
__imlib_RGBA_to_RGB888_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy)
{

46
rgba.h
View File

@ -1,71 +1,71 @@
#ifndef __RGBA
#define __RGBA 1
void RGBA_init(void);
void RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_init(void);
void __imlib_RGBA_to_RGB565_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB565_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB555_fast(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB555_dither(DATA32 *src , int src_jump,
DATA16 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB332_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB332_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB232_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB232_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB222_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB222_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB221_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB221_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB121_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB121_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB111_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB111_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB1_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB1_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_A1_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_A1_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_A1_dither(DATA32 *src , int src_jump,
void __imlib_RGBA_to_A1_dither(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB8888_fast(DATA32 *src , int src_jump,
DATA32 *dest, int dest_jump,
int width, int height, int dx, int dy);
void RGBA_to_RGB888_fast(DATA32 *src , int src_jump,
void __imlib_RGBA_to_RGB888_fast(DATA32 *src , int src_jump,
DATA8 *dest, int dest_jump,
int width, int height, int dx, int dy);
#endif

7
rgbadraw.c Normal file
View File

@ -0,0 +1,7 @@
#include <X11/Xlib.h>
#include "common.h"
#include "scale.h"
#include "image.h"
#include "rgba.h"
#include "blend.h"

3
rgbadraw.h Normal file
View File

@ -0,0 +1,3 @@
#ifndef __RGBADRAW
#define __RGBADRAW 1
#endif

12
scale.c
View File

@ -12,7 +12,7 @@
#define YAP (yapoints[dyy + y])
DATA32 **
CalcYPoints(DATA32 *src, int sw, int sh, int dh, int b1, int b2)
__imlib_CalcYPoints(DATA32 *src, int sw, int sh, int dh, int b1, int b2)
{
DATA32 **p;
int i, j = 0;
@ -57,7 +57,7 @@ CalcYPoints(DATA32 *src, int sw, int sh, int dh, int b1, int b2)
}
int *
CalcXPoints(int sw, int dw, int b1, int b2)
__imlib_CalcXPoints(int sw, int dw, int b1, int b2)
{
int *p, i, j = 0;
int val, inc;
@ -101,7 +101,7 @@ CalcXPoints(int sw, int dw, int b1, int b2)
}
int *
CalcApoints(int s, int d, int b1, int b2)
__imlib_CalcApoints(int s, int d, int b1, int b2)
{
int *p, i, v, j = 0;
@ -176,7 +176,7 @@ CalcApoints(int s, int d, int b1, int b2)
/* scale by pixel sampling only */
void
ScaleSampleRGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
__imlib_ScaleSampleRGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int dxx, int dyy, int dx, int dy, int dw, int dh, int dow)
{
DATA32 *sptr, *dptr;
@ -201,7 +201,7 @@ ScaleSampleRGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
/* scale by area sampling */
void
ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
__imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int *xapoints, int *yapoints, char xup, char yup,
int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow)
{
@ -552,7 +552,7 @@ ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
/* scale by area sampling - IGNORE the ALPHA byte*/
void
ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
__imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int *xapoints, int *yapoints, char xup, char yup,
int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow)
{

12
scale.h
View File

@ -2,20 +2,20 @@
#define __SCALE 1
DATA32 **
CalcYPoints(DATA32 *src, int sw, int sh, int dh, int b1, int b2);
__imlib_CalcYPoints(DATA32 *src, int sw, int sh, int dh, int b1, int b2);
int *
CalcXPoints(int sw, int dw, int b1, int b2);
__imlib_CalcXPoints(int sw, int dw, int b1, int b2);
int *
CalcApoints(int s, int d, int b1, int b2);
__imlib_CalcApoints(int s, int d, int b1, int b2);
void
ScaleSampleRGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
__imlib_ScaleSampleRGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int dxx, int dyy, int dx, int dy, int dw, int dh, int dow);
void
ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
__imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int *xapoints, int *yapoints, char xup, char yup,
int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow);
void
ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
__imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int *xapoints, int *yapoints, char xup, char yup,
int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow);
#endif

View File

@ -28,33 +28,33 @@ TmpXError(Display * d, XErrorEvent * ev)
}
void
SetMaxXImageCount(Display *d, int num)
__imlib_SetMaxXImageCount(Display *d, int num)
{
list_max_count = num;
FlushXImage(d);
__imlib_FlushXImage(d);
}
int
GetMaxXImageCount(Display *d)
__imlib_GetMaxXImageCount(Display *d)
{
return list_max_count;
}
void
SetMaxXImageTotalSize(Display *d, int num)
__imlib_SetMaxXImageTotalSize(Display *d, int num)
{
list_max_mem = num;
FlushXImage(d);
__imlib_FlushXImage(d);
}
int
GetMaxXImageTotalSize(Display *d)
__imlib_GetMaxXImageTotalSize(Display *d)
{
return list_max_mem;
}
void
FlushXImage(Display *d)
__imlib_FlushXImage(Display *d)
{
int i;
XImage *xim;
@ -101,7 +101,7 @@ FlushXImage(Display *d)
/* free (consume == opposite of produce) the XImage (mark as unused) */
void
ConsumeXImage(Display *d, XImage *xim)
__imlib_ConsumeXImage(Display *d, XImage *xim)
{
int i;
@ -114,7 +114,7 @@ ConsumeXImage(Display *d, XImage *xim)
/* we have a match = mark as unused */
list_used[i] = 0;
/* flush the XImage list to get rud of stuff we dont want */
FlushXImage(d);
__imlib_FlushXImage(d);
/* return */
return;
}
@ -124,7 +124,7 @@ ConsumeXImage(Display *d, XImage *xim)
/* create a new XImage or find it on our list of currently available ones so */
/* we dont need to create a new one */
XImage *
ProduceXImage(Display *d, Visual *v, int depth, int w, int h, char *shared)
__imlib_ProduceXImage(Display *d, Visual *v, int depth, int w, int h, char *shared)
{
XImage *xim;
int i;
@ -276,7 +276,7 @@ ProduceXImage(Display *d, Visual *v, int depth, int w, int h, char *shared)
list_d[list_num - 1] = d;
}
/* flush unused images from the image list */
FlushXImage(d);
__imlib_FlushXImage(d);
/* return out image */
return xim;
}

View File

@ -1,10 +1,10 @@
#ifndef __XIMAGE
#define __XIMAGE 1
void SetMaxXImageCount(Display *d, int num);
int GetMaxXImageCount(Display *d);
void SetMaxXImageTotalSize(Display *d, int num);
int GetMaxXImageTotalSize(Display *d);
void FlushXImage(Display *d);
void ConsumeXImage(Display *d, XImage *xim);
XImage *ProduceXImage(Display *d, Visual *v, int depth, int w, int h, char *shared);
void __imlib_SetMaxXImageCount(Display *d, int num);
int __imlib_GetMaxXImageCount(Display *d);
void __imlib_SetMaxXImageTotalSize(Display *d, int num);
int __imlib_GetMaxXImageTotalSize(Display *d);
void __imlib_FlushXImage(Display *d);
void __imlib_ConsumeXImage(Display *d, XImage *xim);
XImage *__imlib_ProduceXImage(Display *d, Visual *v, int depth, int w, int h, char *shared);
#endif