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];
505 file
= fopen(f
, "r");
527 if (pc
== '/' && c
== '*')
529 else if (pc
== '*' && c
== '/' && comment
)
534 if (!quote
&& c
== '"')
539 else if (quote
&& c
== '"')
546 sscanf(line
, "%i %i %i %i", w
, h
, &ncolors
, &cpp
);
549 fprintf(stderr
, "gdk_imlib ERROR: XPM files with characters per pixel > 7 not supported\n");
554 fprintf(stderr
, "gdk_imlib ERROR: Image width > 32767 pixels for file\n");
559 fprintf(stderr
, "gdk_imlib ERROR: Image height > 32767 pixels for file\n");
562 cmap
= malloc(sizeof(struct _cmap
) * ncolors
);
566 data
= malloc(*w
** h
* 3);
576 else if (context
== 1)
581 /* int colptr = 0; not used */
588 strncpy(cmap
[j
].str
, line
, cpp
);
589 cmap
[j
].str
[cpp
] = 0;
592 for (k
= cpp
; k
< len
; k
++)
597 sscanf(&line
[k
], "%65535s", s
);
600 if ((!strcmp(s
, "m")) || (!strcmp(s
, "s")) ||
601 (!strcmp(s
, "g4")) || (!strcmp(s
, "g")) ||
602 (!strcmp(s
, "c")) || (k
>= len
))
612 if (!strcasecmp(col
, "none"))
619 if ((cmap
[j
].r
< 0) ||
622 XParseColor(id
->x
.disp
,
625 cmap
[j
].r
= xcol
.red
>> 8;
626 cmap
[j
].g
= xcol
.green
>> 8;
627 cmap
[j
].b
= xcol
.blue
>> 8;
628 if ((cmap
[j
].r
== 255) &&
651 for (i
= 0; i
< ncolors
; i
++)
652 lookup
[(int)cmap
[i
].str
[0]][(int)cmap
[i
].str
[1]] = i
;
654 for (i
= 0; i
< ncolors
; i
++)
655 lookup
[(int)cmap
[i
].str
[0]][(int)cmap
[i
].str
[1]] = i
;
665 /* Chars per pixel = 0? well u never know */
671 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
674 if (cmap
[lookup
[(int)col
[0]][0]].transp
)
682 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][0]].r
;
683 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][0]].g
;
684 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][0]].b
;
690 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
693 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][0]].r
;
694 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][0]].g
;
695 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][0]].b
;
703 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
707 if (cmap
[lookup
[(int)col
[0]][(int)col
[1]]].transp
)
715 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][(int)col
[1]]].r
;
716 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][(int)col
[1]]].g
;
717 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][(int)col
[1]]].b
;
723 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
727 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][(int)col
[1]]].r
;
728 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][(int)col
[1]]].g
;
729 *ptr
++ = (unsigned char)cmap
[lookup
[(int)col
[0]][(int)col
[1]]].b
;
737 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
739 for (j
= 0; j
< cpp
; j
++, i
++)
745 for (j
= 0; j
< ncolors
; j
++)
747 if (!strcmp(col
, cmap
[j
].str
))
757 *ptr
++ = (unsigned char)cmap
[j
].r
;
758 *ptr
++ = (unsigned char)cmap
[j
].g
;
759 *ptr
++ = (unsigned char)cmap
[j
].b
;
768 for (i
= 0; ((i
< 65536) && (line
[i
])); i
++)
770 for (j
= 0; j
< cpp
; j
++, i
++)
776 for (j
= 0; j
< ncolors
; j
++)
778 if (!strcmp(col
, cmap
[j
].str
))
780 *ptr
++ = (unsigned char)cmap
[j
].r
;
781 *ptr
++ = (unsigned char)cmap
[j
].g
;
782 *ptr
++ = (unsigned char)cmap
[j
].b
;
792 /* Scan in line from XPM file (limit line length 65k) */
795 if ((!comment
) && (quote
) && (c
!= '"'))
800 if ((ptr
) && ((ptr
- data
) >= *w
** h
* 3))
813 g_LoadPPM(FILE * f
, int *w
, int *h
)
824 s
[strlen(s
) - 1] = 0;
826 if (!strcmp(s
, "P6"))
828 else if (!strcmp(s
, "P5"))
837 if (fgets(s
, 256, f
) == NULL
)
840 s
[strlen(s
) - 1] = 0;
844 sscanf(s
, "%i %i", w
, h
);
849 fprintf(stderr
, "gdk_imlib ERROR: Image width > 32767 pixels for file\n");
854 fprintf(stderr
, "gdk_imlib ERROR: Image height > 32767 pixels for file\n");
858 sscanf(s
, "%i", &scale
);
859 s
[strlen(s
) - 1] = 0;
860 ptr
= (unsigned char *)malloc(a
* b
* 3);
863 fprintf(stderr
, "gdk_imlib ERROR: Cannot allocate RAM for RGB data in file");
868 if (!fread(ptr
, a
* b
* 3, 1, f
))
878 while ((fread(&chr
, 1, 1, f
)) && (a
< b
))
903 else if (scale
<= 15)
905 else if (scale
<= 31)
907 else if (scale
<= 63)
915 while (po
< (ptr
+ (*w
** h
* 3)))
932 f
= fopen(file
, "rb");
937 if (!strcmp("P6\n", buf
))
939 if (!strcmp("P5\n", buf
))
948 unsigned char buf
[8];
950 f
= fopen(file
, "rb");
955 if ((buf
[0] == 0xff) && (buf
[1] == 0xd8))
965 unsigned char buf
[8];
967 f
= fopen(file
, "rb");
972 return (int)png_check_sig(buf
, 8);
984 f
= fopen(file
, "rb");
989 if ((buf
[0] == 'M') && (buf
[1] == 'M') && (buf
[2] == 0x00) && (buf
[3] == 0x2a))
991 if ((buf
[0] == 'I') && (buf
[1] == 'I') && (buf
[2] == 0x2a) && (buf
[3] == 0x00))
1002 f
= fopen(file
, "rb");
1005 fread(buf
, 1, 4, f
);
1007 if (!strncmp("EIM ", buf
, 4))
1018 f
= fopen(file
, "rb");
1021 fread(buf
, 1, 4, f
);
1024 if (!strcmp("GIF8", buf
))
1035 f
= fopen(file
, "rb");
1038 fread(buf
, 1, 9, f
);
1041 if (!strcmp("/* XPM */", buf
))
1047 gdk_imlib_load_image(char *file
)
1051 unsigned char *data
;
1070 if (id
->cache
.on_image
)
1071 if ((im
= gfind_image(file
)))
1074 strncpy(fil
, file
, sizeof(fil
));
1075 iden
= g_SplitID(fil
);
1076 e
= g_GetExtension(fil
);
1083 else if (gisjpeg(fil
))
1093 else if (gistiff(fil
))
1103 else if (giseim(fil
))
1109 else if (gisxpm(fil
))
1114 else if (gispng(fil
))
1124 else if (gisgif(fil
))
1134 if (needs_conv
&& id
->fallback
)
1136 p
= open_helper("%C/convert %s pnm:-", fil
, "rb");
1138 else if ((fmt
== 2) || (fmt
== 1) || (fmt
== 0))
1139 p
= fopen(fil
, "rb");
1147 data
= g_LoadXPM(fil
, &w
, &h
, &trans
);
1151 data
= g_LoadGIF(fil
, &w
, &h
, &trans
);
1156 data
= g_LoadTIFF(fil
, &w
, &h
, &trans
);
1162 data
= g_LoadJPEG(p
, &w
, &h
);
1168 data
= g_LoadPNG(p
, &w
, &h
, &trans
);
1173 data
= g_LoadPPM(p
, &w
, &h
);
1178 if (p
&& !needs_conv
)
1183 if ((!data
) && (id
->fallback
))
1185 p
= open_helper("%C/convert %s pnm:-", fil
, "rb");
1188 data
= g_LoadPPM(p
, &w
, &h
);
1192 if ((!eim
) && (!data
) && (id
->fallback
))
1194 if (!strcasecmp(s
, "jpeg"))
1195 strcpy(cmd
, "%J %s");
1196 else if (!strcasecmp(s
, "jpg"))
1197 strcpy(cmd
, "%J %s");
1198 else if (!strcasecmp(s
, "bmp"))
1199 strcpy(cmd
, "%P/bmptoppm %s");
1200 else if (!strcasecmp(s
, "ilbm"))
1201 strcpy(cmd
, "%P/ilbmtoppm %s");
1202 else if (!strcasecmp(s
, "ilb"))
1203 strcpy(cmd
, "%P/ilbmtoppm %s");
1204 else if (!strcasecmp(s
, "iff"))
1205 strcpy(cmd
, "%P/ilbmtoppm %s");
1206 else if (!strcasecmp(s
, "img"))
1207 strcpy(cmd
, "%P/imgtoppm %s");
1208 else if (!strcasecmp(s
, "mtv"))
1209 strcpy(cmd
, "%P/mtvtoppm %s");
1210 else if (!strcasecmp(s
, "pcx"))
1211 strcpy(cmd
, "%P/pcxtoppm %s");
1212 else if (!strcasecmp(s
, "pgm"))
1213 strcpy(cmd
, "%P/pgmtoppm rgb:ffff/ffff/ffff %s");
1214 else if (!strcasecmp(s
, "pi1"))
1215 strcpy(cmd
, "%P/pi1toppm %s");
1216 else if (!strcasecmp(s
, "pict"))
1217 strcpy(cmd
, "%P/picttoppm %s");
1218 else if (!strcasecmp(s
, "pic"))
1219 strcpy(cmd
, "%P/picttoppm %s");
1220 else if (!strcasecmp(s
, "pj"))
1221 strcpy(cmd
, "%P/pjtoppm %s");
1222 else if (!strcasecmp(s
, "qrt"))
1223 strcpy(cmd
, "%P/qrttoppm %s");
1224 else if (!strcasecmp(s
, "sld"))
1225 strcpy(cmd
, "%P/sldtoppm %s");
1226 else if (!strcasecmp(s
, "spc"))
1227 strcpy(cmd
, "%P/spctoppm %s");
1228 else if (!strcasecmp(s
, "spu"))
1229 strcpy(cmd
, "%P/sputoppm %s");
1230 else if (!strcasecmp(s
, "tga"))
1231 strcpy(cmd
, "%P/tgatoppm %s");
1232 else if (!strcasecmp(s
, "xim"))
1233 strcpy(cmd
, "%P/ximtoppm %s");
1234 else if (!strcasecmp(s
, "xpm"))
1235 strcpy(cmd
, "%P/xpmtoppm %s");
1236 else if (!strcasecmp(s
, "gif"))
1237 strcpy(cmd
, "%P/giftopnm %s");
1238 else if (!strcasecmp(s
, "rast"))
1239 strcpy(cmd
, "%P/rasttopnm %s");
1240 else if (!strcasecmp(s
, "ras"))
1241 strcpy(cmd
, "%P/rasttopnm %s");
1242 else if (!strcasecmp(s
, "sgi"))
1243 strcpy(cmd
, "%P/sgitopnm %s");
1244 else if (!strcasecmp(s
, "sir"))
1245 strcpy(cmd
, "%P/sirtopnm %s");
1246 else if (!strcasecmp(s
, "tiff"))
1247 strcpy(cmd
, "%P/tifftopnm %s");
1248 else if (!strcasecmp(s
, "tif"))
1249 strcpy(cmd
, "%P/tifftopnm %s");
1250 else if (!strcasecmp(s
, "wxd"))
1251 strcpy(cmd
, "%P/wxdtopnm %s");
1252 else if (!strcasecmp(s
, "zeiss"))
1253 strcpy(cmd
, "%P/zeisstopnm -ppm %s");
1254 else if (!strcasecmp(s
, "zei"))
1255 strcpy(cmd
, "%P/zeisstopnm -ppm %s");
1256 else if (!strcasecmp(s
, "zis"))
1257 strcpy(cmd
, "%P/zeisstopnm -ppm %s");
1259 strcpy(cmd
, "%P/anytopnm %s");
1260 p
= open_helper(cmd
, fil
, "rb");
1263 data
= g_LoadPPM(p
, &w
, &h
);
1270 fprintf(stderr
, "gdk_imlib ERROR: Cannot load image: %s\nAll fallbacks failed.\n", fil
);
1274 im
= (GdkImlibImage
*) malloc(sizeof(GdkImlibImage
));
1277 fprintf(stderr
, "gdk_imlib ERROR: Cannot allocate RAM for image data\n");
1282 im
->alpha_data
= NULL
;
1285 im
->shape_color
.r
= 255;
1286 im
->shape_color
.g
= 0;
1287 im
->shape_color
.b
= 255;
1291 im
->shape_color
.r
= -1;
1292 im
->shape_color
.g
= -1;
1293 im
->shape_color
.b
= -1;
1295 im
->border
.left
= 0;
1296 im
->border
.right
= 0;
1298 im
->border
.bottom
= 0;
1300 im
->rgb_data
= data
;
1304 im
->shape_mask
= NULL
;
1307 char s1
[256], s2
[256];
1312 /* Load Native-as-can-be EIM format (Enlightenment IMlib format) */
1313 p
= fopen(fil
, "r");
1320 if ((s
[0] != 'E') && (s
[1] != 'I') && (s
[2] != 'M') && (s
[3] != ' '))
1326 sscanf(s
, "%256s %i", s1
, &num
);
1333 while (fgets(s
, 4096, p
))
1335 sscanf(s
, "%256s", s1
);
1336 if (!strcmp("IMAGE", s1
))
1338 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
);
1341 else if (!strcmp(iden
, s2
))
1344 fseek(p
, size
, SEEK_CUR
);
1347 im
->rgb_data
= malloc(w
* h
* 3);
1354 im
->shape_color
.r
= r
;
1355 im
->shape_color
.g
= g
;
1356 im
->shape_color
.b
= b
;
1359 im
->border
.left
= bl
;
1360 im
->border
.right
= br
;
1361 im
->border
.top
= bt
;
1362 im
->border
.bottom
= bb
;
1363 fread(im
->rgb_data
, 1, w
* h
* 3, p
);
1367 strncat(fil
, ":", sizeof(fil
) - strlen(fil
));
1368 strncat(fil
, iden
, sizeof(fil
) - strlen(fil
));
1371 im
->mod
.gamma
= id
->mod
.gamma
;
1372 im
->mod
.brightness
= id
->mod
.brightness
;
1373 im
->mod
.contrast
= id
->mod
.contrast
;
1374 im
->rmod
.gamma
= id
->rmod
.gamma
;
1375 im
->rmod
.brightness
= id
->rmod
.brightness
;
1376 im
->rmod
.contrast
= id
->rmod
.contrast
;
1377 im
->gmod
.gamma
= id
->gmod
.gamma
;
1378 im
->gmod
.brightness
= id
->gmod
.brightness
;
1379 im
->gmod
.contrast
= id
->gmod
.contrast
;
1380 im
->bmod
.gamma
= id
->bmod
.gamma
;
1381 im
->bmod
.brightness
= id
->bmod
.brightness
;
1382 im
->bmod
.contrast
= id
->bmod
.contrast
;
1383 im
->filename
= malloc(strlen(file
) + 1);
1385 strcpy(im
->filename
, file
);
1386 if ((id
->cache
.on_image
&& im
))
1387 gadd_image(im
, fil
);
1388 gcalc_map_tables(im
);
1393 gdk_imlib_save_image_to_eim(GdkImlibImage
* im
, char *file
)
1400 if ((!id
) || (!im
) || (!file
))
1402 strncpy(fil
, file
, sizeof(fil
));
1403 iden
= g_SplitID(fil
);
1406 f
= fopen(fil
, "w");
1410 size
= im
->rgb_width
* im
->rgb_height
* 3;
1411 fprintf(f
, "EIM 1\n");
1412 fprintf(f
, "IMAGE %i %s %i %i %i %i %i %i %i %i %i\n",
1424 if (fwrite(im
->rgb_data
, size
, 1, f
) != 1)
1434 gdk_imlib_add_image_to_eim(GdkImlibImage
* im
, char *file
)
1441 if ((!id
) || (!im
) || (!file
))
1443 strncpy(fil
, file
, sizeof(fil
));
1445 iden
= g_SplitID(file
);
1447 strcpy(iden
, "default");
1449 f
= fopen(fil
, "a");
1453 size
= im
->rgb_width
* im
->rgb_height
* 3;
1454 fprintf(f
, "IMAGE %i %s %i %i %i %i %i %i %i %i %i\n",
1467 if (fwrite(im
->rgb_data
, size
, 1, f
) != 1)
1477 gdk_imlib_save_image_to_ppm(GdkImlibImage
* im
, char *file
)
1481 if ((!id
) || (!im
) || (!file
))
1483 f
= fopen(file
, "w");
1488 fprintf(f
, "%i %i\n255\n",
1491 if (fwrite(im
->rgb_data
, im
->rgb_width
* im
->rgb_height
* 3, 1, f
) != 1)