3 #include "../gdk_imlib/config.h"
5 #include "../gdk_imlib/gdk_imlib.h"
6 #include "../gdk_imlib/gdk_imlib_private.h"
8 /* Split the ID - damages input */
13 char *p
= strrchr(file
, ':');
25 * Doesn't damage the input
29 g_GetExtension(char *file
)
31 char *p
= strrchr(file
, '.');
41 g_LoadJPEG(FILE * f
, int *w
, int *h
)
43 struct jpeg_decompress_struct cinfo
;
44 struct jpeg_error_mgr jerr
;
45 unsigned char *data
, *line
[16], *ptr
;
48 cinfo
.err
= jpeg_std_error(&jerr
);
49 jpeg_create_decompress(&cinfo
);
50 jpeg_stdio_src(&cinfo
, f
);
51 jpeg_read_header(&cinfo
, TRUE
);
52 cinfo
.do_fancy_upsampling
= FALSE
;
53 cinfo
.do_block_smoothing
= FALSE
;
54 jpeg_start_decompress(&cinfo
);
55 *w
= cinfo
.output_width
;
56 *h
= cinfo
.output_height
;
57 data
= malloc(*w
** h
* 3);
60 jpeg_destroy_decompress(&cinfo
);
65 if (cinfo
.rec_outbuf_height
> 16)
67 fprintf(stderr
, "gdk_imlib ERROR: JPEG uses line buffers > 16. Cannot load.\n");
70 if (cinfo
.output_components
== 3)
72 for (y
= 0; y
< *h
; y
+= cinfo
.rec_outbuf_height
)
74 for (i
= 0; i
< cinfo
.rec_outbuf_height
; i
++)
79 jpeg_read_scanlines(&cinfo
, line
, cinfo
.rec_outbuf_height
);
82 else if (cinfo
.output_components
== 1)
84 for (i
= 0; i
< cinfo
.rec_outbuf_height
; i
++)
86 if ((line
[i
] = malloc(*w
)) == NULL
)
90 for (t
= 0; t
< i
; t
++)
92 jpeg_destroy_decompress(&cinfo
);
96 for (y
= 0; y
< *h
; y
+= cinfo
.rec_outbuf_height
)
98 jpeg_read_scanlines(&cinfo
, line
, cinfo
.rec_outbuf_height
);
99 for (i
= 0; i
< cinfo
.rec_outbuf_height
; i
++)
101 for (x
= 0; x
< *w
; x
++)
109 for (i
= 0; i
< cinfo
.rec_outbuf_height
; i
++)
112 jpeg_finish_decompress(&cinfo
);
113 jpeg_destroy_decompress(&cinfo
);
116 #endif /* HAVE_LIBJPEG */
120 g_LoadPNG(FILE * f
, int *w
, int *h
, int *t
)
124 unsigned char *data
, *ptr
, **lines
, *ptr2
, r
, g
, b
, a
;
125 int i
, x
, y
, transp
, bit_depth
, color_type
, interlace_type
;
126 png_uint_32
*ww
, *hh
;
128 /* Init PNG Reader */
130 png_ptr
= png_create_read_struct(PNG_LIBPNG_VER_STRING
, NULL
, NULL
, NULL
);
134 info_ptr
= png_create_info_struct(png_ptr
);
137 png_destroy_read_struct(&png_ptr
, NULL
, NULL
);
141 if (setjmp(png_ptr
->jmpbuf
))
143 png_destroy_read_struct(&png_ptr
, &info_ptr
, NULL
);
147 if (info_ptr
->color_type
== PNG_COLOR_TYPE_RGB_ALPHA
)
149 png_destroy_read_struct(&png_ptr
, &info_ptr
, NULL
);
152 png_init_io(png_ptr
, f
);
154 png_read_info(png_ptr
, info_ptr
);
155 ww
= (png_uint_32
*) w
;
156 hh
= (png_uint_32
*) h
;
157 png_get_IHDR(png_ptr
, info_ptr
, ww
, hh
, &bit_depth
, &color_type
, &interlace_type
,
159 /* Setup Translators */
160 if (color_type
== PNG_COLOR_TYPE_PALETTE
)
161 png_set_expand(png_ptr
);
162 png_set_strip_16(png_ptr
);
163 png_set_packing(png_ptr
);
164 if (png_get_valid(png_ptr
, info_ptr
, PNG_INFO_tRNS
))
165 png_set_expand(png_ptr
);
166 png_set_filler(png_ptr
, 0xff, PNG_FILLER_AFTER
);
167 *w
= info_ptr
->width
;
168 *h
= info_ptr
->height
;
169 data
= malloc(*w
** h
* 3);
172 png_destroy_read_struct(&png_ptr
, &info_ptr
, NULL
);
175 lines
= (unsigned char **)malloc(*h
* sizeof(unsigned char *));
180 png_destroy_read_struct(&png_ptr
, &info_ptr
, NULL
);
183 for (i
= 0; i
< *h
; i
++)
185 if ((lines
[i
] = malloc(*w
* (sizeof(unsigned char) * 4))) == NULL
)
190 for (n
= 0; n
< i
; n
++)
193 png_destroy_read_struct(&png_ptr
, &info_ptr
, NULL
);
197 png_read_image(png_ptr
, lines
);
198 png_destroy_read_struct(&png_ptr
, &info_ptr
, NULL
);
200 if (color_type
== PNG_COLOR_TYPE_GRAY
)
202 for (y
= 0; y
< *h
; y
++)
205 for (x
= 0; x
< *w
; x
++)
216 for (y
= 0; y
< *h
; y
++)
219 for (x
= 0; x
< *w
; x
++)
234 if ((r
== 255) && (g
== 0) && (b
== 255))
243 for (i
= 0; i
< *h
; i
++)
249 #endif /* HAVE_LIBPNG */
253 g_LoadTIFF(char *f
, int *w
, int *h
, int *t
)
256 unsigned char *data
, *ptr
, r
, g
, b
, a
;
258 uint32 ww
, hh
, *rast
, *tptr
;
266 tif
= TIFFOpen(f
, "r");
270 TIFFGetField(tif
, TIFFTAG_IMAGEWIDTH
, &ww
);
271 TIFFGetField(tif
, TIFFTAG_IMAGELENGTH
, &hh
);
275 rast
= (uint32
*) _TIFFmalloc(npix
* sizeof(uint32
));
282 if (TIFFReadRGBAImage(tif
, ww
, hh
, rast
, 0))
284 data
= (unsigned char *)malloc(*w
** h
* 3);
292 for (y
= 0; y
< *h
; y
++)
295 tptr
+= ((*h
- y
- 1) ** w
);
296 for (x
= 0; x
< *w
; x
++)
312 if ((r
== 255) && (g
== 0) && (b
== 255))
327 #endif /* HAVE_LIBTIFF */
331 g_LoadGIF(char *f
, int *w
, int *h
, int *t
)
333 unsigned char *data
, *ptr
;
337 ColorMapObject
*cmap
;
338 int i
, j
, done
, bg
, csize
, r
, g
, b
;
343 int istransp
, transp
;
347 gif
= DGifOpenFileName(f
);
353 DGifGetRecordType(gif
, &rec
);
354 if ((rec
== IMAGE_DESC_RECORD_TYPE
) && (!done
))
356 DGifGetImageDesc(gif
);
357 *w
= gif
->Image
.Width
;
358 *h
= gif
->Image
.Height
;
359 rows
= malloc(*h
* sizeof(GifRowType
*));
365 data
= malloc(*w
** h
* 3);
372 for (i
= 0; i
< *h
; i
++)
374 for (i
= 0; i
< *h
; i
++)
376 rows
[i
] = malloc(*w
* sizeof(GifPixelType
));
380 for (i
= 0; i
< *h
; i
++)
388 if (gif
->Image
.Interlace
)
390 for (i
= 0; i
< 4; i
++)
392 for (j
= intoffset
[i
]; j
< *h
; j
+= intjump
[i
])
393 DGifGetLine(gif
, rows
[j
], *w
);
398 for (i
= 0; i
< *h
; i
++)
399 DGifGetLine(gif
, rows
[i
], *w
);
403 else if (rec
== EXTENSION_RECORD_TYPE
)
408 DGifGetExtension(gif
, &ext_code
, &ext
);
414 transp
= (int)ext
[4];
419 DGifGetExtensionNext(gif
, &ext
);
424 while (rec
!= TERMINATE_RECORD_TYPE
);
425 bg
= gif
->SBackGroundColor
;
426 cmap
= (gif
->Image
.ColorMap
? gif
->Image
.ColorMap
: gif
->SColorMap
);
427 csize
= cmap
->ColorCount
;
431 for (i
= 0; i
< *h
; i
++)
433 for (j
= 0; j
< *w
; j
++)
435 r
= cmap
->Colors
[rows
[i
][j
]].Red
;
436 g
= cmap
->Colors
[rows
[i
][j
]].Green
;
437 b
= cmap
->Colors
[rows
[i
][j
]].Blue
;
446 for (i
= 0; i
< *h
; i
++)
448 for (j
= 0; j
< *w
; j
++)
450 if (rows
[i
][j
] == transp
)
458 r
= cmap
->Colors
[rows
[i
][j
]].Red
;
459 g
= cmap
->Colors
[rows
[i
][j
]].Green
;
460 b
= cmap
->Colors
[rows
[i
][j
]].Blue
;
461 if (r
== 255 && g
== 0 && b
== 255)
471 for (i
= 0; i
< *h
; i
++)
478 #endif /* HAVE_LIBGIF */
481 g_LoadXPM(char *f
, int *w
, int *h
, int *t
)
484 unsigned char *data
, *ptr
;
485 int pc
, c
, i
, j
, k
, ncolors
, cpp
, comment
, transp
, quote
,
486 context
, len
, token
, done
;
487 char line
[65536], s
[65536], tok
[65536], col
[65536];
496 int lookup
[128][128];
501 file
= fopen(f
, "r");
523 if (pc
== '/' && c
== '*')
525 else if (pc
== '*' && c
== '/' && comment
)
530 if (!quote
&& c
== '"')
535 else if (quote
&& c
== '"')
542 sscanf(line
, "%i %i %i %i", w
, h
, &ncolors
, &cpp
);
545 fprintf(stderr
, "gdk_imlib ERROR: XPM files with characters per pixel > 7 not supported\n");
550 fprintf(stderr
, "gdk_imlib ERROR: Image width > 32767 pixels for file\n");
555 fprintf(stderr
, "gdk_imlib ERROR: Image height > 32767 pixels for file\n");
558 cmap
= malloc(sizeof(struct _cmap
) * ncolors
);
562 data
= malloc(*w
** h
* 3);
572 else if (context
== 1)
584 strncpy(cmap
[j
].str
, line
, cpp
);
585 cmap
[j
].str
[cpp
] = 0;
588 for (k
= cpp
; k
< len
; k
++)
593 sscanf(&line
[k
], "%65535s", s
);
596 if ((!strcmp(s
, "m")) || (!strcmp(s
, "s")) ||
597 (!strcmp(s
, "g4")) || (!strcmp(s
, "g")) ||
598 (!strcmp(s
, "c")) || (k
>= len
))
608 if (!strcasecmp(col
, "none"))
615 if ((cmap
[j
].r
< 0) ||
618 XParseColor(id
->x
.disp
,
621 cmap
[j
].r
= xcol
.red
>> 8;
622 cmap
[j
].g
= xcol
.green
>> 8;
623 cmap
[j
].b
= xcol
.blue
>> 8;
624 if ((cmap
[j
].r
== 255) &&
647 for (i
= 0; i
< ncolors
; i
++)
648 lookup
[cmap
[i
].str
[0]][cmap
[i
].str
[1]] = i
;
650 for (i
= 0; i
< ncolors
; i
++)
651 lookup
[cmap
[i
].str
[0]][cmap
[i
].str
[1]] = i
;
661 /* Chars per pixel = 0? well u never know */
667 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
670 if (cmap
[lookup
[col
[0]][0]].transp
)
678 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][0]].r
;
679 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][0]].g
;
680 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][0]].b
;
686 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
689 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][0]].r
;
690 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][0]].g
;
691 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][0]].b
;
699 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
703 if (cmap
[lookup
[col
[0]][col
[1]]].transp
)
711 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][col
[1]]].r
;
712 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][col
[1]]].g
;
713 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][col
[1]]].b
;
719 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
723 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][col
[1]]].r
;
724 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][col
[1]]].g
;
725 *ptr
++ = (unsigned char)cmap
[lookup
[col
[0]][col
[1]]].b
;
733 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
735 for (j
= 0; j
< cpp
; j
++, i
++)
741 for (j
= 0; j
< ncolors
; j
++)
743 if (!strcmp(col
, cmap
[j
].str
))
753 *ptr
++ = (unsigned char)cmap
[j
].r
;
754 *ptr
++ = (unsigned char)cmap
[j
].g
;
755 *ptr
++ = (unsigned char)cmap
[j
].b
;
764 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
766 for (j
= 0; j
< cpp
; j
++, i
++)
772 for (j
= 0; j
< ncolors
; j
++)
774 if (!strcmp(col
, cmap
[j
].str
))
776 *ptr
++ = (unsigned char)cmap
[j
].r
;
777 *ptr
++ = (unsigned char)cmap
[j
].g
;
778 *ptr
++ = (unsigned char)cmap
[j
].b
;
788 /* Scan in line from XPM file (limit line length 65k) */
791 if ((!comment
) && (quote
) && (c
!= '"'))
796 if ((ptr
) && ((ptr
- data
) >= *w
** h
* 3))
809 g_LoadPPM(FILE * f
, int *w
, int *h
)
820 s
[strlen(s
) - 1] = 0;
822 if (!strcmp(s
, "P6"))
824 else if (!strcmp(s
, "P5"))
833 if (fgets(s
, 256, f
) == NULL
)
836 s
[strlen(s
) - 1] = 0;
840 sscanf(s
, "%i %i", w
, h
);
845 fprintf(stderr
, "gdk_imlib ERROR: Image width > 32767 pixels for file\n");
850 fprintf(stderr
, "gdk_imlib ERROR: Image height > 32767 pixels for file\n");
854 sscanf(s
, "%i", &scale
);
855 s
[strlen(s
) - 1] = 0;
856 ptr
= (unsigned char *)malloc(a
* b
* 3);
859 fprintf(stderr
, "gdk_imlib ERROR: Cannot allocate RAM for RGB data in file");
864 if (!fread(ptr
, a
* b
* 3, 1, f
))
874 while ((fread(&chr
, 1, 1, f
)) && (a
< b
))
899 else if (scale
<= 15)
901 else if (scale
<= 31)
903 else if (scale
<= 63)
911 while (po
< (ptr
+ (*w
** h
* 3)))
928 f
= fopen(file
, "rb");
933 if (!strcmp("P6\n", buf
))
935 if (!strcmp("P5\n", buf
))
944 unsigned char buf
[8];
946 f
= fopen(file
, "rb");
951 if ((buf
[0] == 0xff) && (buf
[1] == 0xd8))
961 unsigned char buf
[8];
963 f
= fopen(file
, "rb");
968 return (int)png_check_sig(buf
, 8);
980 f
= fopen(file
, "rb");
985 if ((buf
[0] == 'M') && (buf
[1] == 'M') && (buf
[2] == 0x00) && (buf
[3] == 0x2a))
987 if ((buf
[0] == 'I') && (buf
[1] == 'I') && (buf
[2] == 0x2a) && (buf
[3] == 0x00))
998 f
= fopen(file
, "rb");
1001 fread(buf
, 1, 4, f
);
1003 if (!strncmp("EIM ", buf
, 4))
1014 f
= fopen(file
, "rb");
1017 fread(buf
, 1, 4, f
);
1020 if (!strcmp("GIF8", buf
))
1031 f
= fopen(file
, "rb");
1034 fread(buf
, 1, 9, f
);
1037 if (!strcmp("/* XPM */", buf
))
1043 gdk_imlib_load_image(char *file
)
1047 unsigned char *data
;
1066 if (id
->cache
.on_image
)
1067 if ((im
= gfind_image(file
)))
1070 strncpy(fil
, file
, sizeof(fil
));
1071 iden
= g_SplitID(fil
);
1072 e
= g_GetExtension(fil
);
1079 else if (gisjpeg(fil
))
1089 else if (gistiff(fil
))
1099 else if (giseim(fil
))
1105 else if (gisxpm(fil
))
1110 else if (gispng(fil
))
1120 else if (gisgif(fil
))
1130 if (needs_conv
&& id
->fallback
)
1132 p
= open_helper("%C/convert %s pnm:-", fil
, "rb");
1134 else if ((fmt
== 2) || (fmt
== 1) || (fmt
== 0))
1135 p
= fopen(fil
, "rb");
1143 data
= g_LoadXPM(fil
, &w
, &h
, &trans
);
1147 data
= g_LoadGIF(fil
, &w
, &h
, &trans
);
1152 data
= g_LoadTIFF(fil
, &w
, &h
, &trans
);
1158 data
= g_LoadJPEG(p
, &w
, &h
);
1164 data
= g_LoadPNG(p
, &w
, &h
, &trans
);
1169 data
= g_LoadPPM(p
, &w
, &h
);
1174 if (p
&& !needs_conv
)
1179 if ((!data
) && (id
->fallback
))
1181 p
= open_helper("%C/convert %s pnm:-", fil
, "rb");
1184 data
= g_LoadPPM(p
, &w
, &h
);
1188 if ((!eim
) && (!data
) && (id
->fallback
))
1190 if (!strcasecmp(s
, "jpeg"))
1191 strcpy(cmd
, "%J %s");
1192 else if (!strcasecmp(s
, "jpg"))
1193 strcpy(cmd
, "%J %s");
1194 else if (!strcasecmp(s
, "bmp"))
1195 strcpy(cmd
, "%P/bmptoppm %s");
1196 else if (!strcasecmp(s
, "ilbm"))
1197 strcpy(cmd
, "%P/ilbmtoppm %s");
1198 else if (!strcasecmp(s
, "ilb"))
1199 strcpy(cmd
, "%P/ilbmtoppm %s");
1200 else if (!strcasecmp(s
, "iff"))
1201 strcpy(cmd
, "%P/ilbmtoppm %s");
1202 else if (!strcasecmp(s
, "img"))
1203 strcpy(cmd
, "%P/imgtoppm %s");
1204 else if (!strcasecmp(s
, "mtv"))
1205 strcpy(cmd
, "%P/mtvtoppm %s");
1206 else if (!strcasecmp(s
, "pcx"))
1207 strcpy(cmd
, "%P/pcxtoppm %s");
1208 else if (!strcasecmp(s
, "pgm"))
1209 strcpy(cmd
, "%P/pgmtoppm rgb:ffff/ffff/ffff %s");
1210 else if (!strcasecmp(s
, "pi1"))
1211 strcpy(cmd
, "%P/pi1toppm %s");
1212 else if (!strcasecmp(s
, "pict"))
1213 strcpy(cmd
, "%P/picttoppm %s");
1214 else if (!strcasecmp(s
, "pic"))
1215 strcpy(cmd
, "%P/picttoppm %s");
1216 else if (!strcasecmp(s
, "pj"))
1217 strcpy(cmd
, "%P/pjtoppm %s");
1218 else if (!strcasecmp(s
, "qrt"))
1219 strcpy(cmd
, "%P/qrttoppm %s");
1220 else if (!strcasecmp(s
, "sld"))
1221 strcpy(cmd
, "%P/sldtoppm %s");
1222 else if (!strcasecmp(s
, "spc"))
1223 strcpy(cmd
, "%P/spctoppm %s");
1224 else if (!strcasecmp(s
, "spu"))
1225 strcpy(cmd
, "%P/sputoppm %s");
1226 else if (!strcasecmp(s
, "tga"))
1227 strcpy(cmd
, "%P/tgatoppm %s");
1228 else if (!strcasecmp(s
, "xim"))
1229 strcpy(cmd
, "%P/ximtoppm %s");
1230 else if (!strcasecmp(s
, "xpm"))
1231 strcpy(cmd
, "%P/xpmtoppm %s");
1232 else if (!strcasecmp(s
, "gif"))
1233 strcpy(cmd
, "%P/giftopnm %s");
1234 else if (!strcasecmp(s
, "rast"))
1235 strcpy(cmd
, "%P/rasttopnm %s");
1236 else if (!strcasecmp(s
, "ras"))
1237 strcpy(cmd
, "%P/rasttopnm %s");
1238 else if (!strcasecmp(s
, "sgi"))
1239 strcpy(cmd
, "%P/sgitopnm %s");
1240 else if (!strcasecmp(s
, "sir"))
1241 strcpy(cmd
, "%P/sirtopnm %s");
1242 else if (!strcasecmp(s
, "tiff"))
1243 strcpy(cmd
, "%P/tifftopnm %s");
1244 else if (!strcasecmp(s
, "tif"))
1245 strcpy(cmd
, "%P/tifftopnm %s");
1246 else if (!strcasecmp(s
, "wxd"))
1247 strcpy(cmd
, "%P/wxdtopnm %s");
1248 else if (!strcasecmp(s
, "zeiss"))
1249 strcpy(cmd
, "%P/zeisstopnm -ppm %s");
1250 else if (!strcasecmp(s
, "zei"))
1251 strcpy(cmd
, "%P/zeisstopnm -ppm %s");
1252 else if (!strcasecmp(s
, "zis"))
1253 strcpy(cmd
, "%P/zeisstopnm -ppm %s");
1255 strcpy(cmd
, "%P/anytopnm %s");
1256 p
= open_helper(cmd
, fil
, "rb");
1259 data
= g_LoadPPM(p
, &w
, &h
);
1266 fprintf(stderr
, "gdk_imlib ERROR: Cannot load image: %s\nAll fallbacks failed.\n", fil
);
1270 im
= (GdkImlibImage
*) malloc(sizeof(GdkImlibImage
));
1273 fprintf(stderr
, "gdk_imlib ERROR: Cannot allocate RAM for image data\n");
1278 im
->alpha_data
= NULL
;
1281 im
->shape_color
.r
= 255;
1282 im
->shape_color
.g
= 0;
1283 im
->shape_color
.b
= 255;
1287 im
->shape_color
.r
= -1;
1288 im
->shape_color
.g
= -1;
1289 im
->shape_color
.b
= -1;
1291 im
->border
.left
= 0;
1292 im
->border
.right
= 0;
1294 im
->border
.bottom
= 0;
1296 im
->rgb_data
= data
;
1300 im
->shape_mask
= NULL
;
1303 char s1
[256], s2
[256];
1308 /* Load Native-as-can-be EIM format (Enlightenment IMlib format) */
1309 p
= fopen(fil
, "r");
1316 if ((s
[0] != 'E') && (s
[1] != 'I') && (s
[2] != 'M') && (s
[3] != ' '))
1322 sscanf(s
, "%256s %i", s1
, &num
);
1329 while (fgets(s
, 4096, p
))
1331 sscanf(s
, "%256s", s1
);
1332 if (!strcmp("IMAGE", s1
))
1334 sscanf(s
, "%256s %i %256s %i %i %i %i %i %i %i %i %i", s1
, &size
, s2
, &w
, &h
, &r
, &g
, &b
, &bl
, &br
, &bt
, &bb
);
1337 else if (!strcmp(iden
, s2
))
1340 fseek(p
, size
, SEEK_CUR
);
1343 im
->rgb_data
= malloc(w
* h
* 3);
1350 im
->shape_color
.r
= r
;
1351 im
->shape_color
.g
= g
;
1352 im
->shape_color
.b
= b
;
1355 im
->border
.left
= bl
;
1356 im
->border
.right
= br
;
1357 im
->border
.top
= bt
;
1358 im
->border
.bottom
= bb
;
1359 fread(im
->rgb_data
, 1, w
* h
* 3, p
);
1363 strncat(fil
, ":", sizeof(fil
) - strlen(fil
));
1364 strncat(fil
, iden
, sizeof(fil
) - strlen(fil
));
1367 im
->mod
.gamma
= id
->mod
.gamma
;
1368 im
->mod
.brightness
= id
->mod
.brightness
;
1369 im
->mod
.contrast
= id
->mod
.contrast
;
1370 im
->rmod
.gamma
= id
->rmod
.gamma
;
1371 im
->rmod
.brightness
= id
->rmod
.brightness
;
1372 im
->rmod
.contrast
= id
->rmod
.contrast
;
1373 im
->gmod
.gamma
= id
->gmod
.gamma
;
1374 im
->gmod
.brightness
= id
->gmod
.brightness
;
1375 im
->gmod
.contrast
= id
->gmod
.contrast
;
1376 im
->bmod
.gamma
= id
->bmod
.gamma
;
1377 im
->bmod
.brightness
= id
->bmod
.brightness
;
1378 im
->bmod
.contrast
= id
->bmod
.contrast
;
1379 im
->filename
= malloc(strlen(file
) + 1);
1381 strcpy(im
->filename
, file
);
1382 if ((id
->cache
.on_image
&& im
))
1383 gadd_image(im
, fil
);
1384 gcalc_map_tables(im
);
1389 gdk_imlib_save_image_to_eim(GdkImlibImage
* im
, char *file
)
1396 if ((!id
) || (!im
) || (!file
))
1398 strncpy(fil
, file
, sizeof(fil
));
1399 iden
= g_SplitID(fil
);
1402 f
= fopen(fil
, "w");
1406 size
= im
->rgb_width
* im
->rgb_height
* 3;
1407 fprintf(f
, "EIM 1\n");
1408 fprintf(f
, "IMAGE %i %s %i %i %i %i %i %i %i %i %i\n",
1420 if (fwrite(im
->rgb_data
, size
, 1, f
) != 1)
1430 gdk_imlib_add_image_to_eim(GdkImlibImage
* im
, char *file
)
1437 if ((!id
) || (!im
) || (!file
))
1439 strncpy(fil
, file
, sizeof(fil
));
1441 iden
= g_SplitID(file
);
1443 strcpy(iden
, "default");
1445 f
= fopen(fil
, "a");
1449 size
= im
->rgb_width
* im
->rgb_height
* 3;
1450 fprintf(f
, "IMAGE %i %s %i %i %i %i %i %i %i %i %i\n",
1463 if (fwrite(im
->rgb_data
, size
, 1, f
) != 1)
1473 gdk_imlib_save_image_to_ppm(GdkImlibImage
* im
, char *file
)
1477 if ((!id
) || (!im
) || (!file
))
1479 f
= fopen(file
, "w");
1484 fprintf(f
, "%i %i\n255\n",
1487 if (fwrite(im
->rgb_data
, im
->rgb_width
* im
->rgb_height
* 3, 1, f
) != 1)