| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#ifndef FONTFORGE_GIMAGE_H |
| 29 |
#define FONTFORGE_GIMAGE_H |
| 30 |
|
| 31 |
#include "basics.h" |
| 32 |
|
| 33 |
typedef uint32_t Color; |
| 34 |
|
| 35 |
#define COLOR_UNKNOWN ((Color) 0xffffffff) |
| 36 |
#define COLOR_TRANSPARENT ((Color) 0xffffffff) |
| 37 |
#define COLOR_DEFAULT ((Color) 0xfffffffe) |
| 38 |
#define COLOR_WARNING ((Color) 0xfffffffd) |
| 39 |
#define COLOR_WHITE ((Color) 0xffffff) |
| 40 |
#define COLOR_CREATE(r,g,b) (((r)<<16) | ((g)<<8) | (b)) |
| 41 |
#define COLOR_ALPHA(col) (((col)>>24)) |
| 42 |
#define COLOR_RED(col) (((col)>>16) & 0xff) |
| 43 |
#define COLOR_GREEN(col) (((col)>>8) & 0xff) |
| 44 |
#define COLOR_BLUE(col) ((col)&0xff) |
| 45 |
|
| 46 |
struct hslrgb { |
| 47 |
double h,s,l,v; |
| 48 |
double r,g,b; |
| 49 |
uint8_t rgb, hsl, hsv; |
| 50 |
}; |
| 51 |
|
| 52 |
struct hslrgba { |
| 53 |
double h,s,l,v; |
| 54 |
double r,g,b; |
| 55 |
uint8_t rgb, hsl, hsv, has_alpha; |
| 56 |
double alpha; |
| 57 |
}; |
| 58 |
|
| 59 |
typedef struct clut { |
| 60 |
int16_t clut_len; |
| 61 |
unsigned int is_grey: 1; |
| 62 |
uint32_t trans_index; |
| 63 |
Color clut[256]; |
| 64 |
} GClut; |
| 65 |
|
| 66 |
#define GCLUT_CLUT_EMPTY \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|
|
| 90 |
struct _GImage { |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
enum image_type image_type: 2; |
| 97 |
int16_t delay; |
| 98 |
int32_t width, height; |
| 99 |
int32_t bytes_per_line; |
| 100 |
uint8_t *data; |
| 101 |
GClut *clut; |
| 102 |
Color trans; |
| 103 |
|
| 104 |
}; |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
typedef struct gimage { |
| 112 |
short list_len; |
| 113 |
union { |
| 114 |
struct _GImage *image; |
| 115 |
struct _GImage **images; |
| 116 |
} u; |
| 117 |
void *userdata; |
| 118 |
} GImage; |
| 119 |
|
| 120 |
enum pastetrans_type { ptt_paste_trans_to_trans, ptt_old_shines_through}; |
| 121 |
|
| 122 |
typedef struct grect { |
| 123 |
int32_t x,y,width,height; |
| 124 |
} GRect; |
| 125 |
|
| 126 |
#define GRECT_EMPTY { 0, 0, 0, 0 } |
| 127 |
|
| 128 |
|
| 129 |
typedef struct gpoint { |
| 130 |
int16_t x,y; |
| 131 |
} GPoint; |
| 132 |
|
| 133 |
#define GPOINT_EMPTY { 0, 0 } |
| 134 |
|
| 135 |
#ifdef __cplusplus |
| 136 |
extern "C" { |
| 137 |
#endif |
| 138 |
|
| 139 |
extern GImage *GImageCreate(enum image_type type, int32_t width, int32_t height); |
| 140 |
extern GImage *_GImage_Create(enum image_type type, int32_t width, int32_t height); |
| 141 |
extern void GImageDestroy(GImage *gi); |
| 142 |
extern GImage *GImageCreateAnimation(GImage **images, int n); |
| 143 |
extern GImage *GImageAddImageBefore(GImage *dest, GImage *src, int pos); |
| 144 |
|
| 145 |
extern Color GImageGetPixelRGBA(GImage *base,int x, int y); |
| 146 |
extern int GImageGetWidth(GImage *); |
| 147 |
extern int GImageGetHeight(GImage *); |
| 148 |
extern void *GImageGetUserData(GImage *img); |
| 149 |
extern void GImageSetUserData(GImage *img,void *userdata); |
| 150 |
extern RevCMap *GClutReverse(GClut *clut,int side_size); |
| 151 |
void GClut_RevCMapFree(RevCMap *rev); |
| 152 |
extern GClut *GImageFindCLUT(GImage *image,GClut *clut,int clutmax); |
| 153 |
extern int GImageGreyClut(GClut *clut); |
| 154 |
extern Color _GImage_ColourFName(char *name); |
| 155 |
extern Color GDrawColorDarken(Color col, int by); |
| 156 |
extern Color GDrawColorBrighten(Color col, int by); |
| 157 |
|
| 158 |
extern int GImageWriteGImage(GImage *gi, char *filename); |
| 159 |
extern int GImageWrite_Bmp(GImage *gi, FILE *fp); |
| 160 |
extern int GImageWriteBmp(GImage *gi, char *filename); |
| 161 |
extern GImage *GImageRead_Bmp(FILE *file); |
| 162 |
extern GImage *GImageReadBmp(char *filename); |
| 163 |
extern int GImageWriteXbm(GImage *gi, char *filename); |
| 164 |
extern GImage *GImageReadXbm(char *filename); |
| 165 |
extern int GImageWriteXpm(GImage *gi, char *filename); |
| 166 |
extern GImage *GImageReadXpm(char *filename); |
| 167 |
extern GImage *GImageReadTiff(char *filename); |
| 168 |
extern GImage *GImageReadJpeg(char *filename); |
| 169 |
extern GImage *GImageRead_Jpeg(FILE *fp); |
| 170 |
extern int GImageWrite_Jpeg(GImage *gi, FILE *outfile, int quality, int progressive); |
| 171 |
extern int GImageWriteJpeg(GImage *gi, char *filename, int quality, int progressive); |
| 172 |
extern GImage *GImageRead_Png(FILE *fp); |
| 173 |
extern GImage *GImageReadPng(char *filename); |
| 174 |
extern GImage *GImageReadPngBuf(char* buf, size_t sz); |
| 175 |
extern int GImageWrite_Png(GImage *gi, FILE *fp, int progressive); |
| 176 |
extern int GImageWritePng(GImage *gi, char *filename, int progressive); |
| 177 |
extern int GImageWritePngBuf(GImage *gi, char** buf, size_t* sz, int compression_level, int progressive); |
| 178 |
extern GImage *GImageReadGif(char *filename); |
| 179 |
extern int GImageWriteGif(GImage *gi,char *filename,int progressive); |
| 180 |
extern GImage *GImageReadRas(char *filename); |
| 181 |
extern GImage *GImageReadRgb(char *filename); |
| 182 |
extern GImage *GImageRead(char *filename); |
| 183 |
|
| 184 |
extern void GImageDrawRect(GImage *img,GRect *r,Color col); |
| 185 |
extern void GImageDrawImage(GImage *dest,GImage *src,GRect *junk,int x, int y); |
| 186 |
extern void GImageBlendOver(GImage *dest,GImage *src,GRect *from,int x, int y); |
| 187 |
|
| 188 |
extern void gRGB2HSL(struct hslrgb *col); |
| 189 |
extern void gHSL2RGB(struct hslrgb *col); |
| 190 |
extern void gRGB2HSV(struct hslrgb *col); |
| 191 |
extern void gHSV2RGB(struct hslrgb *col); |
| 192 |
extern void gColor2Hslrgb(struct hslrgb *col,Color from); |
| 193 |
extern void gColor2Hslrgba(struct hslrgba *col,Color from); |
| 194 |
extern Color gHslrgb2Color(struct hslrgb *col); |
| 195 |
extern Color gHslrgba2Color(struct hslrgba *col); |
| 196 |
|
| 197 |
#ifdef __cplusplus |
| 198 |
} |
| 199 |
#endif |
| 200 |
|
| 201 |
#endif |