damn willem! you love playing with imlib2 don;t you? :-) good show :)

SVN revision: 2358
This commit is contained in:
Carsten Haitzler 2000-03-28 18:09:46 +00:00
parent 24cc517876
commit 87146f0a33
10 changed files with 86 additions and 92 deletions

View File

@ -185,7 +185,7 @@ load (ImlibImage *im,
lines[0] = line;
png_read_rows(png_ptr, &lines[0], NULL, nrows);
ptr = ((unsigned char *)(im->data)) + (y * w * sizeof(DATA32));
ptr = im->data + (y * w);
for (i = 0; i < w; i++)
{
ptr[0] =

View File

@ -180,7 +180,7 @@ void imlib_remove_path_from_font_path(const char *path);
char **imlib_list_font_path(int *number_return);
int imlib_text_get_index_and_location(const char *text, int x, int y, int *char_x_return, int *char_y_return, int *char_width_return, int *char_height_return);
char **imlib_list_fonts(int *number_return);
void imlib_free_font_list(const char **font_list, int number);
void imlib_free_font_list(char **font_list, int number);
int imlib_get_font_cache_size(void);
void imlib_set_font_cache_size(int bytes);
void imlib_flush_font_cache(void);

View File

@ -371,8 +371,8 @@ imlib_load_image(const char *file)
CHECK_PARAM_POINTER_RETURN("imlib_load_image", "file", file, NULL);
prev_ctxt_image = ctxt_image;
im = __imlib_LoadImage(file, ctxt_progress_func, ctxt_progress_granularity,
0, 0, NULL);
im = __imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func,
ctxt_progress_granularity, 0, 0, NULL);
ctxt_image = prev_ctxt_image;
return (Imlib_Image)im;
}
@ -385,8 +385,8 @@ imlib_load_image_immediately(const char *file)
CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately", "file", file, NULL);
prev_ctxt_image = ctxt_image;
im = __imlib_LoadImage(file, ctxt_progress_func, ctxt_progress_granularity,
1, 0, NULL);
im = __imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func,
ctxt_progress_granularity, 1, 0, NULL);
ctxt_image = prev_ctxt_image;
return (Imlib_Image)im;
}
@ -399,8 +399,8 @@ imlib_load_image_without_cache(const char *file)
CHECK_PARAM_POINTER_RETURN("imlib_load_image_without_cache", "file", file, NULL);
prev_ctxt_image = ctxt_image;
im = __imlib_LoadImage(file, ctxt_progress_func, ctxt_progress_granularity,
0, 1, NULL);
im = __imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func,
ctxt_progress_granularity, 0, 1, NULL);
ctxt_image = prev_ctxt_image;
return (Imlib_Image)im;
}
@ -413,8 +413,8 @@ imlib_load_image_immediately_without_cache(const char *file)
CHECK_PARAM_POINTER_RETURN("imlib_load_image_immediately_without_cache", "file", file, NULL);
prev_ctxt_image = ctxt_image;
im = __imlib_LoadImage(file, ctxt_progress_func, ctxt_progress_granularity,
1, 1, NULL);
im = __imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func,
ctxt_progress_granularity, 1, 1, NULL);
ctxt_image = prev_ctxt_image;
return (Imlib_Image)im;
}
@ -443,7 +443,7 @@ imlib_load_image_with_error_return(const char *file, Imlib_Load_Error *error_ret
return NULL;
}
prev_ctxt_image = ctxt_image;
im = (Imlib_Image)__imlib_LoadImage(file, ctxt_progress_func,
im = (Imlib_Image)__imlib_LoadImage(file, (ImlibProgressFunction)ctxt_progress_func,
ctxt_progress_granularity, 1, 0, &er);
ctxt_image = prev_ctxt_image;
if (im)
@ -1618,7 +1618,7 @@ imlib_list_fonts(int *number_return)
}
void
imlib_free_font_list(const char **font_list, int number)
imlib_free_font_list(char **font_list, int number)
{
CHECK_PARAM_POINTER("imlib_free_font_list", "font_list", font_list);
CHECK_PARAM_POINTER("imlib_free_font_list", "number", number);
@ -2041,7 +2041,8 @@ imlib_image_attach_data_value(const char *key, void *data, int value,
CHECK_PARAM_POINTER("imlib_image_attach_data_value", "image", ctxt_image);
CHECK_PARAM_POINTER("imlib_image_attach_data_value", "key", key);
CAST_IMAGE(im, ctxt_image);
__imlib_AttachTag(im, key, value, data, destructor_function);
__imlib_AttachTag(im, key, value, data,
(ImlibDataDestructorFunction)destructor_function);
}
void *
@ -2112,7 +2113,7 @@ imlib_save_image(const char *filename)
if (!im->data)
return;
prev_ctxt_image = ctxt_image;
__imlib_SaveImage(im, filename, ctxt_progress_func,
__imlib_SaveImage(im, filename, (ImlibProgressFunction)ctxt_progress_func,
ctxt_progress_granularity, NULL);
ctxt_image = prev_ctxt_image;
}
@ -2133,7 +2134,7 @@ imlib_save_image_with_error_return(const char *filename,
if (!im->data)
return;
prev_ctxt_image = ctxt_image;
__imlib_SaveImage(im, filename, ctxt_progress_func,
__imlib_SaveImage(im, filename, (ImlibProgressFunction)ctxt_progress_func,
ctxt_progress_granularity, error_return);
ctxt_image = prev_ctxt_image;
}

View File

@ -12,7 +12,7 @@
static void __imlib_FileFieldWord(char *s, int num, char *wd);
char *
__imlib_FileExtension(char *file)
__imlib_FileExtension(const char *file)
{
char *p;
@ -23,7 +23,7 @@ __imlib_FileExtension(char *file)
}
int
__imlib_FileExists(char *s)
__imlib_FileExists(const char *s)
{
struct stat st;
@ -35,7 +35,7 @@ __imlib_FileExists(char *s)
}
int
__imlib_FileIsFile(char *s)
__imlib_FileIsFile(const char *s)
{
struct stat st;
@ -49,7 +49,7 @@ __imlib_FileIsFile(char *s)
}
int
__imlib_FileIsDir(char *s)
__imlib_FileIsDir(const char *s)
{
struct stat st;
@ -63,7 +63,7 @@ __imlib_FileIsDir(char *s)
}
int
__imlib_FilePermissions(char *s)
__imlib_FilePermissions(const char *s)
{
struct stat st;
@ -75,7 +75,7 @@ __imlib_FilePermissions(char *s)
}
int
__imlib_FileCanRead(char *s)
__imlib_FileCanRead(const char *s)
{
if (!(__imlib_FilePermissions(s) & (S_IRUSR | S_IRGRP | S_IROTH)))
return 0;
@ -171,7 +171,7 @@ __imlib_FileDel(char *s)
}
time_t
__imlib_FileModDate(char *s)
__imlib_FileModDate(const char *s)
{
struct stat st;

View File

@ -1,17 +1,17 @@
#ifndef __FILE
#define __FILE 1
char *__imlib_FileExtension(char *file);
int __imlib_FileExists(char *s);
int __imlib_FileIsFile(char *s);
int __imlib_FileIsDir(char *s);
char *__imlib_FileExtension(const char *file);
int __imlib_FileExists(const char *s);
int __imlib_FileIsFile(const char *s);
int __imlib_FileIsDir(const 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);
time_t __imlib_FileModDate(const char *s);
char *__imlib_FileHomeDir(int uid);
char *__imlib_FileField(char *s, int field);
int __imlib_FilePermissions(char *s);
int __imlib_FileCanRead(char *s);
int __imlib_FilePermissions(const char *s);
int __imlib_FileCanRead(const char *s);
#endif

View File

@ -69,7 +69,7 @@ __imlib_destroy_font_raster(TT_Raster_Map * rmap)
}
void
__imlib_add_font_path(char *path)
__imlib_add_font_path(const char *path)
{
fpath_num++;
if (!fpath)
@ -80,7 +80,7 @@ __imlib_add_font_path(char *path)
}
void
__imlib_del_font_path(char *path)
__imlib_del_font_path(const char *path)
{
int i, j;
@ -110,7 +110,7 @@ __imlib_list_font_path(int *num_ret)
}
ImlibFont *
__imlib_find_cached_font(char *fontname)
__imlib_find_cached_font(const char *fontname)
{
ImlibFont *pf, *f;
@ -136,7 +136,7 @@ __imlib_find_cached_font(char *fontname)
}
ImlibFont *
__imlib_load_font(char *fontname)
__imlib_load_font(const char *fontname)
{
ImlibFont *f;
TT_Error error;
@ -350,7 +350,7 @@ __imlib_load_font(char *fontname)
}
void
__imlib_calc_size(ImlibFont *f, int *width, int *height, char *text)
__imlib_calc_size(ImlibFont *f, int *width, int *height, const char *text)
{
int i, ascent, descent, pw, ph;
TT_Glyph_Metrics gmetrics;
@ -380,7 +380,7 @@ __imlib_calc_size(ImlibFont *f, int *width, int *height, char *text)
}
void
__imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx, int dry, char *text,
__imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx, int dry, const char *text,
DATA8 r, DATA8 g, DATA8 b, DATA8 a,
char dir, int *retw, int *reth, int blur,
int *nextx, int *nexty, ImlibOp op)
@ -616,7 +616,7 @@ __imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx, int dry, char *text,
}
int
__imlib_char_pos(ImlibFont *fn, char *text, int x, int y,
__imlib_char_pos(ImlibFont *fn, const char *text, int x, int y,
int *cx, int *cy, int *cw, int *ch)
{
int i, px, ppx;

View File

@ -25,20 +25,20 @@ struct _imlib_font
TT_Raster_Map *__imlib_create_font_raster(int width, int height);
void __imlib_destroy_font_raster(TT_Raster_Map * rmap);
void __imlib_add_font_path(char *path);
void __imlib_del_font_path(char *path);
void __imlib_add_font_path(const char *path);
void __imlib_del_font_path(const char *path);
char **__imlib_list_font_path(int *num_ret);
ImlibFont *__imlib_find_cached_font(char *fontname);
ImlibFont *__imlib_load_font(char *fontname);
ImlibFont *__imlib_find_cached_font(const char *fontname);
ImlibFont *__imlib_load_font(const char *fontname);
void __imlib_free_font(ImlibFont *font);
void __imlib_calc_size(ImlibFont *f, int *width, int *height,
char *text);
const char *text);
void __imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx,
int dry, char *text,
int dry, const char *text,
DATA8 r, DATA8 g, DATA8 b, DATA8 a,
char dir, int *retw, int *reth, int blur,
int *nextx, int *nexty, ImlibOp op);
int __imlib_char_pos(ImlibFont *fn, char *text, int x, int y,
int __imlib_char_pos(ImlibFont *fn, const char *text, int x, int y,
int *cx, int *cy, int *cw, int *ch);
char **__imlib_list_fonts(int *num_ret);
void __imlib_free_font_list(char **list, int num);

View File

@ -19,8 +19,8 @@ static int cache_size = 4096 * 1024;
/* attach a string key'd data and/or int value to an image that cna be */
/* looked up later by its string key */
void
__imlib_AttachTag(ImlibImage *im, char *key, int val, void *data,
void (*destructor)(ImlibImage *im, void *data))
__imlib_AttachTag(ImlibImage *im, const char *key, int val, void *data,
ImlibDataDestructorFunction destructor)
{
ImlibImageTag *t;
@ -45,7 +45,7 @@ __imlib_AttachTag(ImlibImage *im, char *key, int val, void *data,
/* look up a tage by its key on the image it was attached to */
ImlibImageTag *
__imlib_GetTag(ImlibImage *im, char *key)
__imlib_GetTag(ImlibImage *im, const char *key)
{
ImlibImageTag *t;
@ -63,7 +63,7 @@ __imlib_GetTag(ImlibImage *im, char *key)
/* remove a tag by looking it up by its key and removing it from */
/* the list of keys */
ImlibImageTag *
__imlib_RemoveTag(ImlibImage *im, char *key)
__imlib_RemoveTag(ImlibImage *im, const char *key)
{
ImlibImageTag *t, *tt;
@ -160,7 +160,7 @@ __imlib_ConsumeImage(ImlibImage *im)
}
ImlibImage *
__imlib_FindCachedImage(char *file)
__imlib_FindCachedImage(const char *file)
{
ImlibImage *im, *previous_im;
@ -781,7 +781,7 @@ __imlib_LoadAllLoaders(void)
}
ImlibLoader *
__imlib_FindBestLoaderForFile(char *file)
__imlib_FindBestLoaderForFile(const char *file)
{
char *extension, *lower;
ImlibLoader *l = NULL;
@ -836,7 +836,7 @@ __imlib_FindBestLoaderForFile(char *file)
}
ImlibLoader *
__imlib_FindBestLoaderForFileFormat(char *file, char *format)
__imlib_FindBestLoaderForFileFormat(const char *file, char *format)
{
char *extension, *lower;
ImlibLoader *l = NULL;
@ -911,10 +911,8 @@ __imlib_CreateImage(int w, int h, DATA32 *data)
}
ImlibImage *
__imlib_LoadImage(char *file,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
__imlib_LoadImage(const char *file,
ImlibProgressFunction progress,
char progress_granularity, char immediate_load, char dont_cache,
ImlibLoadError *er)
{
@ -1197,10 +1195,8 @@ __imlib_DirtyImage(ImlibImage *im)
}
void
__imlib_SaveImage(ImlibImage *im, char *file,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
__imlib_SaveImage(ImlibImage *im, const char *file,
ImlibProgressFunction progress,
char progress_granularity,
ImlibLoadError *er)
{

View File

@ -9,6 +9,11 @@ typedef struct _imlibborder ImlibBorder;
typedef struct _imlibloader ImlibLoader;
typedef struct _imlibimagetag ImlibImageTag;
typedef void (*ImlibProgressFunction)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h);
typedef void (*ImlibDataDestructorFunction)(ImlibImage *im, void *data);
enum _load_error
{
LOAD_ERROR_NONE,
@ -99,22 +104,18 @@ struct _imlibloader
char **formats;
lt_dlhandle handle;
char (*load)(ImlibImage *im,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
ImlibProgressFunction progress,
char progress_granularity, char immediate_load);
char (*save)(ImlibImage *im,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
ImlibProgressFunction progress,
char progress_granularity);
ImlibLoader *next;
};
void __imlib_AttachTag(ImlibImage *im, char *key, int val, void *data,
void (*destructor)(ImlibImage *im, void *data));
ImlibImageTag *__imlib_GetTag(ImlibImage *im, char *key);
ImlibImageTag *__imlib_RemoveTag(ImlibImage *im, char *key);
void __imlib_AttachTag(ImlibImage *im, const char *key, int val, void *data,
ImlibDataDestructorFunction destructor);
ImlibImageTag *__imlib_GetTag(ImlibImage *im, const char *key);
ImlibImageTag *__imlib_RemoveTag(ImlibImage *im, const char *key);
void __imlib_FreeTag(ImlibImage *im, ImlibImageTag *t);
void __imlib_FreeAllTags(ImlibImage *im);
@ -122,7 +123,7 @@ void __imlib_SetCacheSize(int size);
int __imlib_GetCacheSize(void);
ImlibImage *__imlib_ProduceImage(void);
void __imlib_ConsumeImage(ImlibImage *im);
ImlibImage *__imlib_FindCachedImage(char *file);
ImlibImage *__imlib_FindCachedImage(const char *file);
void __imlib_AddImageToCache(ImlibImage *im);
void __imlib_RemoveImageFromCache(ImlibImage *im);
int __imlib_CurrentCacheSize(void);
@ -147,14 +148,12 @@ void __imlib_ConsumeLoader(ImlibLoader *l);
void __imlib_RescanLoaders(void);
void __imlib_RemoveAllLoaders(void);
void __imlib_LoadAllLoaders(void);
ImlibLoader *__imlib_FindBestLoaderForFile(char *file);
ImlibLoader *__imlib_FindBestLoaderForFileFormat(char *file, char *format);
ImlibLoader *__imlib_FindBestLoaderForFile(const char *file);
ImlibLoader *__imlib_FindBestLoaderForFileFormat(const char *file, char *format);
void __imlib_SetImageAlphaFlag(ImlibImage *im, char alpha);
ImlibImage *__imlib_CreateImage(int w, int h, DATA32 *data);
ImlibImage *__imlib_LoadImage(char *file,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
ImlibImage *__imlib_LoadImage(const char *file,
ImlibProgressFunction progress,
char progress_granularity, char immediate_load,
char dont_cache, ImlibLoadError *er);
ImlibImagePixmap *__imlib_FindImlibImagePixmapByID(Display *d, Pixmap p);
@ -163,10 +162,8 @@ void __imlib_FreePixmap(Display *d, Pixmap p);
void __imlib_FlushCache(void);
void __imlib_DirtyPixmapsForImage(ImlibImage *im);
void __imlib_DirtyImage(ImlibImage *im);
void __imlib_SaveImage(ImlibImage *im, char *file,
void (*progress)(ImlibImage *im, char percent,
int update_x, int update_y,
int update_w, int update_h),
void __imlib_SaveImage(ImlibImage *im, const char *file,
ImlibProgressFunction progress,
char progress_granularity,
ImlibLoadError *er);

View File

@ -47,7 +47,7 @@ x &= _ROTATE_PREC_BITS; y &= _ROTATE_PREC_BITS;
/*\ One colour, alpha between one value and three zeroes \*/
#define INTERP_A000(dest, v, f1, f2) do { \
dest = v; \
*dest = *v; \
A_VAL(dest) = (A_VAL(dest) * \
(f1) * (f2)) >> (2 * _ROTATE_PREC); \
} while (0)
@ -96,8 +96,8 @@ __imlib_RotateAAInside(DATA32 *src, DATA32 *dest, int sow, int dow,
while (1) {
i = dw - 1;
do {
INTERP_ARGB(*dest, src[0], src[1],
src[sow], src[sow + 1], x, y);
INTERP_ARGB(dest, src, src + 1,
src + sow, src + sow + 1, x, y);
/*\ RIGHT; \*/
x += dx;
y += dy;
@ -219,20 +219,20 @@ __imlib_RotateAA(DATA32 *src, DATA32 *dest, int sow, int sw, int sh,
/*\ 12
|*| 34
\*/
INTERP_ARGB(*dest, src[0], src[1],
src[sow], src[sow + 1], x, y);
INTERP_ARGB(dest, src, src + 1,
src + sow, src + sow + 1, x, y);
} else if (src < (sb + sow)) {
/*\ 12
|*| ..
\*/
INTERP_RGB_A0(*dest, src[0], src[1], x,
INTERP_RGB_A0(dest, src, src + 1, x,
(_ROTATE_PREC_MAX - y));
}
} else if (src >= (st - sow)) {
/*\ ..
|*| 34
\*/
INTERP_RGB_A0(*dest, src[sow], src[sow + 1], x, y);
INTERP_RGB_A0(dest, src + sow, src + sow + 1, x, y);
}
} else if (xp < sw) {
if (src >= st) {
@ -240,20 +240,20 @@ __imlib_RotateAA(DATA32 *src, DATA32 *dest, int sow, int sw, int sh,
/*\ 1.
|*| 3.
\*/
INTERP_RGB_A0(*dest, src[0], src[sow], y,
INTERP_RGB_A0(dest, src, src + sow, y,
(_ROTATE_PREC_MAX - x));
} else if (src < (sb + sow)) {
/*\ 1.
|*| ..
\*/
INTERP_A000(*dest, src[0], (_ROTATE_PREC_MAX - x),
INTERP_A000(dest, src, (_ROTATE_PREC_MAX - x),
(_ROTATE_PREC_MAX - y));
}
} else if (src >= (st - sow)) {
/*\ ..
|*| 3.
\*/
INTERP_A000(*dest, src[sow], (_ROTATE_PREC_MAX - x), y);
INTERP_A000(dest, src + sow, (_ROTATE_PREC_MAX - x), y);
}
}
} else if (xp >= -1) {
@ -262,18 +262,18 @@ __imlib_RotateAA(DATA32 *src, DATA32 *dest, int sow, int sw, int sh,
/*\ .2
|*| .4
\*/
INTERP_RGB_A0(*dest, src[1], src[sow + 1], y, x);
INTERP_RGB_A0(dest, src + 1, src + sow + 1, y, x);
} else if (src < ((sb - 1) + sow)) {
/*\ .2
|*| ..
\*/
INTERP_A000(*dest, src[1], x, (_ROTATE_PREC_MAX - y));
INTERP_A000(dest, src + 1, x, (_ROTATE_PREC_MAX - y));
}
} else if (src >= ((st - 1) - sow)) {
/*\ ..
|*| .4
\*/
INTERP_A000(*dest, src[sow + 1], x, y);
INTERP_A000(dest, src + sow + 1, x, y);
}
}
/*\ RIGHT; \*/