You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
6.2 KiB
C

4 years ago
#ifndef __IMAGE
#define __IMAGE 1
#include "imlib2_common.h"
#ifdef BUILD_X11
#include <X11/Xlib.h>
#else
#ifndef X_DISPLAY_MISSING
#define X_DISPLAY_MISSING
#endif
#endif
typedef struct _imlibldctx ImlibLdCtx;
#ifdef BUILD_X11
typedef struct _imlibimagepixmap ImlibImagePixmap;
#endif
typedef struct _imlibloader ImlibLoader;
typedef enum _imlib_load_error ImlibLoadError;
typedef int (*ImlibProgressFunction)(ImlibImage * im, char percent,
int update_x, int update_y,
int update_w, int update_h);
typedef void (*ImlibDataDestructorFunction)(ImlibImage * im, void *data);
typedef void *(*ImlibImageDataMemoryFunction)(void *, size_t size);
#ifdef BUILD_X11
struct _imlibimagepixmap {
int w, h;
Pixmap pixmap, mask;
Display *display;
Visual *visual;
int depth;
int source_x, source_y, source_w, source_h;
Colormap colormap;
char antialias, hi_quality, dither_mask;
ImlibBorder border;
ImlibImage *image;
char *file;
char dirty;
int references;
DATABIG modification_count;
ImlibImagePixmap *next;
};
#endif
void __imlib_LoadAllLoaders(void);
void __imlib_RemoveAllLoaders(void);
ImlibLoader **__imlib_GetLoaderList(void);
ImlibLoader *__imlib_FindBestLoaderForFile(const char *file,
int for_save);
ImlibLoader *__imlib_FindBestLoaderForFormat(const char *format,
int for_save);
ImlibLoader *__imlib_FindBestLoaderForFileFormat(const char *file,
const char *format,
int for_save);
void __imlib_LoaderSetFormats(ImlibLoader * l,
const char *const *fmt,
unsigned int num);
ImlibImage *__imlib_CreateImage(int w, int h, DATA32 * data);
ImlibImage *__imlib_LoadImage(const char *file, FILE * fp,
ImlibProgressFunction progress,
char progress_granularity,
char immediate_load, char dont_cache,
ImlibLoadError * er);
int __imlib_LoadEmbedded(ImlibLoader * l, ImlibImage * im,
const char *file, int load_data);
int __imlib_LoadImageData(ImlibImage * im);
void __imlib_DirtyImage(ImlibImage * im);
void __imlib_FreeImage(ImlibImage * im);
void __imlib_SaveImage(ImlibImage * im, const char *file,
ImlibProgressFunction progress,
char progress_granularity,
ImlibLoadError * er);
DATA32 *__imlib_AllocateData(ImlibImage * im);
void __imlib_FreeData(ImlibImage * im);
void __imlib_ReplaceData(ImlibImage * im, DATA32 * new_data);
void __imlib_LoadProgressSetPass(ImlibImage * im,
int pass, int n_pass);
int __imlib_LoadProgress(ImlibImage * im,
int x, int y, int w, int h);
int __imlib_LoadProgressRows(ImlibImage * im,
int row, int nrows);
#ifdef BUILD_X11
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 sx, int sy,
int sw, int sh, Colormap cm,
char aa, char hiq, char dmask,
DATABIG modification_count);
ImlibImagePixmap *__imlib_FindCachedImagePixmapByID(Display * d, Pixmap p);
void __imlib_AddImagePixmapToCache(ImlibImagePixmap * ip);
void __imlib_RemoveImagePixmapFromCache(ImlibImagePixmap * ip);
void __imlib_CleanupImagePixmapCache(void);
ImlibImagePixmap *__imlib_FindImlibImagePixmapByID(Display * d, Pixmap p);
void __imlib_FreePixmap(Display * d, Pixmap p);
void __imlib_DirtyPixmapsForImage(ImlibImage * im);
#endif
void __imlib_AttachTag(ImlibImage * im, const char *key,
int val, void *data,
ImlibDataDestructorFunction destructor);
void __imlib_FreeTag(ImlibImage * im, ImlibImageTag * t);
void __imlib_FreeAllTags(ImlibImage * im);
void __imlib_SetCacheSize(int size);
int __imlib_GetCacheSize(void);
int __imlib_CurrentCacheSize(void);
#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_FREE_DATA(im) (!((im)->flags & F_DONT_FREE_DATA))
#define SET_FLAG(flags, f) ((flags) |= (f))
#define UNSET_FLAG(flags, f) ((flags) &= (~f))
#define LOAD_FAIL 0
#define LOAD_SUCCESS 1
#define LOAD_BREAK 2
/* 32767 is the maximum pixmap dimension and ensures that
* (w * h * sizeof(DATA32)) won't exceed ULONG_MAX */
#define X_MAX_DIM 32767
/* NB! The image dimensions are sometimes used in (dim << 16) like expressions
* so great care must be taken if ever it is attempted to change this
* condition */
#define IMAGE_DIMENSIONS_OK(w, h) \
( ((w) > 0) && ((h) > 0) && ((w) <= X_MAX_DIM) && ((h) <= X_MAX_DIM) )
#endif