forked from old/legacy-imlib2
parent
4c55d2c3f6
commit
41c3a967d0
|
@ -45,19 +45,18 @@ main(int argc, char **argv)
|
||||||
* First tests to determine which rendering task to perform
|
* First tests to determine which rendering task to perform
|
||||||
*/
|
*/
|
||||||
if (!display_name)
|
if (!display_name)
|
||||||
display_name = ":0";
|
display_name = ":0";
|
||||||
disp = XOpenDisplay(display_name);
|
disp = XOpenDisplay(display_name);
|
||||||
if (!disp)
|
if (!disp)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
vis = DefaultVisual(disp, DefaultScreen(disp));
|
vis = DefaultVisual(disp, DefaultScreen(disp));
|
||||||
depth = DefaultDepth(disp, DefaultScreen(disp));
|
depth = DefaultDepth(disp, DefaultScreen(disp));
|
||||||
cm = DefaultColormap(disp, DefaultScreen(disp));
|
cm = DefaultColormap(disp, DefaultScreen(disp));
|
||||||
win =
|
win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100,
|
||||||
XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
|
0, 0, 0);
|
||||||
0);
|
|
||||||
XSelectInput(disp, win,
|
XSelectInput(disp, win,
|
||||||
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
|
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
|
||||||
PointerMotionMask | ExposureMask);
|
PointerMotionMask | ExposureMask);
|
||||||
|
@ -74,8 +73,8 @@ main(int argc, char **argv)
|
||||||
imlib_context_set_blend(0);
|
imlib_context_set_blend(0);
|
||||||
imlib_context_set_color_modifier(NULL);
|
imlib_context_set_color_modifier(NULL);
|
||||||
|
|
||||||
im_bg = imlib_load_image(PACKAGE_DATA_DIR"/data/images/imlib2.png");
|
im_bg = imlib_load_image(PACKAGE_DATA_DIR "/data/images/imlib2.png");
|
||||||
im = imlib_load_image(PACKAGE_DATA_DIR"/data/images/imlib2.png");
|
im = imlib_load_image(PACKAGE_DATA_DIR "/data/images/imlib2.png");
|
||||||
|
|
||||||
imlib_context_set_image(im_bg);
|
imlib_context_set_image(im_bg);
|
||||||
w = imlib_image_get_width();
|
w = imlib_image_get_width();
|
||||||
|
@ -96,16 +95,16 @@ main(int argc, char **argv)
|
||||||
XNextEvent(disp, &ev);
|
XNextEvent(disp, &ev);
|
||||||
switch (ev.type)
|
switch (ev.type)
|
||||||
{
|
{
|
||||||
case Expose:
|
case Expose:
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
x = ev.xmotion.x;
|
x = ev.xmotion.x;
|
||||||
y = ev.xmotion.y;
|
y = ev.xmotion.y;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +121,8 @@ main(int argc, char **argv)
|
||||||
* first = 0; */
|
* first = 0; */
|
||||||
|
|
||||||
imlib_apply_filter
|
imlib_apply_filter
|
||||||
("bump_map_point(x=[],y=[],map="PACKAGE_DATA_DIR"/data/images/imlib2.png);", &x, &y);
|
("bump_map_point(x=[],y=[],map=" PACKAGE_DATA_DIR
|
||||||
|
"/data/images/imlib2.png);", &x, &y);
|
||||||
|
|
||||||
temp2 = im_bg;
|
temp2 = im_bg;
|
||||||
im_bg = temp;
|
im_bg = temp;
|
||||||
|
|
|
@ -35,19 +35,18 @@ main(int argc, char **argv)
|
||||||
* First tests to determine which rendering task to perform
|
* First tests to determine which rendering task to perform
|
||||||
*/
|
*/
|
||||||
if (!display_name)
|
if (!display_name)
|
||||||
display_name = ":0";
|
display_name = ":0";
|
||||||
disp = XOpenDisplay(display_name);
|
disp = XOpenDisplay(display_name);
|
||||||
if (!disp)
|
if (!disp)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
vis = DefaultVisual(disp, DefaultScreen(disp));
|
vis = DefaultVisual(disp, DefaultScreen(disp));
|
||||||
depth = DefaultDepth(disp, DefaultScreen(disp));
|
depth = DefaultDepth(disp, DefaultScreen(disp));
|
||||||
cm = DefaultColormap(disp, DefaultScreen(disp));
|
cm = DefaultColormap(disp, DefaultScreen(disp));
|
||||||
win =
|
win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100,
|
||||||
XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
|
0, 0, 0);
|
||||||
0);
|
|
||||||
XSelectInput(disp, win,
|
XSelectInput(disp, win,
|
||||||
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
|
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
|
||||||
PointerMotionMask | ExposureMask | KeyPressMask);
|
PointerMotionMask | ExposureMask | KeyPressMask);
|
||||||
|
@ -56,7 +55,7 @@ main(int argc, char **argv)
|
||||||
* Start rendering
|
* Start rendering
|
||||||
*/
|
*/
|
||||||
imlib_set_font_cache_size(512 * 1024);
|
imlib_set_font_cache_size(512 * 1024);
|
||||||
imlib_add_path_to_font_path(PACKAGE_DATA_DIR"/data/fonts");
|
imlib_add_path_to_font_path(PACKAGE_DATA_DIR "/data/fonts");
|
||||||
imlib_context_set_display(disp);
|
imlib_context_set_display(disp);
|
||||||
imlib_context_set_visual(vis);
|
imlib_context_set_visual(vis);
|
||||||
imlib_context_set_colormap(cm);
|
imlib_context_set_colormap(cm);
|
||||||
|
@ -83,22 +82,22 @@ main(int argc, char **argv)
|
||||||
XNextEvent(disp, &ev);
|
XNextEvent(disp, &ev);
|
||||||
switch (ev.type)
|
switch (ev.type)
|
||||||
{
|
{
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
XLookupString(&ev.xkey, (char *)kbuf, sizeof(kbuf), &keysym,
|
XLookupString(&ev.xkey, (char *)kbuf, sizeof(kbuf), &keysym,
|
||||||
NULL);
|
NULL);
|
||||||
switch (*kbuf)
|
switch (*kbuf)
|
||||||
{
|
{
|
||||||
case 'q':
|
case 'q':
|
||||||
exit(0);
|
exit(0);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ int image_width = 0, image_height = 0;
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: imlib2_grab [-v] [-id <drawable id>] [-width <width>] [-height <height>] [-noshape] <output file>\n");
|
printf
|
||||||
|
("Usage: imlib2_grab [-v] [-id <drawable id>] [-width <width>] [-height <height>] [-noshape] <output file>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -102,12 +103,12 @@ main(int argc, char **argv)
|
||||||
file = argv[0];
|
file = argv[0];
|
||||||
|
|
||||||
if (!display_name)
|
if (!display_name)
|
||||||
display_name = ":0";
|
display_name = ":0";
|
||||||
disp = XOpenDisplay(display_name);
|
disp = XOpenDisplay(display_name);
|
||||||
if (!disp)
|
if (!disp)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vis = DefaultVisual(disp, DefaultScreen(disp));
|
vis = DefaultVisual(disp, DefaultScreen(disp));
|
||||||
|
@ -123,9 +124,9 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
XGetGeometry(disp, draw, &rr, &x, &y, &w, &h, &bw, &depth);
|
XGetGeometry(disp, draw, &rr, &x, &y, &w, &h, &bw, &depth);
|
||||||
if (wo == 0)
|
if (wo == 0)
|
||||||
wo = w;
|
wo = w;
|
||||||
if (ho == 0)
|
if (ho == 0)
|
||||||
ho = h;
|
ho = h;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
printf("Drawable: %#lx: x,y: %d,%d wxh=%ux%u bw=%u depth=%u\n",
|
printf("Drawable: %#lx: x,y: %d,%d wxh=%ux%u bw=%u depth=%u\n",
|
||||||
|
|
|
@ -34,19 +34,18 @@ main(int argc, char **argv)
|
||||||
* First tests to determine which rendering task to perform
|
* First tests to determine which rendering task to perform
|
||||||
*/
|
*/
|
||||||
if (!display_name)
|
if (!display_name)
|
||||||
display_name = ":0";
|
display_name = ":0";
|
||||||
disp = XOpenDisplay(display_name);
|
disp = XOpenDisplay(display_name);
|
||||||
if (!disp)
|
if (!disp)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
vis = DefaultVisual(disp, DefaultScreen(disp));
|
vis = DefaultVisual(disp, DefaultScreen(disp));
|
||||||
depth = DefaultDepth(disp, DefaultScreen(disp));
|
depth = DefaultDepth(disp, DefaultScreen(disp));
|
||||||
cm = DefaultColormap(disp, DefaultScreen(disp));
|
cm = DefaultColormap(disp, DefaultScreen(disp));
|
||||||
win =
|
win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100,
|
||||||
XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 100, 100, 0, 0,
|
0, 0, 0);
|
||||||
0);
|
|
||||||
XSelectInput(disp, win,
|
XSelectInput(disp, win,
|
||||||
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
|
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
|
||||||
PointerMotionMask | ExposureMask | KeyPressMask);
|
PointerMotionMask | ExposureMask | KeyPressMask);
|
||||||
|
@ -96,28 +95,28 @@ main(int argc, char **argv)
|
||||||
XNextEvent(disp, &ev);
|
XNextEvent(disp, &ev);
|
||||||
switch (ev.type)
|
switch (ev.type)
|
||||||
{
|
{
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
XLookupString(&ev.xkey, (char *)kbuf, sizeof(kbuf), &keysym,
|
XLookupString(&ev.xkey, (char *)kbuf, sizeof(kbuf), &keysym,
|
||||||
NULL);
|
NULL);
|
||||||
switch (*kbuf)
|
switch (*kbuf)
|
||||||
{
|
{
|
||||||
case ' ':
|
case ' ':
|
||||||
imlib_context_set_anti_alias
|
imlib_context_set_anti_alias
|
||||||
(!imlib_context_get_anti_alias());
|
(!imlib_context_get_anti_alias());
|
||||||
printf("AA is %s\n",
|
printf("AA is %s\n",
|
||||||
imlib_context_get_anti_alias()? "on" : "off");
|
imlib_context_get_anti_alias()? "on" : "off");
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
exit(0);
|
exit(0);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,33 +110,33 @@ main(int argc, char **argv)
|
||||||
printf("-up\t\tWhen doing scal test scale up, not down.\n");
|
printf("-up\t\tWhen doing scal test scale up, not down.\n");
|
||||||
printf("-both\t\tScale horizontally AND vertically in scale test.\n");
|
printf("-both\t\tScale horizontally AND vertically in scale test.\n");
|
||||||
printf
|
printf
|
||||||
("-orig\t\tKeep original width and height in each pass of scale test.\n");
|
("-orig\t\tKeep original width and height in each pass of scale test.\n");
|
||||||
printf("-blend\t\tBlending test.\n");
|
printf("-blend\t\tBlending test.\n");
|
||||||
printf("-dither\t\tTurn dithering on for depths < 24bpp\n");
|
printf("-dither\t\tTurn dithering on for depths < 24bpp\n");
|
||||||
printf("-colormod <r> <g> <b> <a>\t\tSet up color mod tables\n");
|
printf("-colormod <r> <g> <b> <a>\t\tSet up color mod tables\n");
|
||||||
printf("-scale\t\tScale test.\n");
|
printf("-scale\t\tScale test.\n");
|
||||||
printf("-noloop\t\tDont loop - timing test.\n");
|
printf("-noloop\t\tDont loop - timing test.\n");
|
||||||
printf
|
printf
|
||||||
("-rotate\t\tAlso rotate background image with mouse in interative test.\n");
|
("-rotate\t\tAlso rotate background image with mouse in interative test.\n");
|
||||||
printf("-size <w> <h>\t\tScale from w x h down in scaling test.\n"); // require parameters w / h
|
printf("-size <w> <h>\t\tScale from w x h down in scaling test.\n"); // require parameters w / h
|
||||||
printf("-maxcolors <n>\t\tLimit color allocation count to n colors.\n"); // require parameter nb colors
|
printf("-maxcolors <n>\t\tLimit color allocation count to n colors.\n"); // require parameter nb colors
|
||||||
printf
|
printf
|
||||||
("-text\t\tDisplays the text following this option. Need a loaded font.\n");
|
("-text\t\tDisplays the text following this option. Need a loaded font.\n");
|
||||||
printf
|
printf
|
||||||
("-font\t\tLoads a font. The parameter must follow the police_name/size format. Example: loading the grunge font at size 18 is : grunge/18.\n\t\tThe XFD font also can be specified. Ex. 'notepad/32,-*--24-*'.\n");
|
("-font\t\tLoads a font. The parameter must follow the police_name/size format. Example: loading the grunge font at size 18 is : grunge/18.\n\t\tThe XFD font also can be specified. Ex. 'notepad/32,-*--24-*'.\n");
|
||||||
printf("-poly\t\tPerforms a poly test\n");
|
printf("-poly\t\tPerforms a poly test\n");
|
||||||
printf("The following options requires a file to work properly.\n");
|
printf("The following options requires a file to work properly.\n");
|
||||||
printf("-textdir\t\tText Direction. 0: L to R, 1: R to L\n");
|
printf("-textdir\t\tText Direction. 0: L to R, 1: R to L\n");
|
||||||
printf(" 2: U to D, 3: D to U, 4: angle\n");
|
printf(" 2: U to D, 3: D to U, 4: angle\n");
|
||||||
printf("-xfdtest\t\tXFD Font queue test.\n");
|
printf("-xfdtest\t\tXFD Font queue test.\n");
|
||||||
printf
|
printf
|
||||||
("-xfdcachetest <f> [<l>]\t\tXFD tFont cache test.\n\t\tThe file f is drawn l times\n");
|
("-xfdcachetest <f> [<l>]\t\tXFD tFont cache test.\n\t\tThe file f is drawn l times\n");
|
||||||
printf("-blast\t\tDisplays the file.\n");
|
printf("-blast\t\tDisplays the file.\n");
|
||||||
printf("-loop\t\tScales down the image.\n");
|
printf("-loop\t\tScales down the image.\n");
|
||||||
printf("-blendtest\tPerforms a blending test on the file.\n");
|
printf("-blendtest\tPerforms a blending test on the file.\n");
|
||||||
printf("-rotatetest\tPerforms a rotate test on the file.\n");
|
printf("-rotatetest\tPerforms a rotate test on the file.\n");
|
||||||
printf
|
printf
|
||||||
("-filter\t\tPerforms filtering. Possible filters are,\n\t\t\t1:Blur filter, 2:Sharpen filter, 3:Color blur filter, \n\t\t\t4:Emboss filter, 5:Grayscale filter, 6:Saturation filter,\n\t\t\t7:Edge detection filter.\n");
|
("-filter\t\tPerforms filtering. Possible filters are,\n\t\t\t1:Blur filter, 2:Sharpen filter, 3:Color blur filter, \n\t\t\t4:Emboss filter, 5:Grayscale filter, 6:Saturation filter,\n\t\t\t7:Edge detection filter.\n");
|
||||||
printf("-bmp2pt\t\tPerformas Bump Mapping to a point\n");
|
printf("-bmp2pt\t\tPerformas Bump Mapping to a point\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -265,13 +265,14 @@ main(int argc, char **argv)
|
||||||
if (!blendtest)
|
if (!blendtest)
|
||||||
{
|
{
|
||||||
const char *display_name = getenv("DISPLAY");
|
const char *display_name = getenv("DISPLAY");
|
||||||
|
|
||||||
if (!display_name)
|
if (!display_name)
|
||||||
display_name = ":0";
|
display_name = ":0";
|
||||||
disp = XOpenDisplay(display_name);
|
disp = XOpenDisplay(display_name);
|
||||||
if (!disp)
|
if (!disp)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
vis = DefaultVisual(disp, DefaultScreen(disp));
|
vis = DefaultVisual(disp, DefaultScreen(disp));
|
||||||
depth = DefaultDepth(disp, DefaultScreen(disp));
|
depth = DefaultDepth(disp, DefaultScreen(disp));
|
||||||
|
@ -286,8 +287,8 @@ main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
win =
|
win =
|
||||||
XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 10,
|
XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 10,
|
||||||
10, 0, 0, 0);
|
10, 0, 0, 0);
|
||||||
XSelectInput(disp, win,
|
XSelectInput(disp, win,
|
||||||
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
|
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
|
||||||
| PointerMotionMask | ExposureMask);
|
| PointerMotionMask | ExposureMask);
|
||||||
|
@ -381,7 +382,7 @@ main(int argc, char **argv)
|
||||||
if (file)
|
if (file)
|
||||||
im_bg = imlib_load_image(file);
|
im_bg = imlib_load_image(file);
|
||||||
else
|
else
|
||||||
im_bg = imlib_load_image(PACKAGE_DATA_DIR"/data/images/bg.png");
|
im_bg = imlib_load_image(PACKAGE_DATA_DIR "/data/images/bg.png");
|
||||||
imlib_context_set_image(im_bg);
|
imlib_context_set_image(im_bg);
|
||||||
w = imlib_image_get_width();
|
w = imlib_image_get_width();
|
||||||
h = imlib_image_get_height();
|
h = imlib_image_get_height();
|
||||||
|
@ -406,9 +407,9 @@ main(int argc, char **argv)
|
||||||
double xx, yy;
|
double xx, yy;
|
||||||
|
|
||||||
xx = (w / 2) +
|
xx = (w / 2) +
|
||||||
(cos(a) * points[i][0]) + (cos(a + A90) * points[i][1]);
|
(cos(a) * points[i][0]) + (cos(a + A90) * points[i][1]);
|
||||||
yy = (h / 2) +
|
yy = (h / 2) +
|
||||||
(sin(a) * points[i][0]) + (sin(a + A90) * points[i][1]);
|
(sin(a) * points[i][0]) + (sin(a + A90) * points[i][1]);
|
||||||
imlib_polygon_add_point(poly, xx, yy);
|
imlib_polygon_add_point(poly, xx, yy);
|
||||||
}
|
}
|
||||||
printf("draw angle %3.3f\n", a);
|
printf("draw angle %3.3f\n", a);
|
||||||
|
@ -482,9 +483,9 @@ main(int argc, char **argv)
|
||||||
Imlib_Image im_tmp;
|
Imlib_Image im_tmp;
|
||||||
|
|
||||||
im_tmp =
|
im_tmp =
|
||||||
imlib_create_cropped_scaled_image(0, 0, w, h, w,
|
imlib_create_cropped_scaled_image(0, 0, w, h, w,
|
||||||
(((i) * h) /
|
(((i) * h) /
|
||||||
w));
|
w));
|
||||||
if (im_tmp)
|
if (im_tmp)
|
||||||
{
|
{
|
||||||
imlib_context_set_image(im_tmp);
|
imlib_context_set_image(im_tmp);
|
||||||
|
@ -498,9 +499,9 @@ main(int argc, char **argv)
|
||||||
Imlib_Image im_tmp;
|
Imlib_Image im_tmp;
|
||||||
|
|
||||||
im_tmp =
|
im_tmp =
|
||||||
imlib_create_cropped_scaled_image(0, 0, w, h, w,
|
imlib_create_cropped_scaled_image(0, 0, w, h, w,
|
||||||
(((i) * h) /
|
(((i) * h) /
|
||||||
w));
|
w));
|
||||||
if (im_tmp)
|
if (im_tmp)
|
||||||
{
|
{
|
||||||
imlib_context_set_image(im_tmp);
|
imlib_context_set_image(im_tmp);
|
||||||
|
@ -521,8 +522,8 @@ main(int argc, char **argv)
|
||||||
Imlib_Image im_tmp;
|
Imlib_Image im_tmp;
|
||||||
|
|
||||||
im_tmp =
|
im_tmp =
|
||||||
imlib_create_cropped_scaled_image(0, 0, w, h,
|
imlib_create_cropped_scaled_image(0, 0, w, h,
|
||||||
2 * w - i, h);
|
2 * w - i, h);
|
||||||
if (im_tmp)
|
if (im_tmp)
|
||||||
{
|
{
|
||||||
imlib_context_set_image(im_tmp);
|
imlib_context_set_image(im_tmp);
|
||||||
|
@ -547,10 +548,10 @@ main(int argc, char **argv)
|
||||||
Imlib_Image im_tmp;
|
Imlib_Image im_tmp;
|
||||||
|
|
||||||
im_tmp =
|
im_tmp =
|
||||||
imlib_create_cropped_scaled_image(0, 0, w, h,
|
imlib_create_cropped_scaled_image(0, 0, w, h,
|
||||||
2 * w - i,
|
2 * w - i,
|
||||||
(((i) * h) /
|
(((i) * h) /
|
||||||
w));
|
w));
|
||||||
if (im_tmp)
|
if (im_tmp)
|
||||||
{
|
{
|
||||||
imlib_context_set_image(im_tmp);
|
imlib_context_set_image(im_tmp);
|
||||||
|
@ -616,7 +617,7 @@ main(int argc, char **argv)
|
||||||
* pixels += (2 * w - i) * (((i) * h) / w);
|
* pixels += (2 * w - i) * (((i) * h) / w);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* } */// end if loop
|
* } */// end if loop
|
||||||
else if (blendtest)
|
else if (blendtest)
|
||||||
{
|
{
|
||||||
Imlib_Image im2;
|
Imlib_Image im2;
|
||||||
|
@ -704,74 +705,74 @@ main(int argc, char **argv)
|
||||||
imlib_context_set_filter(imlib_create_filter(0));
|
imlib_context_set_filter(imlib_create_filter(0));
|
||||||
switch (filter)
|
switch (filter)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 1:
|
case 1:
|
||||||
/*\ Blur filter \ */
|
/*\ Blur filter \ */
|
||||||
imlib_filter_set(0, 0, 0, 8, 8, 8);
|
imlib_filter_set(0, 0, 0, 8, 8, 8);
|
||||||
imlib_filter_set(-1, 0, 0, 4, 4, 4);
|
imlib_filter_set(-1, 0, 0, 4, 4, 4);
|
||||||
imlib_filter_set(0, -1, 0, 4, 4, 4);
|
imlib_filter_set(0, -1, 0, 4, 4, 4);
|
||||||
imlib_filter_set(1, 0, 0, 4, 4, 4);
|
imlib_filter_set(1, 0, 0, 4, 4, 4);
|
||||||
imlib_filter_set(0, 1, 0, 4, 4, 4);
|
imlib_filter_set(0, 1, 0, 4, 4, 4);
|
||||||
imlib_filter_set(-2, 0, 0, 1, 1, 1);
|
imlib_filter_set(-2, 0, 0, 1, 1, 1);
|
||||||
imlib_filter_set(0, -2, 0, 1, 1, 1);
|
imlib_filter_set(0, -2, 0, 1, 1, 1);
|
||||||
imlib_filter_set(2, 0, 0, 1, 1, 1);
|
imlib_filter_set(2, 0, 0, 1, 1, 1);
|
||||||
imlib_filter_set(0, 2, 0, 1, 1, 1);
|
imlib_filter_set(0, 2, 0, 1, 1, 1);
|
||||||
imlib_filter_set(-1, -1, 0, 1, 1, 1);
|
imlib_filter_set(-1, -1, 0, 1, 1, 1);
|
||||||
imlib_filter_set(-1, 1, 0, 1, 1, 1);
|
imlib_filter_set(-1, 1, 0, 1, 1, 1);
|
||||||
imlib_filter_set(1, -1, 0, 1, 1, 1);
|
imlib_filter_set(1, -1, 0, 1, 1, 1);
|
||||||
imlib_filter_set(1, 1, 0, 1, 1, 1);
|
imlib_filter_set(1, 1, 0, 1, 1, 1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/*\ Sharpen filter \ */
|
/*\ Sharpen filter \ */
|
||||||
imlib_filter_set(0, 0, 0, 5, 5, 5);
|
imlib_filter_set(0, 0, 0, 5, 5, 5);
|
||||||
imlib_filter_set(-1, 0, 0, -1, -1, -1);
|
imlib_filter_set(-1, 0, 0, -1, -1, -1);
|
||||||
imlib_filter_set(0, -1, 0, -1, -1, -1);
|
imlib_filter_set(0, -1, 0, -1, -1, -1);
|
||||||
imlib_filter_set(1, 0, 0, -1, -1, -1);
|
imlib_filter_set(1, 0, 0, -1, -1, -1);
|
||||||
imlib_filter_set(0, 1, 0, -1, -1, -1);
|
imlib_filter_set(0, 1, 0, -1, -1, -1);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
/*\ Color blur filter \ */
|
/*\ Color blur filter \ */
|
||||||
imlib_filter_set(0, 0, 0, 3, 3, 3);
|
imlib_filter_set(0, 0, 0, 3, 3, 3);
|
||||||
imlib_filter_set(-1, -1, 0, 1, 0, 0);
|
imlib_filter_set(-1, -1, 0, 1, 0, 0);
|
||||||
imlib_filter_set(1, -1, 0, 0, 1, 0);
|
imlib_filter_set(1, -1, 0, 0, 1, 0);
|
||||||
imlib_filter_set(0, 1, 0, 0, 0, 1);
|
imlib_filter_set(0, 1, 0, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
/*\ Emboss filter \ */
|
/*\ Emboss filter \ */
|
||||||
imlib_filter_set_red(-1, -1, 0, -1, -1, -1);
|
imlib_filter_set_red(-1, -1, 0, -1, -1, -1);
|
||||||
imlib_filter_set_red(0, 0, 0, 1, 1, 1);
|
imlib_filter_set_red(0, 0, 0, 1, 1, 1);
|
||||||
imlib_filter_set_green(-1, -1, 0, -1, -1, -1);
|
imlib_filter_set_green(-1, -1, 0, -1, -1, -1);
|
||||||
imlib_filter_set_green(0, 0, 0, 1, 1, 1);
|
imlib_filter_set_green(0, 0, 0, 1, 1, 1);
|
||||||
imlib_filter_set_blue(-1, -1, 0, -1, -1, -1);
|
imlib_filter_set_blue(-1, -1, 0, -1, -1, -1);
|
||||||
imlib_filter_set_blue(0, 0, 0, 1, 1, 1);
|
imlib_filter_set_blue(0, 0, 0, 1, 1, 1);
|
||||||
|
|
||||||
imlib_filter_constants(0, 768, 768, 768);
|
imlib_filter_constants(0, 768, 768, 768);
|
||||||
imlib_filter_divisors(0, 6, 6, 6);
|
imlib_filter_divisors(0, 6, 6, 6);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
/*\ Grayscale filter \ */
|
/*\ Grayscale filter \ */
|
||||||
imlib_filter_set_red(0, 0, 0, 80, 1, 1);
|
imlib_filter_set_red(0, 0, 0, 80, 1, 1);
|
||||||
imlib_filter_set_green(0, 0, 0, 1, 80, 1);
|
imlib_filter_set_green(0, 0, 0, 1, 80, 1);
|
||||||
imlib_filter_set_blue(0, 0, 0, 1, 1, 80);
|
imlib_filter_set_blue(0, 0, 0, 1, 1, 80);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
/*\ Saturation filter \ */
|
/*\ Saturation filter \ */
|
||||||
imlib_filter_set_red(0, 0, 0, 80, -1, -1);
|
imlib_filter_set_red(0, 0, 0, 80, -1, -1);
|
||||||
imlib_filter_set_green(0, 0, 0, -1, 80, -1);
|
imlib_filter_set_green(0, 0, 0, -1, 80, -1);
|
||||||
imlib_filter_set_blue(0, 0, 0, -1, -1, 80);
|
imlib_filter_set_blue(0, 0, 0, -1, -1, 80);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
/*\ Edge detection filter \ */
|
/*\ Edge detection filter \ */
|
||||||
imlib_filter_set(-1, -1, 0, -1, -1, -1);
|
imlib_filter_set(-1, -1, 0, -1, -1, -1);
|
||||||
imlib_filter_set(-1, 0, 0, -3, -3, -3);
|
imlib_filter_set(-1, 0, 0, -3, -3, -3);
|
||||||
imlib_filter_set(-1, 1, 0, -1, -1, -1);
|
imlib_filter_set(-1, 1, 0, -1, -1, -1);
|
||||||
imlib_filter_set(0, -1, 0, -3, -3, -3);
|
imlib_filter_set(0, -1, 0, -3, -3, -3);
|
||||||
imlib_filter_set(0, 0, 0, 16, 16, 16);
|
imlib_filter_set(0, 0, 0, 16, 16, 16);
|
||||||
imlib_filter_set(0, 1, 0, -3, -3, -3);
|
imlib_filter_set(0, 1, 0, -3, -3, -3);
|
||||||
imlib_filter_set(1, -1, 0, -1, -1, -1);
|
imlib_filter_set(1, -1, 0, -1, -1, -1);
|
||||||
imlib_filter_set(1, 0, 0, -3, -3, -3);
|
imlib_filter_set(1, 0, 0, -3, -3, -3);
|
||||||
imlib_filter_set(1, 1, 0, -1, -1, -1);
|
imlib_filter_set(1, 1, 0, -1, -1, -1);
|
||||||
imlib_filter_divisors(0, 3, 3, 3);
|
imlib_filter_divisors(0, 3, 3, 3);
|
||||||
}
|
}
|
||||||
pixels = 0;
|
pixels = 0;
|
||||||
imlib_render_image_on_drawable_at_size(0, 0, w, h);
|
imlib_render_image_on_drawable_at_size(0, 0, w, h);
|
||||||
|
@ -812,7 +813,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
/* "ARIAL/30" "COMIC/30" "IMPACT/30" "Prole/30" "Proteron/30" */
|
/* "ARIAL/30" "COMIC/30" "IMPACT/30" "Prole/30" "Proteron/30" */
|
||||||
/* "TIMES/30" "badacid/30" "bajoran/30" "bigfish/30" */
|
/* "TIMES/30" "badacid/30" "bajoran/30" "bigfish/30" */
|
||||||
imlib_add_path_to_font_path(PACKAGE_DATA_DIR"/data/fonts");
|
imlib_add_path_to_font_path(PACKAGE_DATA_DIR "/data/fonts");
|
||||||
|
|
||||||
if (xfdtest)
|
if (xfdtest)
|
||||||
{
|
{
|
||||||
|
@ -823,10 +824,10 @@ main(int argc, char **argv)
|
||||||
f, f->next, f->type, f->ref, f->name);
|
f, f->next, f->type, f->ref, f->name);
|
||||||
imlib_context_set_font((Imlib_Font) f);
|
imlib_context_set_font((Imlib_Font) f);
|
||||||
printf
|
printf
|
||||||
("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
|
("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
|
||||||
imlib_get_font_ascent(), imlib_get_font_descent(),
|
imlib_get_font_ascent(), imlib_get_font_descent(),
|
||||||
imlib_get_maximum_font_ascent(),
|
imlib_get_maximum_font_ascent(),
|
||||||
imlib_get_maximum_font_descent());
|
imlib_get_maximum_font_descent());
|
||||||
imlib_free_font();
|
imlib_free_font();
|
||||||
printf("imlib_free_font: f=%p, next=%p, type=%d, ref=%d, '%s'\n",
|
printf("imlib_free_font: f=%p, next=%p, type=%d, ref=%d, '%s'\n",
|
||||||
f, f->next, f->type, f->ref, f->name);
|
f, f->next, f->type, f->ref, f->name);
|
||||||
|
@ -837,10 +838,10 @@ main(int argc, char **argv)
|
||||||
f, f->next, f->type, f->ref, f->name);
|
f, f->next, f->type, f->ref, f->name);
|
||||||
imlib_context_set_font((Imlib_Font) f);
|
imlib_context_set_font((Imlib_Font) f);
|
||||||
printf
|
printf
|
||||||
("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
|
("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
|
||||||
imlib_get_font_ascent(), imlib_get_font_descent(),
|
imlib_get_font_ascent(), imlib_get_font_descent(),
|
||||||
imlib_get_maximum_font_ascent(),
|
imlib_get_maximum_font_ascent(),
|
||||||
imlib_get_maximum_font_descent());
|
imlib_get_maximum_font_descent());
|
||||||
imlib_free_font();
|
imlib_free_font();
|
||||||
printf("imlib_free_font: f=%p, next=%p, type=%d, ref=%d, '%s'\n",
|
printf("imlib_free_font: f=%p, next=%p, type=%d, ref=%d, '%s'\n",
|
||||||
f, f->next, f->type, f->ref, f->name);
|
f, f->next, f->type, f->ref, f->name);
|
||||||
|
@ -900,10 +901,10 @@ main(int argc, char **argv)
|
||||||
f, f->next, f->type, f->ref, f->name);
|
f, f->next, f->type, f->ref, f->name);
|
||||||
imlib_context_set_font((Imlib_Font) f1);
|
imlib_context_set_font((Imlib_Font) f1);
|
||||||
printf
|
printf
|
||||||
("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
|
("\t\t ascent=%d, descent=%d, max_ascent=%d, max_descent=%d\n",
|
||||||
imlib_get_font_ascent(), imlib_get_font_descent(),
|
imlib_get_font_ascent(), imlib_get_font_descent(),
|
||||||
imlib_get_maximum_font_ascent(),
|
imlib_get_maximum_font_ascent(),
|
||||||
imlib_get_maximum_font_descent());
|
imlib_get_maximum_font_descent());
|
||||||
|
|
||||||
printf("Font Cache test end\n");
|
printf("Font Cache test end\n");
|
||||||
}
|
}
|
||||||
|
@ -932,7 +933,7 @@ main(int argc, char **argv)
|
||||||
if (file)
|
if (file)
|
||||||
im_bg = imlib_load_image(file);
|
im_bg = imlib_load_image(file);
|
||||||
else
|
else
|
||||||
im_bg = imlib_load_image(PACKAGE_DATA_DIR"/data/images/bg.png");
|
im_bg = imlib_load_image(PACKAGE_DATA_DIR "/data/images/bg.png");
|
||||||
imlib_context_set_image(im_bg);
|
imlib_context_set_image(im_bg);
|
||||||
im_tmp = imlib_clone_image();
|
im_tmp = imlib_clone_image();
|
||||||
w = imlib_image_get_width();
|
w = imlib_image_get_width();
|
||||||
|
@ -958,47 +959,60 @@ main(int argc, char **argv)
|
||||||
XNextEvent(disp, &ev);
|
XNextEvent(disp, &ev);
|
||||||
switch (ev.type)
|
switch (ev.type)
|
||||||
{
|
{
|
||||||
case Expose:
|
case Expose:
|
||||||
up = imlib_update_append_rect(up,
|
up = imlib_update_append_rect(up,
|
||||||
ev.xexpose.x,
|
ev.xexpose.x,
|
||||||
ev.xexpose.y,
|
ev.xexpose.y,
|
||||||
ev.xexpose.width,
|
ev.xexpose.width,
|
||||||
ev.xexpose.height);
|
ev.xexpose.height);
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
if (fon)
|
if (fon)
|
||||||
{
|
{
|
||||||
imlib_context_set_font(fn);
|
imlib_context_set_font(fn);
|
||||||
imlib_free_font();
|
imlib_free_font();
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
x = ev.xmotion.x;
|
x = ev.xmotion.x;
|
||||||
y = ev.xmotion.y;
|
y = ev.xmotion.y;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (XPending(disp));
|
while (XPending(disp));
|
||||||
|
|
||||||
im_sh1 = imlib_load_image(PACKAGE_DATA_DIR"/data/images/sh1.png");
|
im_sh1 = imlib_load_image(PACKAGE_DATA_DIR "/data/images/sh1.png");
|
||||||
im_sh2 = imlib_load_image(PACKAGE_DATA_DIR"/data/images/sh2.png");
|
im_sh2 = imlib_load_image(PACKAGE_DATA_DIR "/data/images/sh2.png");
|
||||||
im_sh3 = imlib_load_image(PACKAGE_DATA_DIR"/data/images/sh3.png");
|
im_sh3 = imlib_load_image(PACKAGE_DATA_DIR "/data/images/sh3.png");
|
||||||
im_ic[0] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/audio.png");
|
im_ic[0] =
|
||||||
im_ic[1] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/folder.png");
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/audio.png");
|
||||||
im_ic[2] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/mush.png");
|
im_ic[1] =
|
||||||
im_ic[3] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/paper.png");
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/folder.png");
|
||||||
im_ic[4] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/mail.png");
|
im_ic[2] =
|
||||||
im_ic[5] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/calc.png");
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/mush.png");
|
||||||
im_ic[6] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/cal.png");
|
im_ic[3] =
|
||||||
im_ic[7] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/stop.png");
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/paper.png");
|
||||||
im_ic[8] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/globe.png");
|
im_ic[4] =
|
||||||
im_ic[9] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/menu.png");
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/mail.png");
|
||||||
im_ic[10] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/tnt.png");
|
im_ic[5] =
|
||||||
im_ic[11] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/bulb.png");
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/calc.png");
|
||||||
im_ic[12] = imlib_load_image(PACKAGE_DATA_DIR"/data/images/lock.png");
|
im_ic[6] =
|
||||||
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/cal.png");
|
||||||
|
im_ic[7] =
|
||||||
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/stop.png");
|
||||||
|
im_ic[8] =
|
||||||
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/globe.png");
|
||||||
|
im_ic[9] =
|
||||||
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/menu.png");
|
||||||
|
im_ic[10] =
|
||||||
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/tnt.png");
|
||||||
|
im_ic[11] =
|
||||||
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/bulb.png");
|
||||||
|
im_ic[12] =
|
||||||
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/lock.png");
|
||||||
|
|
||||||
imlib_context_set_image(im);
|
imlib_context_set_image(im);
|
||||||
if (first)
|
if (first)
|
||||||
|
@ -1214,7 +1228,7 @@ main(int argc, char **argv)
|
||||||
else if (fon)
|
else if (fon)
|
||||||
{
|
{
|
||||||
int retw, reth, tx, ty, nx, ny, cx, cy, cw,
|
int retw, reth, tx, ty, nx, ny, cx, cy, cw,
|
||||||
ch, cp;
|
ch, cp;
|
||||||
int cx2, cy2, cw2, ch2;
|
int cx2, cy2, cw2, ch2;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
|
@ -1242,15 +1256,15 @@ main(int argc, char **argv)
|
||||||
up = imlib_update_append_rect(up, tx, ty, retw, reth);
|
up = imlib_update_append_rect(up, tx, ty, retw, reth);
|
||||||
switch (textdir)
|
switch (textdir)
|
||||||
{
|
{
|
||||||
case IMLIB_TEXT_TO_RIGHT:
|
case IMLIB_TEXT_TO_RIGHT:
|
||||||
case IMLIB_TEXT_TO_LEFT:
|
case IMLIB_TEXT_TO_LEFT:
|
||||||
case IMLIB_TEXT_TO_ANGLE:
|
case IMLIB_TEXT_TO_ANGLE:
|
||||||
ty += ny;
|
ty += ny;
|
||||||
break;
|
break;
|
||||||
case IMLIB_TEXT_TO_DOWN:
|
case IMLIB_TEXT_TO_DOWN:
|
||||||
case IMLIB_TEXT_TO_UP:
|
case IMLIB_TEXT_TO_UP:
|
||||||
tx += nx;
|
tx += nx;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cp = imlib_text_get_index_and_location(str, x - 50, y - 50,
|
cp = imlib_text_get_index_and_location(str, x - 50, y - 50,
|
||||||
|
|
|
@ -41,12 +41,12 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
/* connect to X */
|
/* connect to X */
|
||||||
if (!display_name)
|
if (!display_name)
|
||||||
display_name = ":0";
|
display_name = ":0";
|
||||||
disp = XOpenDisplay(display_name);
|
disp = XOpenDisplay(display_name);
|
||||||
if (!disp)
|
if (!disp)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* get default visual , colormap etc. you could ask imlib2 for what it */
|
/* get default visual , colormap etc. you could ask imlib2 for what it */
|
||||||
/* thinks is the best, but this example is intended to be simple */
|
/* thinks is the best, but this example is intended to be simple */
|
||||||
|
@ -68,7 +68,7 @@ main(int argc, char **argv)
|
||||||
imlib_set_font_cache_size(512 * 1024);
|
imlib_set_font_cache_size(512 * 1024);
|
||||||
/* add the ./ttfonts dir to our font path - you'll want a notepad.ttf */
|
/* add the ./ttfonts dir to our font path - you'll want a notepad.ttf */
|
||||||
/* in that dir for the text to display */
|
/* in that dir for the text to display */
|
||||||
imlib_add_path_to_font_path(PACKAGE_DATA_DIR"/data/fonts");
|
imlib_add_path_to_font_path(PACKAGE_DATA_DIR "/data/fonts");
|
||||||
/* set the maximum number of colors to allocate for 8bpp and less to 128 */
|
/* set the maximum number of colors to allocate for 8bpp and less to 128 */
|
||||||
imlib_set_color_usage(128);
|
imlib_set_color_usage(128);
|
||||||
/* dither for depths < 24bpp */
|
/* dither for depths < 24bpp */
|
||||||
|
@ -95,70 +95,71 @@ main(int argc, char **argv)
|
||||||
XNextEvent(disp, &ev);
|
XNextEvent(disp, &ev);
|
||||||
switch (ev.type)
|
switch (ev.type)
|
||||||
{
|
{
|
||||||
case Expose:
|
case Expose:
|
||||||
/* window rectangle was exposed - add it to the list of */
|
/* window rectangle was exposed - add it to the list of */
|
||||||
/* rectangles we need to re-render */
|
/* rectangles we need to re-render */
|
||||||
updates = imlib_update_append_rect(updates,
|
updates = imlib_update_append_rect(updates,
|
||||||
ev.xexpose.x,
|
ev.xexpose.x,
|
||||||
ev.xexpose.y,
|
ev.xexpose.y,
|
||||||
ev.xexpose.width,
|
ev.xexpose.width,
|
||||||
ev.xexpose.height);
|
ev.xexpose.height);
|
||||||
break;
|
break;
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
/* if we click anywhere in the window, exit */
|
/* if we click anywhere in the window, exit */
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
/* if the mouse moves - note it */
|
/* if the mouse moves - note it */
|
||||||
/* add a rectangle update for the new mouse position */
|
/* add a rectangle update for the new mouse position */
|
||||||
image = imlib_load_image(PACKAGE_DATA_DIR"/data/images/mush.png");
|
image =
|
||||||
imlib_context_set_image(image);
|
imlib_load_image(PACKAGE_DATA_DIR "/data/images/mush.png");
|
||||||
w = imlib_image_get_width();
|
imlib_context_set_image(image);
|
||||||
h = imlib_image_get_height();
|
w = imlib_image_get_width();
|
||||||
imlib_context_set_image(image);
|
h = imlib_image_get_height();
|
||||||
imlib_free_image();
|
imlib_context_set_image(image);
|
||||||
/* the old position - so we wipe over where it used to be */
|
imlib_free_image();
|
||||||
updates = imlib_update_append_rect(updates,
|
/* the old position - so we wipe over where it used to be */
|
||||||
mouse_x - (w / 2),
|
updates = imlib_update_append_rect(updates,
|
||||||
mouse_y - (h / 2), w, h);
|
mouse_x - (w / 2),
|
||||||
font = imlib_load_font("notepad/30");
|
mouse_y - (h / 2), w, h);
|
||||||
if (font)
|
font = imlib_load_font("notepad/30");
|
||||||
{
|
if (font)
|
||||||
char text[4096];
|
{
|
||||||
|
char text[4096];
|
||||||
|
|
||||||
imlib_context_set_font(font);
|
imlib_context_set_font(font);
|
||||||
sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
|
sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
|
||||||
imlib_get_text_size(text, &text_w, &text_h);
|
imlib_get_text_size(text, &text_w, &text_h);
|
||||||
imlib_free_font();
|
imlib_free_font();
|
||||||
updates = imlib_update_append_rect(updates,
|
updates = imlib_update_append_rect(updates,
|
||||||
320 - (text_w / 2),
|
320 - (text_w / 2),
|
||||||
240 - (text_h / 2),
|
240 - (text_h / 2),
|
||||||
text_w, text_h);
|
text_w, text_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse_x = ev.xmotion.x;
|
mouse_x = ev.xmotion.x;
|
||||||
mouse_y = ev.xmotion.y;
|
mouse_y = ev.xmotion.y;
|
||||||
/* the new one */
|
/* the new one */
|
||||||
updates = imlib_update_append_rect(updates,
|
updates = imlib_update_append_rect(updates,
|
||||||
mouse_x - (w / 2),
|
mouse_x - (w / 2),
|
||||||
mouse_y - (h / 2), w, h);
|
mouse_y - (h / 2), w, h);
|
||||||
font = imlib_load_font("notepad/30");
|
font = imlib_load_font("notepad/30");
|
||||||
if (font)
|
if (font)
|
||||||
{
|
{
|
||||||
char text[4096];
|
char text[4096];
|
||||||
|
|
||||||
imlib_context_set_font(font);
|
imlib_context_set_font(font);
|
||||||
sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
|
sprintf(text, "Mouse is at %i, %i", mouse_x, mouse_y);
|
||||||
imlib_get_text_size(text, &text_w, &text_h);
|
imlib_get_text_size(text, &text_w, &text_h);
|
||||||
imlib_free_font();
|
imlib_free_font();
|
||||||
updates = imlib_update_append_rect(updates,
|
updates = imlib_update_append_rect(updates,
|
||||||
320 - (text_w / 2),
|
320 - (text_w / 2),
|
||||||
240 - (text_h / 2),
|
240 - (text_h / 2),
|
||||||
text_w, text_h);
|
text_w, text_h);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
/* any other events - do nothing */
|
/* any other events - do nothing */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (XPending(disp));
|
while (XPending(disp));
|
||||||
|
@ -187,7 +188,7 @@ main(int argc, char **argv)
|
||||||
/* fill the window background */
|
/* fill the window background */
|
||||||
/* load the background image - you'll need to have some images */
|
/* load the background image - you'll need to have some images */
|
||||||
/* in ./test_images lying around for this to actually work */
|
/* in ./test_images lying around for this to actually work */
|
||||||
image = imlib_load_image(PACKAGE_DATA_DIR"/data/images/bg.png");
|
image = imlib_load_image(PACKAGE_DATA_DIR "/data/images/bg.png");
|
||||||
/* we're working with this image now */
|
/* we're working with this image now */
|
||||||
imlib_context_set_image(image);
|
imlib_context_set_image(image);
|
||||||
/* get its size */
|
/* get its size */
|
||||||
|
@ -209,7 +210,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw an icon centered around the mouse position */
|
/* draw an icon centered around the mouse position */
|
||||||
image = imlib_load_image(PACKAGE_DATA_DIR"/data/images/mush.png");
|
image = imlib_load_image(PACKAGE_DATA_DIR "/data/images/mush.png");
|
||||||
imlib_context_set_image(image);
|
imlib_context_set_image(image);
|
||||||
w = imlib_image_get_width();
|
w = imlib_image_get_width();
|
||||||
h = imlib_image_get_height();
|
h = imlib_image_get_height();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
#else
|
#else
|
||||||
# define X_DISPLAY_MISSING
|
#define X_DISPLAY_MISSING
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
|
@ -1722,7 +1722,7 @@ __imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef DO_MMX_ASM
|
#ifdef DO_MMX_ASM
|
||||||
do_mmx = !!(__imlib_get_cpuid() & CPUID_MMX);
|
do_mmx = ! !(__imlib_get_cpuid() & CPUID_MMX);
|
||||||
#elif DO_AMD64_ASM
|
#elif DO_AMD64_ASM
|
||||||
do_mmx = 1; // instruction set is always present
|
do_mmx = 1; // instruction set is always present
|
||||||
#endif
|
#endif
|
||||||
|
@ -1730,7 +1730,7 @@ __imlib_GetBlendFunction(ImlibOp op, char blend, char merge_alpha, char rgb_src,
|
||||||
blend = 0;
|
blend = 0;
|
||||||
if (blend && cm && rgb_src && (A_CMOD(cm, 0xff) == 0))
|
if (blend && cm && rgb_src && (A_CMOD(cm, 0xff) == 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
return ibfuncs[!!do_mmx][opi][!!cm][!!merge_alpha][!!rgb_src][!!blend];
|
return ibfuncs[! !do_mmx][opi][! !cm][! !merge_alpha][! !rgb_src][! !blend];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -33,6 +33,7 @@ __imlib_BestVisual(Display * d, int screen, int *depth_return)
|
||||||
XVisualInfo xvi, *xvir;
|
XVisualInfo xvi, *xvir;
|
||||||
int j, i, num, maxd = 0;
|
int j, i, num, maxd = 0;
|
||||||
Visual *v = NULL;
|
Visual *v = NULL;
|
||||||
|
|
||||||
const int visprefs[] = {
|
const int visprefs[] = {
|
||||||
PseudoColor, TrueColor, DirectColor, StaticColor, GrayScale, StaticGray
|
PseudoColor, TrueColor, DirectColor, StaticColor, GrayScale, StaticGray
|
||||||
};
|
};
|
||||||
|
|
|
@ -668,7 +668,7 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
|
||||||
if (x_does_shm)
|
if (x_does_shm)
|
||||||
{
|
{
|
||||||
xim = __imlib_ShmGetXImage(d, v, p, xatt.depth, x, y, w, h, &shminfo);
|
xim = __imlib_ShmGetXImage(d, v, p, xatt.depth, x, y, w, h, &shminfo);
|
||||||
is_shm = !!xim;
|
is_shm = ! !xim;
|
||||||
}
|
}
|
||||||
if (!xim)
|
if (!xim)
|
||||||
xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
|
xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
|
||||||
|
@ -683,7 +683,7 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
|
||||||
if ((m) && (domask))
|
if ((m) && (domask))
|
||||||
{
|
{
|
||||||
mxim = __imlib_ShmGetXImage(d, v, m, 1, 0, 0, w, h, &mshminfo);
|
mxim = __imlib_ShmGetXImage(d, v, m, 1, 0, 0, w, h, &mshminfo);
|
||||||
is_mshm = !!mxim;
|
is_mshm = ! !mxim;
|
||||||
if (!mxim)
|
if (!mxim)
|
||||||
mxim = XGetImage(d, m, 0, 0, w, h, 0xffffffff, ZPixmap);
|
mxim = XGetImage(d, m, 0, 0, w, h, 0xffffffff, ZPixmap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef BUILD_X11
|
#ifdef BUILD_X11
|
||||||
# include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#endif
|
#endif
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
|
@ -136,18 +136,14 @@ __imlib_RenderGetPixel(Display * d, Drawable w, Visual * v, Colormap cm,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__hidden void
|
static void
|
||||||
__imlib_generic_render(DATA32 * src, int jump, int w, int h, int dx, int dy,
|
|
||||||
XImage * xim, Visual * v,
|
|
||||||
Context * ct);
|
|
||||||
|
|
||||||
void
|
|
||||||
__imlib_generic_render(DATA32 * src, int jump, int w, int h, int dx, int dy,
|
__imlib_generic_render(DATA32 * src, int jump, int w, int h, int dx, int dy,
|
||||||
XImage * xim, Visual * v, Context * ct)
|
XImage * xim, Visual * v, Context * ct)
|
||||||
{
|
{
|
||||||
unsigned int x, y, r, g, b, val, hh;
|
unsigned int x, y, r, g, b, val, hh;
|
||||||
unsigned int rmask, gmask, bmask;
|
unsigned int rmask, gmask, bmask;
|
||||||
int i, rshift, gshift, bshift;
|
int i, rshift, gshift, bshift;
|
||||||
|
|
||||||
const DATA8 _dither_88[8][8] = {
|
const DATA8 _dither_88[8][8] = {
|
||||||
{0, 32, 8, 40, 2, 34, 10, 42},
|
{0, 32, 8, 40, 2, 34, 10, 42},
|
||||||
{48, 16, 56, 24, 50, 18, 58, 26},
|
{48, 16, 56, 24, 50, 18, 58, 26},
|
||||||
|
|
|
@ -2327,12 +2327,12 @@ dest += 2; src += 2; \
|
||||||
#if 0 /* Old fixed-threshold macros - Remove? */
|
#if 0 /* Old fixed-threshold macros - Remove? */
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
# define WRITE1_RGBA_A1(src, dest) \
|
#define WRITE1_RGBA_A1(src, dest) \
|
||||||
*dest |= ((*src & 0x80000000) >> (24 + (x & 0x7))); \
|
*dest |= ((*src & 0x80000000) >> (24 + (x & 0x7))); \
|
||||||
if ((x & 0x7) == 0x7) dest++; \
|
if ((x & 0x7) == 0x7) dest++; \
|
||||||
src++
|
src++
|
||||||
#else
|
#else
|
||||||
# define WRITE1_RGBA_A1(src, dest) \
|
#define WRITE1_RGBA_A1(src, dest) \
|
||||||
*dest |= ((*src & 0x80000000) >> (31 - (x & 0x7))); \
|
*dest |= ((*src & 0x80000000) >> (31 - (x & 0x7))); \
|
||||||
if ((x & 0x7) == 0x7) dest++; \
|
if ((x & 0x7) == 0x7) dest++; \
|
||||||
src++
|
src++
|
||||||
|
@ -2341,13 +2341,13 @@ src++
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
# define WRITE1_RGBA_A1(src, dest, threshold) \
|
#define WRITE1_RGBA_A1(src, dest, threshold) \
|
||||||
if ((*src >> 24) >= threshold) \
|
if ((*src >> 24) >= threshold) \
|
||||||
*dest |= (1 << (7 - (x & 0x7))); \
|
*dest |= (1 << (7 - (x & 0x7))); \
|
||||||
if ((x & 0x7) == 0x7) dest++; \
|
if ((x & 0x7) == 0x7) dest++; \
|
||||||
src++
|
src++
|
||||||
#else
|
#else
|
||||||
# define WRITE1_RGBA_A1(src, dest, threshold) \
|
#define WRITE1_RGBA_A1(src, dest, threshold) \
|
||||||
if ((*src >> 24) >= threshold) \
|
if ((*src >> 24) >= threshold) \
|
||||||
*dest |= (1 << (x & 0x7)); \
|
*dest |= (1 << (x & 0x7)); \
|
||||||
if ((x & 0x7) == 0x7) dest++; \
|
if ((x & 0x7) == 0x7) dest++; \
|
||||||
|
@ -2359,7 +2359,7 @@ src++
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* MACROS for dithered RGBA -> A1 conversion */
|
/* MACROS for dithered RGBA -> A1 conversion */
|
||||||
/* FIXME: Mask alpha threshold is not handled (thus the default 128 is used) */
|
/* FIXME: Mask alpha threshold is not handled (thus the default 128 is used) */
|
||||||
# define DITHER_RGBA_A1_LUT(num) \
|
#define DITHER_RGBA_A1_LUT(num) \
|
||||||
(_dither_a1[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 24))])
|
(_dither_a1[(((x + num) & 0x7) << DM_BS1) | ((y & 0x7) << DM_BS2) | ((src[num] >> 24))])
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
#define WRITE1_RGBA_A1_DITHER(src, dest, threshold) \
|
#define WRITE1_RGBA_A1_DITHER(src, dest, threshold) \
|
||||||
|
@ -2382,7 +2382,7 @@ src++;
|
||||||
/* MACROS for plain RGBA -> RGB8888 conversion */
|
/* MACROS for plain RGBA -> RGB8888 conversion */
|
||||||
#define WRITE1_RGBA_RGB8888(src, dest) \
|
#define WRITE1_RGBA_RGB8888(src, dest) \
|
||||||
*dest = *src; dest++; src++;
|
*dest = *src; dest++; src++;
|
||||||
# define WRITE1_RGBA_BGR8888(src, dest) \
|
#define WRITE1_RGBA_BGR8888(src, dest) \
|
||||||
*dest = (((*src) >> 16) & 0x0000ff) | \
|
*dest = (((*src) >> 16) & 0x0000ff) | \
|
||||||
(((*src) ) & 0x00ff00) | \
|
(((*src) ) & 0x00ff00) | \
|
||||||
(((*src) << 16) & 0xff0000); dest++; src++;
|
(((*src) << 16) & 0xff0000); dest++; src++;
|
||||||
|
|
|
@ -604,16 +604,16 @@ __imlib_copy_alpha_data(ImlibImage * src, ImlibImage * dst, int x, int y,
|
||||||
jump = (src->w - w);
|
jump = (src->w - w);
|
||||||
jump2 = (dst->w - w);
|
jump2 = (dst->w - w);
|
||||||
|
|
||||||
/* work our way thru the array */
|
/* work our way thru the array */
|
||||||
for (yy = 0; yy < h; yy++)
|
for (yy = 0; yy < h; yy++)
|
||||||
{
|
{
|
||||||
for (xx = 0; xx < w; xx++)
|
for (xx = 0; xx < w; xx++)
|
||||||
{
|
{
|
||||||
*p2 = (*p1 & 0xff000000) | (*p2 & 0x00ffffff);
|
*p2 = (*p1 & 0xff000000) | (*p2 & 0x00ffffff);
|
||||||
p1++;
|
p1++;
|
||||||
p2++;
|
p2++;
|
||||||
}
|
}
|
||||||
p1 += jump;
|
p1 += jump;
|
||||||
p2 += jump2;
|
p2 += jump2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef BUILD_X11
|
#ifdef BUILD_X11
|
||||||
# include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#else
|
#else
|
||||||
# define X_DISPLAY_MISSING
|
#define X_DISPLAY_MISSING
|
||||||
#endif
|
#endif
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
#define FDEBUG 1
|
#define FDEBUG 1
|
||||||
*/
|
*/
|
||||||
#ifdef FDEBUG
|
#ifdef FDEBUG
|
||||||
# define D( str ) printf( "DEBUG: %s\n", str )
|
#define D( str ) printf( "DEBUG: %s\n", str )
|
||||||
#else
|
#else
|
||||||
#define D( str )
|
#define D( str )
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1194,7 +1194,7 @@ __imlib_GetPointDrawFunction(ImlibOp op, char dst_alpha, char blend)
|
||||||
if (opi == -1)
|
if (opi == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return ptfuncs[opi][!!dst_alpha][!!blend];
|
return ptfuncs[opi][! !dst_alpha][! !blend];
|
||||||
}
|
}
|
||||||
|
|
||||||
ImlibSpanDrawFunction
|
ImlibSpanDrawFunction
|
||||||
|
@ -1222,7 +1222,7 @@ __imlib_GetSpanDrawFunction(ImlibOp op, char dst_alpha, char blend)
|
||||||
if (opi == -1)
|
if (opi == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return spanfuncs[opi][!!dst_alpha][!!blend];
|
return spanfuncs[opi][! !dst_alpha][! !blend];
|
||||||
}
|
}
|
||||||
|
|
||||||
ImlibShapedSpanDrawFunction
|
ImlibShapedSpanDrawFunction
|
||||||
|
@ -1250,5 +1250,5 @@ __imlib_GetShapedSpanDrawFunction(ImlibOp op, char dst_alpha, char blend)
|
||||||
if (opi == -1)
|
if (opi == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return shapedspanfuncs[opi][!!dst_alpha][!!blend];
|
return shapedspanfuncs[opi][! !dst_alpha][! !blend];
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,8 +252,8 @@ init(struct imlib_filter_info *info)
|
||||||
info->name = strdup("Bump Mapping");
|
info->name = strdup("Bump Mapping");
|
||||||
info->author = strdup("Willem Monsuwe (willem@stack.nl)");
|
info->author = strdup("Willem Monsuwe (willem@stack.nl)");
|
||||||
info->description =
|
info->description =
|
||||||
strdup
|
strdup
|
||||||
("Provides bumpmapping to a point and bumpmapping from an infinite light source. *very* cool.");
|
("Provides bumpmapping to a point and bumpmapping from an infinite light source. *very* cool.");
|
||||||
info->num_filters = i;
|
info->num_filters = i;
|
||||||
info->filters = malloc(sizeof(char *) * i);
|
info->filters = malloc(sizeof(char *) * i);
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
|
|
|
@ -232,7 +232,7 @@ init(struct imlib_filter_info *info)
|
||||||
info->name = strdup("Tinting");
|
info->name = strdup("Tinting");
|
||||||
info->author = strdup("Willem Monsuwe (willem@stack.nl)");
|
info->author = strdup("Willem Monsuwe (willem@stack.nl)");
|
||||||
info->description =
|
info->description =
|
||||||
strdup("Provides most common color modification filters.");
|
strdup("Provides most common color modification filters.");
|
||||||
info->num_filters = i;
|
info->num_filters = i;
|
||||||
info->filters = malloc(sizeof(char *) * i);
|
info->filters = malloc(sizeof(char *) * i);
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
|
|
|
@ -10,8 +10,8 @@ init(struct imlib_filter_info *info)
|
||||||
info->name = strdup("Test Filter");
|
info->name = strdup("Test Filter");
|
||||||
info->author = strdup("Chris Ross - Boris - chris@darkrock.co.uk");
|
info->author = strdup("Chris Ross - Boris - chris@darkrock.co.uk");
|
||||||
info->description =
|
info->description =
|
||||||
strdup
|
strdup
|
||||||
("This filter is used to show that the imlib2 filter system works!");
|
("This filter is used to show that the imlib2 filter system works!");
|
||||||
info->num_filters = 3;
|
info->num_filters = 3;
|
||||||
info->filters = malloc(sizeof(char *) * 3);
|
info->filters = malloc(sizeof(char *) * 3);
|
||||||
for (i = 0; i < info->num_filters; i++)
|
for (i = 0; i < info->num_filters; i++)
|
||||||
|
|
|
@ -37,10 +37,10 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!IMAGE_DIMENSIONS_OK(w, h))
|
if (!IMAGE_DIMENSIONS_OK(w, h))
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
im->w = w;
|
im->w = w;
|
||||||
im->h = h;
|
im->h = h;
|
||||||
if (!im->format)
|
if (!im->format)
|
||||||
|
|
|
@ -25,9 +25,9 @@ typedef struct tagRGBQUAD {
|
||||||
|
|
||||||
/* 21.3.3006 - Use enumeration for RLE encoding. This makes it more readable */
|
/* 21.3.3006 - Use enumeration for RLE encoding. This makes it more readable */
|
||||||
enum {
|
enum {
|
||||||
RLE_NEXT = 0, /* Next line */
|
RLE_NEXT = 0, /* Next line */
|
||||||
RLE_END = 1, /* End of RLE encoding */
|
RLE_END = 1, /* End of RLE encoding */
|
||||||
RLE_MOVE = 2 /* Move by X and Y (Offset is stored in two next bytes) */
|
RLE_MOVE = 2 /* Move by X and Y (Offset is stored in two next bytes) */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -38,7 +38,7 @@ ReadleShort(FILE * file, unsigned short *ret)
|
||||||
if (fread(b, sizeof(unsigned char), 2, file) != 2)
|
if (fread(b, sizeof(unsigned char), 2, file) != 2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*ret = (b[1] << 8) | b[0];
|
*ret = (b[1] << 8) | b[0];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ ReadleLong(FILE * file, unsigned long *ret)
|
||||||
static int
|
static int
|
||||||
WriteleByte(FILE * file, unsigned char val)
|
WriteleByte(FILE * file, unsigned char val)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = fputc ((int) val & 0xff, file);
|
rc = fputc((int)val & 0xff, file);
|
||||||
if (rc == EOF)
|
if (rc == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -69,12 +69,12 @@ WriteleByte(FILE * file, unsigned char val)
|
||||||
static int
|
static int
|
||||||
WriteleShort(FILE * file, unsigned short val)
|
WriteleShort(FILE * file, unsigned short val)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = fputc ((int) (val & 0xff), file);
|
rc = fputc((int)(val & 0xff), file);
|
||||||
if (rc == EOF)
|
if (rc == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
rc = fputc ((int) ((val >> 8) & 0xff), file);
|
rc = fputc((int)((val >> 8) & 0xff), file);
|
||||||
if (rc == EOF)
|
if (rc == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -84,18 +84,18 @@ WriteleShort(FILE * file, unsigned short val)
|
||||||
static int
|
static int
|
||||||
WriteleLong(FILE * file, unsigned long val)
|
WriteleLong(FILE * file, unsigned long val)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = fputc ((int) (val & 0xff), file);
|
rc = fputc((int)(val & 0xff), file);
|
||||||
if (rc == EOF)
|
if (rc == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
rc = fputc ((int) ((val >> 8) & 0xff), file);
|
rc = fputc((int)((val >> 8) & 0xff), file);
|
||||||
if (rc == EOF)
|
if (rc == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
rc = fputc ((int) ((val >> 16) & 0xff), file);
|
rc = fputc((int)((val >> 16) & 0xff), file);
|
||||||
if (rc == EOF)
|
if (rc == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
rc = fputc ((int) ((val >> 24) & 0xff), file);
|
rc = fputc((int)((val >> 24) & 0xff), file);
|
||||||
if (rc == EOF)
|
if (rc == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -205,14 +205,16 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
if (headSize == 12)
|
if (headSize == 12)
|
||||||
{
|
{
|
||||||
ncols /= 3;
|
ncols /= 3;
|
||||||
if (ncols > 256) ncols = 256;
|
if (ncols > 256)
|
||||||
|
ncols = 256;
|
||||||
for (i = 0; i < ncols; i++)
|
for (i = 0; i < ncols; i++)
|
||||||
fread(&rgbQuads[i], 3, 1, f);
|
fread(&rgbQuads[i], 3, 1, f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ncols /= 4;
|
ncols /= 4;
|
||||||
if (ncols > 256) ncols = 256;
|
if (ncols > 256)
|
||||||
|
ncols = 256;
|
||||||
fread(rgbQuads, 4, ncols, f);
|
fread(rgbQuads, 4, ncols, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,23 +229,29 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
ReadleLong(f, &bmask);
|
ReadleLong(f, &bmask);
|
||||||
for (bit = bitcount - 1; bit >= 0; bit--)
|
for (bit = bitcount - 1; bit >= 0; bit--)
|
||||||
{
|
{
|
||||||
if (bmask & (1 << bit)) bshift = bit;
|
if (bmask & (1 << bit))
|
||||||
if (gmask & (1 << bit)) gshift = bit;
|
bshift = bit;
|
||||||
if (rmask & (1 << bit)) rshift = bit;
|
if (gmask & (1 << bit))
|
||||||
|
gshift = bit;
|
||||||
|
if (rmask & (1 << bit))
|
||||||
|
rshift = bit;
|
||||||
}
|
}
|
||||||
while(((((0xffffL & bmask) >> bshift) << bleftshift) & 0x80) == 0)
|
while (((((0xffffL & bmask) >> bshift) << bleftshift) & 0x80) ==
|
||||||
|
0)
|
||||||
{
|
{
|
||||||
bleftshift++;
|
bleftshift++;
|
||||||
}
|
}
|
||||||
while(((((0xffffL & gmask) >> gshift) << gleftshift) & 0x80) == 0)
|
while (((((0xffffL & gmask) >> gshift) << gleftshift) & 0x80) ==
|
||||||
|
0)
|
||||||
{
|
{
|
||||||
gleftshift++;
|
gleftshift++;
|
||||||
}
|
}
|
||||||
while(((((0xffffL & rmask) >> rshift) << rleftshift) & 0x80) == 0)
|
while (((((0xffffL & rmask) >> rshift) << rleftshift) & 0x80) ==
|
||||||
|
0)
|
||||||
{
|
{
|
||||||
rleftshift++;
|
rleftshift++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (bitcount == 16)
|
else if (bitcount == 16)
|
||||||
{
|
{
|
||||||
rmask = 0x7C00;
|
rmask = 0x7C00;
|
||||||
|
@ -311,9 +319,9 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
byte = *(buffer_ptr++);
|
byte = *(buffer_ptr++);
|
||||||
k = (byte >> 7) & 1;
|
k = (byte >> 7) & 1;
|
||||||
*ptr++ = 0xff000000 |
|
*ptr++ = 0xff000000 |
|
||||||
(rgbQuads[k].rgbRed << 16) |
|
(rgbQuads[k].rgbRed << 16) |
|
||||||
(rgbQuads[k].rgbGreen << 8) |
|
(rgbQuads[k].rgbGreen << 8) |
|
||||||
rgbQuads[k].rgbBlue;
|
rgbQuads[k].rgbBlue;
|
||||||
byte <<= 1;
|
byte <<= 1;
|
||||||
}
|
}
|
||||||
buffer_ptr += skip;
|
buffer_ptr += skip;
|
||||||
|
@ -353,7 +361,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
* - If we use 'byte = *(buffer_ptr++) in main loop we must check if
|
* - If we use 'byte = *(buffer_ptr++) in main loop we must check if
|
||||||
* 'buffer_ptr != buffer_end', because special or incomplete bmp file can generate
|
* 'buffer_ptr != buffer_end', because special or incomplete bmp file can generate
|
||||||
* segfault (I was writing it, because in RLE we need to read depending count of
|
* segfault (I was writing it, because in RLE we need to read depending count of
|
||||||
* bytes that depends on requester operation).
|
* bytes that depends on requester operation).
|
||||||
* SOLUTION: Don't read one byte, read two bytes and check.
|
* SOLUTION: Don't read one byte, read two bytes and check.
|
||||||
* - If RLE teels us than single color length will be larger than allowed, we can
|
* - If RLE teels us than single color length will be larger than allowed, we can
|
||||||
* stop, because bitmap is corrupted or crawled.
|
* stop, because bitmap is corrupted or crawled.
|
||||||
|
@ -372,89 +380,111 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
/*
|
/*
|
||||||
* 21.3.2006: This is better than using 'if buffer_ptr + 1 < buffer_end'
|
* 21.3.2006: This is better than using 'if buffer_ptr + 1 < buffer_end'
|
||||||
*/
|
*/
|
||||||
unsigned char *buffer_end_minus_1 = buffer_end - 1;
|
unsigned char *buffer_end_minus_1 = buffer_end - 1;
|
||||||
|
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
|
|
||||||
for (i = 0; i < imgsize && buffer_ptr < buffer_end_minus_1; i++)
|
for (i = 0; i < imgsize && buffer_ptr < buffer_end_minus_1;
|
||||||
|
i++)
|
||||||
{
|
{
|
||||||
byte1 = buffer_ptr[0];
|
byte1 = buffer_ptr[0];
|
||||||
byte2 = buffer_ptr[1];
|
byte2 = buffer_ptr[1];
|
||||||
buffer_ptr += 2;
|
buffer_ptr += 2;
|
||||||
if (byte1)
|
if (byte1)
|
||||||
{
|
{
|
||||||
DATA32 t1, t2;
|
DATA32 t1, t2;
|
||||||
|
|
||||||
l = byte1;
|
l = byte1;
|
||||||
/* Check for invalid length */
|
/* Check for invalid length */
|
||||||
if (l + x > w) goto _bail;
|
if (l + x > w)
|
||||||
|
goto _bail;
|
||||||
|
|
||||||
t1 = 0xff000000 | (rgbQuads[byte2 >> 4].rgbRed << 16) |
|
t1 = 0xff000000 |
|
||||||
(rgbQuads[byte2 >> 4].rgbGreen << 8) |
|
(rgbQuads[byte2 >> 4].rgbRed << 16) |
|
||||||
(rgbQuads[byte2 >> 4].rgbBlue ) ;
|
(rgbQuads[byte2 >> 4].rgbGreen << 8) |
|
||||||
t2 = 0xff000000 | (rgbQuads[byte2 & 0xF].rgbRed << 16) |
|
(rgbQuads[byte2 >> 4].rgbBlue);
|
||||||
(rgbQuads[byte2 & 0xF].rgbGreen << 8) |
|
t2 = 0xff000000 |
|
||||||
(rgbQuads[byte2 & 0xF].rgbBlue ) ;
|
(rgbQuads[byte2 & 0xF].rgbRed << 16) |
|
||||||
for (j = l/2; j; j--) {
|
(rgbQuads[byte2 & 0xF].rgbGreen << 8) |
|
||||||
ptr[0] = t1;
|
(rgbQuads[byte2 & 0xF].rgbBlue);
|
||||||
ptr[1] = t2;
|
for (j = l / 2; j; j--)
|
||||||
ptr += 2;
|
{
|
||||||
}
|
ptr[0] = t1;
|
||||||
|
ptr[1] = t2;
|
||||||
|
ptr += 2;
|
||||||
|
}
|
||||||
/* tail */
|
/* tail */
|
||||||
if (l & 1) *ptr++ = t1;
|
if (l & 1)
|
||||||
|
*ptr++ = t1;
|
||||||
x += l;
|
x += l;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (byte2)
|
switch (byte2)
|
||||||
{
|
{
|
||||||
case RLE_NEXT:
|
case RLE_NEXT:
|
||||||
x = 0;
|
x = 0;
|
||||||
if (++y >= h) goto _bail;
|
if (++y >= h)
|
||||||
ptr = im->data + (h - y - 1) * w;
|
goto _bail;
|
||||||
break;
|
ptr = im->data + (h - y - 1) * w;
|
||||||
case RLE_END:
|
break;
|
||||||
goto _bail;
|
case RLE_END:
|
||||||
case RLE_MOVE:
|
goto _bail;
|
||||||
/* Need to read two bytes */
|
case RLE_MOVE:
|
||||||
if (buffer_ptr >= buffer_end_minus_1) goto _bail;
|
/* Need to read two bytes */
|
||||||
x += buffer_ptr[0];
|
if (buffer_ptr >= buffer_end_minus_1)
|
||||||
y += buffer_ptr[1];
|
goto _bail;
|
||||||
buffer_ptr += 2;
|
x += buffer_ptr[0];
|
||||||
/* Check for correct coordinates */
|
y += buffer_ptr[1];
|
||||||
if (x >= w) goto _bail;
|
buffer_ptr += 2;
|
||||||
if (y >= h) goto _bail;
|
/* Check for correct coordinates */
|
||||||
ptr = im->data + (h - y - 1) * w + x;
|
if (x >= w)
|
||||||
break;
|
goto _bail;
|
||||||
default:
|
if (y >= h)
|
||||||
l = byte2;
|
goto _bail;
|
||||||
/* Check for invalid length and valid buffer size */
|
ptr = im->data + (h - y - 1) * w + x;
|
||||||
if (l + x > w) goto _bail;
|
break;
|
||||||
if (buffer_ptr + (l >> 1) + (l & 1) > buffer_end) goto _bail;
|
default:
|
||||||
|
l = byte2;
|
||||||
|
/* Check for invalid length and valid buffer size */
|
||||||
|
if (l + x > w)
|
||||||
|
goto _bail;
|
||||||
|
if (buffer_ptr + (l >> 1) + (l & 1) >
|
||||||
|
buffer_end)
|
||||||
|
goto _bail;
|
||||||
|
|
||||||
for (j = l/2; j; j--) {
|
for (j = l / 2; j; j--)
|
||||||
byte = *buffer_ptr++;
|
{
|
||||||
ptr[0] = 0xff000000 | (rgbQuads[byte >> 4].rgbRed << 16) |
|
byte = *buffer_ptr++;
|
||||||
(rgbQuads[byte >> 4].rgbGreen << 8) |
|
ptr[0] =
|
||||||
(rgbQuads[byte >> 4].rgbBlue ) ;
|
0xff000000 |
|
||||||
ptr[1] = 0xff000000 | (rgbQuads[byte & 0xF].rgbRed << 16) |
|
(rgbQuads[byte >> 4].rgbRed << 16) |
|
||||||
(rgbQuads[byte & 0xF].rgbGreen << 8) |
|
(rgbQuads[byte >> 4].rgbGreen << 8) |
|
||||||
(rgbQuads[byte & 0xF].rgbBlue ) ;
|
(rgbQuads[byte >> 4].rgbBlue);
|
||||||
ptr += 2;
|
ptr[1] =
|
||||||
|
0xff000000 |
|
||||||
|
(rgbQuads[byte & 0xF].rgbRed << 16) |
|
||||||
|
(rgbQuads[byte & 0xF].rgbGreen << 8) |
|
||||||
|
(rgbQuads[byte & 0xF].rgbBlue);
|
||||||
|
ptr += 2;
|
||||||
}
|
}
|
||||||
if (l & 1) {
|
if (l & 1)
|
||||||
byte = *buffer_ptr++;
|
{
|
||||||
*ptr++ = 0xff000000 | (rgbQuads[byte >> 4].rgbRed << 16) |
|
byte = *buffer_ptr++;
|
||||||
(rgbQuads[byte >> 4].rgbGreen << 8) |
|
*ptr++ =
|
||||||
(rgbQuads[byte >> 4].rgbBlue ) ;
|
0xff000000 |
|
||||||
|
(rgbQuads[byte >> 4].rgbRed << 16) |
|
||||||
|
(rgbQuads[byte >> 4].rgbGreen << 8) |
|
||||||
|
(rgbQuads[byte >> 4].rgbBlue);
|
||||||
}
|
}
|
||||||
x += l;
|
x += l;
|
||||||
|
|
||||||
if ((l & 3) == 1)
|
if ((l & 3) == 1)
|
||||||
buffer_ptr += 2;
|
buffer_ptr += 2;
|
||||||
else if ((l & 3) == 2)
|
else if ((l & 3) == 2)
|
||||||
buffer_ptr++;
|
buffer_ptr++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (progress)
|
if (progress)
|
||||||
|
@ -492,9 +522,9 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
byte = *(buffer_ptr++);
|
byte = *(buffer_ptr++);
|
||||||
k = (byte & 0xF0) >> 4;
|
k = (byte & 0xF0) >> 4;
|
||||||
*ptr++ = 0xff000000 |
|
*ptr++ = 0xff000000 |
|
||||||
(rgbQuads[k].rgbRed << 16) |
|
(rgbQuads[k].rgbRed << 16) |
|
||||||
(rgbQuads[k].rgbGreen << 8) |
|
(rgbQuads[k].rgbGreen << 8) |
|
||||||
rgbQuads[k].rgbBlue;
|
rgbQuads[k].rgbBlue;
|
||||||
byte <<= 4;
|
byte <<= 4;
|
||||||
}
|
}
|
||||||
buffer_ptr += skip;
|
buffer_ptr += skip;
|
||||||
|
@ -530,63 +560,74 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
/*
|
/*
|
||||||
* 21.3.2006: This is better than using 'if buffer_ptr + 1 < buffer_end'
|
* 21.3.2006: This is better than using 'if buffer_ptr + 1 < buffer_end'
|
||||||
*/
|
*/
|
||||||
unsigned char *buffer_end_minus_1 = buffer_end - 1;
|
unsigned char *buffer_end_minus_1 = buffer_end - 1;
|
||||||
|
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
for (i = 0; i < imgsize && buffer_ptr < buffer_end_minus_1; i++)
|
for (i = 0; i < imgsize && buffer_ptr < buffer_end_minus_1;
|
||||||
|
i++)
|
||||||
{
|
{
|
||||||
byte1 = buffer_ptr[0];
|
byte1 = buffer_ptr[0];
|
||||||
byte2 = buffer_ptr[1];
|
byte2 = buffer_ptr[1];
|
||||||
buffer_ptr += 2;
|
buffer_ptr += 2;
|
||||||
if (byte1)
|
if (byte1)
|
||||||
{
|
{
|
||||||
DATA32 pix = 0xff000000 | (rgbQuads[byte2].rgbRed << 16) |
|
DATA32 pix =
|
||||||
(rgbQuads[byte2].rgbGreen << 8) |
|
0xff000000 | (rgbQuads[byte2].rgbRed << 16) |
|
||||||
(rgbQuads[byte2].rgbBlue ) ;
|
(rgbQuads[byte2].rgbGreen << 8) |
|
||||||
|
(rgbQuads[byte2].rgbBlue);
|
||||||
l = byte1;
|
l = byte1;
|
||||||
if (x + l > w) goto _bail;
|
if (x + l > w)
|
||||||
for (j = l; j; j--) *ptr++ = pix;
|
goto _bail;
|
||||||
|
for (j = l; j; j--)
|
||||||
|
*ptr++ = pix;
|
||||||
x += l;
|
x += l;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (byte2)
|
switch (byte2)
|
||||||
{
|
{
|
||||||
case RLE_NEXT:
|
case RLE_NEXT:
|
||||||
x = 0;
|
x = 0;
|
||||||
if (++y >= h) goto _bail;
|
if (++y >= h)
|
||||||
ptr = im->data + ((h - y - 1) * w) + x;
|
goto _bail;
|
||||||
break;
|
ptr = im->data + ((h - y - 1) * w) + x;
|
||||||
case RLE_END:
|
break;
|
||||||
goto _bail;
|
case RLE_END:
|
||||||
case RLE_MOVE:
|
goto _bail;
|
||||||
/* Need to read two bytes */
|
case RLE_MOVE:
|
||||||
if (buffer_ptr >= buffer_end_minus_1) goto _bail;
|
/* Need to read two bytes */
|
||||||
x += buffer_ptr[0];
|
if (buffer_ptr >= buffer_end_minus_1)
|
||||||
y += buffer_ptr[1];
|
goto _bail;
|
||||||
buffer_ptr += 2;
|
x += buffer_ptr[0];
|
||||||
/* Check for correct coordinates */
|
y += buffer_ptr[1];
|
||||||
if (x >= w) goto _bail;
|
buffer_ptr += 2;
|
||||||
if (y >= h) goto _bail;
|
/* Check for correct coordinates */
|
||||||
ptr = im->data + ((h - y - 1) * w) + x;
|
if (x >= w)
|
||||||
break;
|
goto _bail;
|
||||||
default:
|
if (y >= h)
|
||||||
l = byte2;
|
goto _bail;
|
||||||
if (x + l > w) goto _bail;
|
ptr = im->data + ((h - y - 1) * w) + x;
|
||||||
if (buffer_ptr + l > buffer_end) goto _bail;
|
break;
|
||||||
for (j = 0; j < l; j++)
|
default:
|
||||||
{
|
l = byte2;
|
||||||
byte = *(buffer_ptr++);
|
if (x + l > w)
|
||||||
|
goto _bail;
|
||||||
|
if (buffer_ptr + l > buffer_end)
|
||||||
|
goto _bail;
|
||||||
|
for (j = 0; j < l; j++)
|
||||||
|
{
|
||||||
|
byte = *(buffer_ptr++);
|
||||||
|
|
||||||
*ptr++ = 0xff000000 |
|
*ptr++ = 0xff000000 |
|
||||||
(rgbQuads[byte].rgbRed << 16) |
|
(rgbQuads[byte].rgbRed << 16) |
|
||||||
(rgbQuads[byte].rgbGreen << 8) |
|
(rgbQuads[byte].rgbGreen << 8) |
|
||||||
rgbQuads[byte].rgbBlue;
|
rgbQuads[byte].rgbBlue;
|
||||||
}
|
}
|
||||||
x += l;
|
x += l;
|
||||||
if (l & 1)
|
if (l & 1)
|
||||||
buffer_ptr++;
|
buffer_ptr++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -621,9 +662,9 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
{
|
{
|
||||||
byte = *(buffer_ptr++);
|
byte = *(buffer_ptr++);
|
||||||
*ptr++ = 0xff000000 |
|
*ptr++ = 0xff000000 |
|
||||||
(rgbQuads[byte].rgbRed << 16) |
|
(rgbQuads[byte].rgbRed << 16) |
|
||||||
(rgbQuads[byte].rgbGreen << 8) |
|
(rgbQuads[byte].rgbGreen << 8) |
|
||||||
rgbQuads[byte].rgbBlue;
|
rgbQuads[byte].rgbBlue;
|
||||||
}
|
}
|
||||||
ptr -= w * 2;
|
ptr -= w * 2;
|
||||||
buffer_ptr += skip;
|
buffer_ptr += skip;
|
||||||
|
@ -655,7 +696,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
else if (bitcount == 16)
|
else if (bitcount == 16)
|
||||||
{
|
{
|
||||||
/* 21.3.2006 - Need to check for buffer_ptr + 1 < buffer_end */
|
/* 21.3.2006 - Need to check for buffer_ptr + 1 < buffer_end */
|
||||||
unsigned char *buffer_end_minus_1 = buffer_end - 1;
|
unsigned char *buffer_end_minus_1 = buffer_end - 1;
|
||||||
|
|
||||||
skip = (((w * 16 + 31) / 32) * 4) - (w * 2);
|
skip = (((w * 16 + 31) / 32) * 4) - (w * 2);
|
||||||
for (y = 0; y < h; y++)
|
for (y = 0; y < h; y++)
|
||||||
{
|
{
|
||||||
|
@ -670,10 +712,13 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
* bshift;
|
* bshift;
|
||||||
* *ptr++ = 0xff000000 | (r << 16) | (g << 8) | b;
|
* *ptr++ = 0xff000000 | (r << 16) | (g << 8) | b;
|
||||||
*/
|
*/
|
||||||
unsigned short pix = *(unsigned short *)buffer_ptr;
|
unsigned short pix = *(unsigned short *)buffer_ptr;
|
||||||
*ptr++ = 0xff000000 | ((((pix & rmask) >> rshift) << rleftshift) << 16) |
|
|
||||||
((((pix & gmask) >> gshift) << gleftshift) << 8) |
|
*ptr++ =
|
||||||
((((pix & bmask) >> bshift) << bleftshift) ) ;
|
0xff000000 |
|
||||||
|
((((pix & rmask) >> rshift) << rleftshift) << 16) |
|
||||||
|
((((pix & gmask) >> gshift) << gleftshift) << 8) |
|
||||||
|
((((pix & bmask) >> bshift) << bleftshift));
|
||||||
buffer_ptr += 2;
|
buffer_ptr += 2;
|
||||||
}
|
}
|
||||||
ptr -= w * 2;
|
ptr -= w * 2;
|
||||||
|
@ -704,7 +749,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
else if (bitcount == 24)
|
else if (bitcount == 24)
|
||||||
{
|
{
|
||||||
/* 21.3.2006 - Fix: need to check for buffer_ptr + 2 < buffer_end */
|
/* 21.3.2006 - Fix: need to check for buffer_ptr + 2 < buffer_end */
|
||||||
unsigned char *buffer_end_minus_2 = buffer_end - 2;
|
unsigned char *buffer_end_minus_2 = buffer_end - 2;
|
||||||
|
|
||||||
skip = (4 - ((w * 3) % 4)) & 3;
|
skip = (4 - ((w * 3) % 4)) & 3;
|
||||||
for (y = 0; y < h; y++)
|
for (y = 0; y < h; y++)
|
||||||
{
|
{
|
||||||
|
@ -743,7 +789,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
else if (bitcount == 32)
|
else if (bitcount == 32)
|
||||||
{
|
{
|
||||||
/* 21.3.2006 - Need to check buffer_ptr + 3 < buffer_end */
|
/* 21.3.2006 - Need to check buffer_ptr + 3 < buffer_end */
|
||||||
unsigned char *buffer_end_minus_3 = buffer_end_minus_3;
|
unsigned char *buffer_end_minus_3 = buffer_end_minus_3;
|
||||||
|
|
||||||
skip = (((w * 32 + 31) / 32) * 4) - (w * 4);
|
skip = (((w * 32 + 31) / 32) * 4) - (w * 4);
|
||||||
for (y = 0; y < h; y++)
|
for (y = 0; y < h; y++)
|
||||||
{
|
{
|
||||||
|
@ -761,10 +808,11 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* TODO: What about alpha channel...Is used? */
|
/* TODO: What about alpha channel...Is used? */
|
||||||
DATA32 pix = *(unsigned int *)buffer_ptr;
|
DATA32 pix = *(unsigned int *)buffer_ptr;
|
||||||
|
|
||||||
*ptr++ = 0xff000000 | (((pix & rmask) >> rshift) << 16) |
|
*ptr++ = 0xff000000 | (((pix & rmask) >> rshift) << 16) |
|
||||||
(((pix & gmask) >> gshift) << 8) |
|
(((pix & gmask) >> gshift) << 8) |
|
||||||
(((pix & bmask) >> bshift) ) ;
|
(((pix & bmask) >> bshift));
|
||||||
buffer_ptr += 4;
|
buffer_ptr += 4;
|
||||||
}
|
}
|
||||||
ptr -= w * 2;
|
ptr -= w * 2;
|
||||||
|
@ -792,7 +840,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bail:
|
_bail:
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -816,36 +864,36 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
|
||||||
pad = (4 - ((im->w * 3) % 4)) & 0x03;
|
pad = (4 - ((im->w * 3) % 4)) & 0x03;
|
||||||
|
|
||||||
/* write BMP file header */
|
/* write BMP file header */
|
||||||
WriteleShort(f, 0x4d42); /* prefix */
|
WriteleShort(f, 0x4d42); /* prefix */
|
||||||
WriteleLong(f, 54 + 3 * im->w * im->h); /* filesize */
|
WriteleLong(f, 54 + 3 * im->w * im->h); /* filesize */
|
||||||
WriteleShort(f, 0x0000); /* reserved #1 */
|
WriteleShort(f, 0x0000); /* reserved #1 */
|
||||||
WriteleShort(f, 0x0000); /* reserved #2 */
|
WriteleShort(f, 0x0000); /* reserved #2 */
|
||||||
WriteleLong(f, 54); /* offset to image data */
|
WriteleLong(f, 54); /* offset to image data */
|
||||||
|
|
||||||
/* write BMP bitmap header */
|
/* write BMP bitmap header */
|
||||||
WriteleLong(f, 40); /* 40-byte header */
|
WriteleLong(f, 40); /* 40-byte header */
|
||||||
WriteleLong(f, im->w);
|
WriteleLong(f, im->w);
|
||||||
WriteleLong(f, im->h);
|
WriteleLong(f, im->h);
|
||||||
WriteleShort(f, 1); /* one plane */
|
WriteleShort(f, 1); /* one plane */
|
||||||
WriteleShort(f, 24); /* bits per pixel */
|
WriteleShort(f, 24); /* bits per pixel */
|
||||||
WriteleLong(f, 0); /* no compression */
|
WriteleLong(f, 0); /* no compression */
|
||||||
WriteleLong(f, 3 * im->w * im->h);
|
WriteleLong(f, 3 * im->w * im->h);
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
WriteleLong(f, 0x0000); /* pad to end of header */
|
WriteleLong(f, 0x0000); /* pad to end of header */
|
||||||
|
|
||||||
/* write actual BMP data */
|
/* write actual BMP data */
|
||||||
for (i = 0; i < im->h; i++)
|
for (i = 0; i < im->h; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < im->w; j++)
|
for (j = 0; j < im->w; j++)
|
||||||
{
|
{
|
||||||
imlib_image_query_pixel (j, im->h - i - 1, &pixel_color);
|
imlib_image_query_pixel(j, im->h - i - 1, &pixel_color);
|
||||||
WriteleByte(f, pixel_color.blue);
|
WriteleByte(f, pixel_color.blue);
|
||||||
WriteleByte(f, pixel_color.green);
|
WriteleByte(f, pixel_color.green);
|
||||||
WriteleByte(f, pixel_color.red);
|
WriteleByte(f, pixel_color.red);
|
||||||
}
|
}
|
||||||
for (j = 0; j < pad; j++)
|
for (j = 0; j < pad; j++)
|
||||||
WriteleByte(f, 0);
|
WriteleByte(f, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -8,115 +8,127 @@
|
||||||
#define OUTBUF_SIZE 16384
|
#define OUTBUF_SIZE 16384
|
||||||
#define INBUF_SIZE 1024
|
#define INBUF_SIZE 1024
|
||||||
|
|
||||||
static int uncompress_file (FILE *fp, int dest)
|
static int
|
||||||
|
uncompress_file(FILE * fp, int dest)
|
||||||
{
|
{
|
||||||
BZFILE *bf;
|
BZFILE *bf;
|
||||||
DATA8 outbuf[OUTBUF_SIZE];
|
DATA8 outbuf[OUTBUF_SIZE];
|
||||||
int bytes, error, ret = 1;
|
int bytes, error, ret = 1;
|
||||||
|
|
||||||
bf = BZ2_bzReadOpen (&error, fp, 0, 0, NULL, 0);
|
bf = BZ2_bzReadOpen(&error, fp, 0, 0, NULL, 0);
|
||||||
|
|
||||||
if (error != BZ_OK) {
|
if (error != BZ_OK)
|
||||||
BZ2_bzReadClose (NULL, bf);
|
{
|
||||||
return 0;
|
BZ2_bzReadClose(NULL, bf);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1)
|
||||||
bytes = BZ2_bzRead (&error, bf, &outbuf, OUTBUF_SIZE);
|
{
|
||||||
|
bytes = BZ2_bzRead(&error, bf, &outbuf, OUTBUF_SIZE);
|
||||||
|
|
||||||
if (error == BZ_OK || error == BZ_STREAM_END)
|
if (error == BZ_OK || error == BZ_STREAM_END)
|
||||||
write (dest, outbuf, bytes);
|
write(dest, outbuf, bytes);
|
||||||
|
|
||||||
if (error == BZ_STREAM_END)
|
if (error == BZ_STREAM_END)
|
||||||
break;
|
break;
|
||||||
else if (error != BZ_OK) {
|
else if (error != BZ_OK)
|
||||||
ret = 0;
|
{
|
||||||
break;
|
ret = 0;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BZ2_bzReadClose (&error, bf);
|
BZ2_bzReadClose(&error, bf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char load (ImlibImage *im, ImlibProgressFunction progress,
|
char
|
||||||
char progress_granularity, char immediate_load)
|
load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
|
char progress_granularity, char immediate_load)
|
||||||
{
|
{
|
||||||
ImlibLoader *loader;
|
ImlibLoader *loader;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int dest, res;
|
int dest, res;
|
||||||
char *file, tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX", *p;
|
char *file, tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX", *p;
|
||||||
char real_ext[16];
|
char real_ext[16];
|
||||||
|
|
||||||
assert (im);
|
assert(im);
|
||||||
|
|
||||||
/* make sure this file ends in ".bz2" and that there's another ext
|
/* make sure this file ends in ".bz2" and that there's another ext
|
||||||
* (e.g. "foo.png.bz2"
|
* (e.g. "foo.png.bz2"
|
||||||
*/
|
*/
|
||||||
p = strrchr(im->real_file, '.');
|
p = strrchr(im->real_file, '.');
|
||||||
if (p && p != im->real_file) {
|
if (p && p != im->real_file)
|
||||||
if (strcasecmp(p + 1, "bz2"))
|
{
|
||||||
return 0;
|
if (strcasecmp(p + 1, "bz2"))
|
||||||
} else
|
return 0;
|
||||||
return 0;
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
strncpy (real_ext, p - sizeof (real_ext) + 1, sizeof (real_ext));
|
strncpy(real_ext, p - sizeof(real_ext) + 1, sizeof(real_ext));
|
||||||
real_ext[sizeof (real_ext) - 1] = '\0';
|
real_ext[sizeof(real_ext) - 1] = '\0';
|
||||||
|
|
||||||
/* abort if there's no dot in the "real" filename */
|
/* abort if there's no dot in the "real" filename */
|
||||||
if (!strrchr (real_ext, '.'))
|
if (!strrchr(real_ext, '.'))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(fp = fopen (im->real_file, "rb"))) {
|
if (!(fp = fopen(im->real_file, "rb")))
|
||||||
return 0;
|
{
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((dest = mkstemp (tmp)) < 0) {
|
if ((dest = mkstemp(tmp)) < 0)
|
||||||
fclose (fp);
|
{
|
||||||
return 0;
|
fclose(fp);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
res = uncompress_file (fp, dest);
|
res = uncompress_file(fp, dest);
|
||||||
fclose (fp);
|
fclose(fp);
|
||||||
close (dest);
|
close(dest);
|
||||||
|
|
||||||
if (!res) {
|
if (!res)
|
||||||
unlink (tmp);
|
{
|
||||||
return 0;
|
unlink(tmp);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(loader = __imlib_FindBestLoaderForFile (real_ext, 0))) {
|
if (!(loader = __imlib_FindBestLoaderForFile(real_ext, 0)))
|
||||||
unlink (tmp);
|
{
|
||||||
return 0;
|
unlink(tmp);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* remember the original filename */
|
/* remember the original filename */
|
||||||
file = strdup (im->real_file);
|
file = strdup(im->real_file);
|
||||||
|
|
||||||
free (im->real_file);
|
free(im->real_file);
|
||||||
im->real_file = strdup (tmp);
|
im->real_file = strdup(tmp);
|
||||||
loader->load (im, progress, progress_granularity, immediate_load);
|
loader->load(im, progress, progress_granularity, immediate_load);
|
||||||
|
|
||||||
free (im->real_file);
|
free(im->real_file);
|
||||||
im->real_file = file;
|
im->real_file = file;
|
||||||
unlink (tmp);
|
unlink(tmp);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void formats (ImlibLoader *l)
|
void
|
||||||
|
formats(ImlibLoader * l)
|
||||||
{
|
{
|
||||||
/* this is the only bit you have to change... */
|
/* this is the only bit you have to change... */
|
||||||
char *list_formats[] = {"bz2"};
|
char *list_formats[] = { "bz2" };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* don't bother changing any of this - it just reads this in
|
/* don't bother changing any of this - it just reads this in
|
||||||
* and sets the struct values and makes copies
|
* and sets the struct values and makes copies
|
||||||
*/
|
*/
|
||||||
l->num_formats = sizeof (list_formats) / sizeof (char *);
|
l->num_formats = sizeof(list_formats) / sizeof(char *);
|
||||||
l->formats = malloc (sizeof (char *) * l->num_formats);
|
l->formats = malloc(sizeof(char *) * l->num_formats);
|
||||||
|
|
||||||
for (i = 0; i < l->num_formats; i++)
|
for (i = 0; i < l->num_formats; i++)
|
||||||
l->formats[i] = strdup (list_formats[i]);
|
l->formats[i] = strdup(list_formats[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,11 +58,11 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
}
|
}
|
||||||
w = gif->Image.Width;
|
w = gif->Image.Width;
|
||||||
h = gif->Image.Height;
|
h = gif->Image.Height;
|
||||||
if (!IMAGE_DIMENSIONS_OK(w, h))
|
if (!IMAGE_DIMENSIONS_OK(w, h))
|
||||||
{
|
{
|
||||||
DGifCloseFile(gif);
|
DGifCloseFile(gif);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
rows = malloc(h * sizeof(GifRowType *));
|
rows = malloc(h * sizeof(GifRowType *));
|
||||||
if (!rows)
|
if (!rows)
|
||||||
{
|
{
|
||||||
|
@ -126,7 +126,8 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
DGifGetExtensionNext(gif, &ext);
|
DGifGetExtensionNext(gif, &ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (rec != TERMINATE_RECORD_TYPE);
|
}
|
||||||
|
while (rec != TERMINATE_RECORD_TYPE);
|
||||||
if (transp >= 0)
|
if (transp >= 0)
|
||||||
{
|
{
|
||||||
SET_FLAG(im->flags, F_HAS_ALPHA);
|
SET_FLAG(im->flags, F_HAS_ALPHA);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -76,13 +76,13 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
{
|
{
|
||||||
im->w = w = cinfo.output_width;
|
im->w = w = cinfo.output_width;
|
||||||
im->h = h = cinfo.output_height;
|
im->h = h = cinfo.output_height;
|
||||||
if (!IMAGE_DIMENSIONS_OK(w, h))
|
if (!IMAGE_DIMENSIONS_OK(w, h))
|
||||||
{
|
{
|
||||||
im->w = im->h = 0;
|
im->w = im->h = 0;
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
UNSET_FLAG(im->flags, F_HAS_ALPHA);
|
UNSET_FLAG(im->flags, F_HAS_ALPHA);
|
||||||
im->format = strdup("jpeg");
|
im->format = strdup("jpeg");
|
||||||
}
|
}
|
||||||
|
@ -138,10 +138,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
{
|
{
|
||||||
for (x = 0; x < w; x++)
|
for (x = 0; x < w; x++)
|
||||||
{
|
{
|
||||||
*ptr2 =
|
*ptr2 = (0xff000000) | ((ptr[0]) << 16) |
|
||||||
(0xff000000) | ((ptr[0]) << 16) | ((ptr[1]) <<
|
((ptr[1]) << 8) | (ptr[2]);
|
||||||
8) |
|
|
||||||
(ptr[2]);
|
|
||||||
ptr += cinfo.output_components;
|
ptr += cinfo.output_components;
|
||||||
ptr2++;
|
ptr2++;
|
||||||
}
|
}
|
||||||
|
@ -184,10 +182,8 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
{
|
{
|
||||||
for (x = 0; x < w; x++)
|
for (x = 0; x < w; x++)
|
||||||
{
|
{
|
||||||
*ptr2 =
|
*ptr2 = (0xff000000) | ((ptr[0]) << 16) |
|
||||||
(0xff000000) | ((ptr[0]) << 16) | ((ptr[0]) <<
|
((ptr[0]) << 8) | (ptr[0]);
|
||||||
8) |
|
|
||||||
(ptr[0]);
|
|
||||||
ptr++;
|
ptr++;
|
||||||
ptr2++;
|
ptr2++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,123 +17,149 @@
|
||||||
#define L2RWORD(a) ((((long)((a)[0]) & 0xff) << 8) + ((long)((a)[1]) & 0xff))
|
#define L2RWORD(a) ((((long)((a)[0]) & 0xff) << 8) + ((long)((a)[1]) & 0xff))
|
||||||
|
|
||||||
typedef struct CHUNK {
|
typedef struct CHUNK {
|
||||||
long size;
|
long size;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
} CHUNK;
|
} CHUNK;
|
||||||
|
|
||||||
typedef struct ILBM {
|
typedef struct ILBM {
|
||||||
CHUNK bmhd;
|
CHUNK bmhd;
|
||||||
CHUNK camg;
|
CHUNK camg;
|
||||||
CHUNK cmap;
|
CHUNK cmap;
|
||||||
CHUNK ctbl;
|
CHUNK ctbl;
|
||||||
CHUNK sham;
|
CHUNK sham;
|
||||||
CHUNK body;
|
CHUNK body;
|
||||||
|
|
||||||
int depth;
|
int depth;
|
||||||
int mask;
|
int mask;
|
||||||
int ham;
|
int ham;
|
||||||
int hbrite;
|
int hbrite;
|
||||||
|
|
||||||
int row;
|
int row;
|
||||||
|
|
||||||
int offset;
|
int offset;
|
||||||
int count;
|
int count;
|
||||||
int rle;
|
int rle;
|
||||||
} ILBM;
|
} ILBM;
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Frees memory allocated as part of an ILBM structure.
|
* Frees memory allocated as part of an ILBM structure.
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
static void freeilbm(ILBM *ilbm)
|
static void
|
||||||
|
freeilbm(ILBM * ilbm)
|
||||||
{
|
{
|
||||||
if (ilbm->bmhd.data) free(ilbm->bmhd.data);
|
if (ilbm->bmhd.data)
|
||||||
if (ilbm->camg.data) free(ilbm->camg.data);
|
free(ilbm->bmhd.data);
|
||||||
if (ilbm->cmap.data) free(ilbm->cmap.data);
|
if (ilbm->camg.data)
|
||||||
if (ilbm->ctbl.data) free(ilbm->ctbl.data);
|
free(ilbm->camg.data);
|
||||||
if (ilbm->sham.data) free(ilbm->sham.data);
|
if (ilbm->cmap.data)
|
||||||
if (ilbm->body.data) free(ilbm->body.data);
|
free(ilbm->cmap.data);
|
||||||
|
if (ilbm->ctbl.data)
|
||||||
|
free(ilbm->ctbl.data);
|
||||||
|
if (ilbm->sham.data)
|
||||||
|
free(ilbm->sham.data);
|
||||||
|
if (ilbm->body.data)
|
||||||
|
free(ilbm->body.data);
|
||||||
|
|
||||||
memset(ilbm, 0, sizeof(*ilbm));
|
memset(ilbm, 0, sizeof(*ilbm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Reads the given chunks out of a file, returns 0 if the file had a problem.
|
* Reads the given chunks out of a file, returns 0 if the file had a problem.
|
||||||
*
|
*
|
||||||
* Format FORMsizeILBMtag.size....tag.size....tag.size....
|
* Format FORMsizeILBMtag.size....tag.size....tag.size....
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
static int loadchunks(char *name, ILBM *ilbm, int full)
|
static int
|
||||||
|
loadchunks(char *name, ILBM * ilbm, int full)
|
||||||
{
|
{
|
||||||
CHUNK *c;
|
CHUNK *c;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
size_t s;
|
size_t s;
|
||||||
long formsize, pos, z;
|
long formsize, pos, z;
|
||||||
int ok, seek;
|
int ok, seek;
|
||||||
char buf[12];
|
char buf[12];
|
||||||
|
|
||||||
ok = 0;
|
ok = 0;
|
||||||
|
|
||||||
f = fopen(name, "rb");
|
f = fopen(name, "rb");
|
||||||
if (f) {
|
if (f)
|
||||||
|
{
|
||||||
s = fread(buf, 1, 12, f);
|
s = fread(buf, 1, 12, f);
|
||||||
if (s == 12 && !memcmp(buf, "FORM", 4) && !memcmp(buf + 8, "ILBM", 4)) {
|
if (s == 12 && !memcmp(buf, "FORM", 4) && !memcmp(buf + 8, "ILBM", 4))
|
||||||
memset(ilbm, 0, sizeof(*ilbm));
|
{
|
||||||
formsize = L2RLONG(buf + 4);
|
memset(ilbm, 0, sizeof(*ilbm));
|
||||||
|
formsize = L2RLONG(buf + 4);
|
||||||
|
|
||||||
while (1) {
|
while (1)
|
||||||
pos = ftell(f);
|
{
|
||||||
if (pos < 0 || pos >= formsize + 8) break; /* Error or FORM data is finished. */
|
pos = ftell(f);
|
||||||
seek = 1;
|
if (pos < 0 || pos >= formsize + 8)
|
||||||
|
break; /* Error or FORM data is finished. */
|
||||||
|
seek = 1;
|
||||||
|
|
||||||
s = fread(buf, 1, 8, f);
|
s = fread(buf, 1, 8, f);
|
||||||
if (s != 8) break; /* Error or short file. */
|
if (s != 8)
|
||||||
|
break; /* Error or short file. */
|
||||||
|
|
||||||
z = L2RLONG(buf + 4);
|
z = L2RLONG(buf + 4);
|
||||||
if (z < 0) break; /* Corrupt file. */
|
if (z < 0)
|
||||||
|
break; /* Corrupt file. */
|
||||||
|
|
||||||
c = NULL;
|
c = NULL;
|
||||||
if (!memcmp(buf, "BMHD", 4)) c = &(ilbm->bmhd);
|
if (!memcmp(buf, "BMHD", 4))
|
||||||
else if (full) {
|
c = &(ilbm->bmhd);
|
||||||
if (!memcmp(buf, "CAMG", 4)) c = &(ilbm->camg);
|
else if (full)
|
||||||
else if (!memcmp(buf, "CMAP", 4)) c = &(ilbm->cmap);
|
{
|
||||||
else if (!memcmp(buf, "CTBL", 4)) c = &(ilbm->ctbl);
|
if (!memcmp(buf, "CAMG", 4))
|
||||||
else if (!memcmp(buf, "SHAM", 4)) c = &(ilbm->sham);
|
c = &(ilbm->camg);
|
||||||
else if (!memcmp(buf, "BODY", 4)) c = &(ilbm->body);
|
else if (!memcmp(buf, "CMAP", 4))
|
||||||
}
|
c = &(ilbm->cmap);
|
||||||
|
else if (!memcmp(buf, "CTBL", 4))
|
||||||
if (c && !c->data) {
|
c = &(ilbm->ctbl);
|
||||||
c->size = z;
|
else if (!memcmp(buf, "SHAM", 4))
|
||||||
c->data = malloc(c->size);
|
c = &(ilbm->sham);
|
||||||
if (!c->data) break; /* Out of memory. */
|
else if (!memcmp(buf, "BODY", 4))
|
||||||
|
c = &(ilbm->body);
|
||||||
s = fread(c->data, 1, c->size, f);
|
|
||||||
if (s != c->size) break; /* Error or short file. */
|
|
||||||
|
|
||||||
seek = 0;
|
|
||||||
if (!full) { /* Only BMHD required. */
|
|
||||||
ok = 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pos + 8 + z >= formsize + 8) break; /* This was last chunk. */
|
if (c && !c->data)
|
||||||
|
{
|
||||||
|
c->size = z;
|
||||||
|
c->data = malloc(c->size);
|
||||||
|
if (!c->data)
|
||||||
|
break; /* Out of memory. */
|
||||||
|
|
||||||
if (seek && fseek(f, z, SEEK_CUR) != 0) break;
|
s = fread(c->data, 1, c->size, f);
|
||||||
}
|
if (s != c->size)
|
||||||
|
break; /* Error or short file. */
|
||||||
|
|
||||||
/* File may end strangely, especially if body size is uneven, but it's
|
seek = 0;
|
||||||
* ok if we have the chunks we want. !full check is already done. */
|
if (!full)
|
||||||
if (ilbm->bmhd.data && ilbm->body.data) ok = 1;
|
{ /* Only BMHD required. */
|
||||||
if (!ok) freeilbm(ilbm);
|
ok = 1;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos + 8 + z >= formsize + 8)
|
||||||
|
break; /* This was last chunk. */
|
||||||
|
|
||||||
|
if (seek && fseek(f, z, SEEK_CUR) != 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* File may end strangely, especially if body size is uneven, but it's
|
||||||
|
* ok if we have the chunks we want. !full check is already done. */
|
||||||
|
if (ilbm->bmhd.data && ilbm->body.data)
|
||||||
|
ok = 1;
|
||||||
|
if (!ok)
|
||||||
|
freeilbm(ilbm);
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Unpacks a row of possibly RLE data at a time.
|
* Unpacks a row of possibly RLE data at a time.
|
||||||
*
|
*
|
||||||
|
@ -145,227 +171,276 @@ char buf[12];
|
||||||
*
|
*
|
||||||
* In theory RLE compression is not supposed to create runs across scanlines.
|
* In theory RLE compression is not supposed to create runs across scanlines.
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
static void bodyrow(unsigned char *p, int z, ILBM *ilbm)
|
static void
|
||||||
|
bodyrow(unsigned char *p, int z, ILBM * ilbm)
|
||||||
{
|
{
|
||||||
int i, x, w;
|
int i, x, w;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
|
|
||||||
if (ilbm->offset >= ilbm->body.size) {
|
if (ilbm->offset >= ilbm->body.size)
|
||||||
|
{
|
||||||
memset(p, 0, z);
|
memset(p, 0, z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ilbm->rle) {
|
if (!ilbm->rle)
|
||||||
|
{
|
||||||
w = ilbm->body.size - ilbm->offset;
|
w = ilbm->body.size - ilbm->offset;
|
||||||
if (w > z) w = z;
|
if (w > z)
|
||||||
|
w = z;
|
||||||
memcpy(p, ilbm->body.data + ilbm->offset, w);
|
memcpy(p, ilbm->body.data + ilbm->offset, w);
|
||||||
if (w < z) memset(p + w, 0, z - w);
|
if (w < z)
|
||||||
|
memset(p + w, 0, z - w);
|
||||||
ilbm->offset += w;
|
ilbm->offset += w;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < z; ) {
|
for (i = 0; i < z;)
|
||||||
|
{
|
||||||
b = ilbm->body.data[ilbm->offset++];
|
b = ilbm->body.data[ilbm->offset++];
|
||||||
while (b == 0x80 && ilbm->offset < ilbm->body.size) b = ilbm->body.data[ilbm->offset++];
|
while (b == 0x80 && ilbm->offset < ilbm->body.size)
|
||||||
if (ilbm->offset >= ilbm->body.size) break;
|
b = ilbm->body.data[ilbm->offset++];
|
||||||
|
if (ilbm->offset >= ilbm->body.size)
|
||||||
|
break;
|
||||||
|
|
||||||
if (b & 0x80) {
|
if (b & 0x80)
|
||||||
w = (0x100 - b) + 1;
|
{
|
||||||
if (w > z - i) w = z - i;
|
w = (0x100 - b) + 1;
|
||||||
|
if (w > z - i)
|
||||||
b = ilbm->body.data[ilbm->offset++];
|
w = z - i;
|
||||||
memset(p + i, b, w);
|
|
||||||
i += w;
|
b = ilbm->body.data[ilbm->offset++];
|
||||||
}
|
memset(p + i, b, w);
|
||||||
else {
|
i += w;
|
||||||
w = (b & 0x7f) + 1;
|
}
|
||||||
if (w > ilbm->body.size - ilbm->offset) w = ilbm->body.size - ilbm->offset;
|
else
|
||||||
x = (w <= z - i)? w: z - i;
|
{
|
||||||
memcpy(p + i, ilbm->body.data + ilbm->offset, x);
|
w = (b & 0x7f) + 1;
|
||||||
i += x;
|
if (w > ilbm->body.size - ilbm->offset)
|
||||||
ilbm->offset += w;
|
w = ilbm->body.size - ilbm->offset;
|
||||||
}
|
x = (w <= z - i) ? w : z - i;
|
||||||
}
|
memcpy(p + i, ilbm->body.data + ilbm->offset, x);
|
||||||
|
i += x;
|
||||||
if (i < z) memset(p, 0, z - i);
|
ilbm->offset += w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < z)
|
||||||
|
memset(p, 0, z - i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Shifts a value to produce an 8-bit colour gun, and fills in the lower bits
|
* Shifts a value to produce an 8-bit colour gun, and fills in the lower bits
|
||||||
* from the high bits of the value so that, for example, 4-bit 0x0f scales to
|
* from the high bits of the value so that, for example, 4-bit 0x0f scales to
|
||||||
* 0xff, or 1-bit 0x01 scales to 0xff.
|
* 0xff, or 1-bit 0x01 scales to 0xff.
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
static unsigned char scalegun(unsigned char v, int sl)
|
static unsigned char
|
||||||
|
scalegun(unsigned char v, int sl)
|
||||||
{
|
{
|
||||||
int sr;
|
int sr;
|
||||||
|
|
||||||
switch (sl) {
|
switch (sl)
|
||||||
case 1:
|
{
|
||||||
case 2:
|
case 1:
|
||||||
case 3:
|
case 2:
|
||||||
sr = 8 - sl;
|
case 3:
|
||||||
return (v << sl) | (v >> sr);
|
sr = 8 - sl;
|
||||||
|
return (v << sl) | (v >> sr);
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
return (v << 4) | v;
|
return (v << 4) | v;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
return v * 0x24;
|
return v * 0x24;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
return v * 0x55;
|
return v * 0x55;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
return v * 0xff;
|
return v * 0xff;
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Scales the colours in a CMAP chunk if they all look like 4-bit colour, so
|
* Scales the colours in a CMAP chunk if they all look like 4-bit colour, so
|
||||||
* that they use all 8-bits. This is done by copying the high nybble into the
|
* that they use all 8-bits. This is done by copying the high nybble into the
|
||||||
* low nybble, so for example 0xf0 becomes 0xff.
|
* low nybble, so for example 0xf0 becomes 0xff.
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
static void scalecmap(ILBM *ilbm)
|
static void
|
||||||
|
scalecmap(ILBM * ilbm)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!ilbm->cmap.data) return;
|
if (!ilbm->cmap.data)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < ilbm->cmap.size; i++)
|
for (i = 0; i < ilbm->cmap.size; i++)
|
||||||
if (ilbm->cmap.data[i] & 0x0f) return;
|
if (ilbm->cmap.data[i] & 0x0f)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < ilbm->cmap.size; i++)
|
for (i = 0; i < ilbm->cmap.size; i++)
|
||||||
ilbm->cmap.data[i] |= ilbm->cmap.data[i] >> 4;
|
ilbm->cmap.data[i] |= ilbm->cmap.data[i] >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Deplanes and converts an array of bitplanes to a single scanline of DATA32
|
* Deplanes and converts an array of bitplanes to a single scanline of DATA32
|
||||||
* (unsigned int) values. DATA32 is ARGB.
|
* (unsigned int) values. DATA32 is ARGB.
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
static void deplane(DATA32 *row, int w, ILBM *ilbm, unsigned char *plane[])
|
static void
|
||||||
|
deplane(DATA32 * row, int w, ILBM * ilbm, unsigned char *plane[])
|
||||||
{
|
{
|
||||||
unsigned long l;
|
unsigned long l;
|
||||||
int i, o, x;
|
int i, o, x;
|
||||||
unsigned char bit, r, g, b, a, v, h, *pal;
|
unsigned char bit, r, g, b, a, v, h, *pal;
|
||||||
|
|
||||||
pal = NULL;
|
pal = NULL;
|
||||||
if (ilbm->sham.data && ilbm->sham.size >= 2 + (ilbm->row + 1) * 2 * 16)
|
if (ilbm->sham.data && ilbm->sham.size >= 2 + (ilbm->row + 1) * 2 * 16)
|
||||||
pal = ilbm->sham.data + 2 + ilbm->row * 2 * 16;
|
pal = ilbm->sham.data + 2 + ilbm->row * 2 * 16;
|
||||||
if (ilbm->ctbl.data && ilbm->ctbl.size >= (ilbm->row + 1) * 2 * 16)
|
if (ilbm->ctbl.data && ilbm->ctbl.size >= (ilbm->row + 1) * 2 * 16)
|
||||||
pal = ilbm->ctbl.data + ilbm->row * 2 * 16;
|
pal = ilbm->ctbl.data + ilbm->row * 2 * 16;
|
||||||
|
|
||||||
if (ilbm->ham) r = g = b = 0;
|
if (ilbm->ham)
|
||||||
|
r = g = b = 0;
|
||||||
|
|
||||||
bit = 0x80;
|
bit = 0x80;
|
||||||
o = 0;
|
o = 0;
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++)
|
||||||
|
{
|
||||||
l = 0;
|
l = 0;
|
||||||
for (i = ilbm->depth - 1; i >= 0; i--) {
|
for (i = ilbm->depth - 1; i >= 0; i--)
|
||||||
l = l << 1;
|
{
|
||||||
if (plane[i][o] & bit) l = l | 1;
|
l = l << 1;
|
||||||
}
|
if (plane[i][o] & bit)
|
||||||
a = (ilbm->mask == 0 || (ilbm->mask == 1 && (plane[ilbm->depth][o] & bit)) || ilbm->mask == 2)? 0xff: 0x00;
|
l = l | 1;
|
||||||
|
}
|
||||||
|
a = (ilbm->mask == 0
|
||||||
|
|| (ilbm->mask == 1 && (plane[ilbm->depth][o] & bit))
|
||||||
|
|| ilbm->mask == 2) ? 0xff : 0x00;
|
||||||
|
|
||||||
if (ilbm->depth == 32) {
|
if (ilbm->depth == 32)
|
||||||
a = (l >> 24) & 0xff;
|
{
|
||||||
b = (l >> 16) & 0xff;
|
a = (l >> 24) & 0xff;
|
||||||
g = (l >> 8) & 0xff;
|
b = (l >> 16) & 0xff;
|
||||||
r = l & 0xff;
|
g = (l >> 8) & 0xff;
|
||||||
}
|
r = l & 0xff;
|
||||||
else if (ilbm->depth == 24) {
|
}
|
||||||
b = (l >> 16) & 0xff;
|
else if (ilbm->depth == 24)
|
||||||
g = (l >> 8) & 0xff;
|
{
|
||||||
r = l & 0xff;
|
b = (l >> 16) & 0xff;
|
||||||
}
|
g = (l >> 8) & 0xff;
|
||||||
else if (ilbm->ham) {
|
r = l & 0xff;
|
||||||
v = l & ((1 << (ilbm->depth - 2)) - 1);
|
}
|
||||||
h = (l & ~v) >> (ilbm->depth - 2);
|
else if (ilbm->ham)
|
||||||
|
{
|
||||||
|
v = l & ((1 << (ilbm->depth - 2)) - 1);
|
||||||
|
h = (l & ~v) >> (ilbm->depth - 2);
|
||||||
|
|
||||||
if (h == 0x00) {
|
if (h == 0x00)
|
||||||
if (!pal) {
|
{
|
||||||
if ((v + 1) * 3 <= ilbm->cmap.size) {
|
if (!pal)
|
||||||
r = ilbm->cmap.data[v * 3];
|
{
|
||||||
g = ilbm->cmap.data[v * 3 + 1];
|
if ((v + 1) * 3 <= ilbm->cmap.size)
|
||||||
b = ilbm->cmap.data[v * 3 + 2];
|
{
|
||||||
|
r = ilbm->cmap.data[v * 3];
|
||||||
|
g = ilbm->cmap.data[v * 3 + 1];
|
||||||
|
b = ilbm->cmap.data[v * 3 + 2];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
r = g = b = 0;
|
||||||
}
|
}
|
||||||
else r = g = b = 0;
|
else
|
||||||
}
|
{
|
||||||
else {
|
r = scalegun(pal[v * 2] & 0x0f, 4);
|
||||||
r = scalegun(pal[v * 2] & 0x0f, 4);
|
g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
|
||||||
g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
|
b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
|
||||||
b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (h == 0x01)
|
||||||
else if (h == 0x01) b = scalegun(v, 8 - (ilbm->depth - 2));
|
b = scalegun(v, 8 - (ilbm->depth - 2));
|
||||||
else if (h == 0x02) r = scalegun(v, 8 - (ilbm->depth - 2));
|
else if (h == 0x02)
|
||||||
else g = scalegun(v, 8 - (ilbm->depth - 2));
|
r = scalegun(v, 8 - (ilbm->depth - 2));
|
||||||
}
|
else
|
||||||
else if (ilbm->hbrite) {
|
g = scalegun(v, 8 - (ilbm->depth - 2));
|
||||||
v = l & ((1 << (ilbm->depth - 1)) - 1);
|
}
|
||||||
h = (l & ~v) >> (ilbm->depth - 1);
|
else if (ilbm->hbrite)
|
||||||
|
{
|
||||||
|
v = l & ((1 << (ilbm->depth - 1)) - 1);
|
||||||
|
h = (l & ~v) >> (ilbm->depth - 1);
|
||||||
|
|
||||||
if (!pal) {
|
if (!pal)
|
||||||
if ((v + 1) * 3 <= ilbm->cmap.size) {
|
{
|
||||||
r = ilbm->cmap.data[v * 3];
|
if ((v + 1) * 3 <= ilbm->cmap.size)
|
||||||
g = ilbm->cmap.data[v * 3 + 1];
|
{
|
||||||
b = ilbm->cmap.data[v * 3 + 2];
|
r = ilbm->cmap.data[v * 3];
|
||||||
}
|
g = ilbm->cmap.data[v * 3 + 1];
|
||||||
else r = g = b = 0;
|
b = ilbm->cmap.data[v * 3 + 2];
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
r = scalegun(pal[v * 2] & 0x0f, 4);
|
r = g = b = 0;
|
||||||
g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
|
}
|
||||||
b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
|
else
|
||||||
}
|
{
|
||||||
|
r = scalegun(pal[v * 2] & 0x0f, 4);
|
||||||
|
g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
|
||||||
|
b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
|
||||||
|
}
|
||||||
|
|
||||||
if (h) {
|
if (h)
|
||||||
r = r >> 1;
|
{
|
||||||
g = g >> 1;
|
r = r >> 1;
|
||||||
b = b >> 1;
|
g = g >> 1;
|
||||||
}
|
b = b >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (ilbm->mask == 2 && v == L2RWORD(ilbm->bmhd.data + 12)) a = 0x00;
|
if (ilbm->mask == 2 && v == L2RWORD(ilbm->bmhd.data + 12))
|
||||||
}
|
a = 0x00;
|
||||||
else if (ilbm->cmap.size == 0 && !pal) {
|
}
|
||||||
v = l & ((1 << ilbm->depth) - 1);
|
else if (ilbm->cmap.size == 0 && !pal)
|
||||||
r = scalegun(v, ilbm->depth);
|
{
|
||||||
g = r;
|
v = l & ((1 << ilbm->depth) - 1);
|
||||||
b = r;
|
r = scalegun(v, ilbm->depth);
|
||||||
}
|
g = r;
|
||||||
else {
|
b = r;
|
||||||
v = l & 0xff;
|
}
|
||||||
if (!pal) {
|
else
|
||||||
if ((v + 1) * 3 <= ilbm->cmap.size) {
|
{
|
||||||
r = ilbm->cmap.data[v * 3];
|
v = l & 0xff;
|
||||||
g = ilbm->cmap.data[v * 3 + 1];
|
if (!pal)
|
||||||
b = ilbm->cmap.data[v * 3 + 2];
|
{
|
||||||
}
|
if ((v + 1) * 3 <= ilbm->cmap.size)
|
||||||
else r = g = b = 0;
|
{
|
||||||
}
|
r = ilbm->cmap.data[v * 3];
|
||||||
else {
|
g = ilbm->cmap.data[v * 3 + 1];
|
||||||
r = scalegun(pal[v * 2] & 0x0f, 4);
|
b = ilbm->cmap.data[v * 3 + 2];
|
||||||
g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
|
}
|
||||||
b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
|
else
|
||||||
}
|
r = g = b = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r = scalegun(pal[v * 2] & 0x0f, 4);
|
||||||
|
g = scalegun((pal[v * 2 + 1] & 0xf0) >> 4, 4);
|
||||||
|
b = scalegun((pal[v * 2 + 1] & 0x0f), 4);
|
||||||
|
}
|
||||||
|
|
||||||
if (ilbm->mask == 2 && v == L2RWORD(ilbm->bmhd.data + 12)) a = 0x00;
|
if (ilbm->mask == 2 && v == L2RWORD(ilbm->bmhd.data + 12))
|
||||||
}
|
a = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
row[x] = ((unsigned long)a << 24) | ((unsigned long)r << 16) | ((unsigned long)g << 8) | (unsigned long)b;
|
row[x] =
|
||||||
|
((unsigned long)a << 24) | ((unsigned long)r << 16) |
|
||||||
|
((unsigned long)g << 8) | (unsigned long)b;
|
||||||
|
|
||||||
bit = bit >> 1;
|
bit = bit >> 1;
|
||||||
if (bit == 0) {
|
if (bit == 0)
|
||||||
o++;
|
{
|
||||||
bit = 0x80;
|
o++;
|
||||||
}
|
bit = 0x80;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Loads an image. If im->loader is non-zero, or immediate_load is non-zero, or
|
* Loads an image. If im->loader is non-zero, or immediate_load is non-zero, or
|
||||||
* progress is non-zero, then the file is fully loaded, otherwise only the width
|
* progress is non-zero, then the file is fully loaded, otherwise only the width
|
||||||
|
@ -373,74 +448,97 @@ unsigned char bit, r, g, b, a, v, h, *pal;
|
||||||
*
|
*
|
||||||
* Imlib2 doesn't support reading comment chunks like ANNO.
|
* Imlib2 doesn't support reading comment chunks like ANNO.
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
char load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity, char immediate_load)
|
char
|
||||||
|
load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
||||||
|
char immediate_load)
|
||||||
{
|
{
|
||||||
char *env;
|
char *env;
|
||||||
int cancel, full, i, n, ok, y, z, gran, nexty, prevy;
|
int cancel, full, i, n, ok, y, z, gran, nexty, prevy;
|
||||||
unsigned char *plane[40];
|
unsigned char *plane[40];
|
||||||
ILBM ilbm;
|
ILBM ilbm;
|
||||||
|
|
||||||
/*----------
|
/*----------
|
||||||
* Do nothing if the data is already loaded.
|
* Do nothing if the data is already loaded.
|
||||||
*----------*/
|
*----------*/
|
||||||
if (im->data) return 0;
|
if (im->data)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/*----------
|
/*----------
|
||||||
* Load the chunk(s) we're interested in. If full is not true, then we only
|
* Load the chunk(s) we're interested in. If full is not true, then we only
|
||||||
* want the image size and format.
|
* want the image size and format.
|
||||||
*----------*/
|
*----------*/
|
||||||
full = (im->loader || immediate_load || progress);
|
full = (im->loader || immediate_load || progress);
|
||||||
ok = loadchunks(im->real_file, &ilbm, full);
|
ok = loadchunks(im->real_file, &ilbm, full);
|
||||||
if (!ok) return 0;
|
if (!ok)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/*----------
|
/*----------
|
||||||
* Use and check header.
|
* Use and check header.
|
||||||
*----------*/
|
*----------*/
|
||||||
ok = 0;
|
ok = 0;
|
||||||
if (ilbm.bmhd.size >= 20) {
|
if (ilbm.bmhd.size >= 20)
|
||||||
|
{
|
||||||
ok = 1;
|
ok = 1;
|
||||||
|
|
||||||
im->w = L2RWORD(ilbm.bmhd.data);
|
im->w = L2RWORD(ilbm.bmhd.data);
|
||||||
im->h = L2RWORD(ilbm.bmhd.data + 2);
|
im->h = L2RWORD(ilbm.bmhd.data + 2);
|
||||||
if (!IMAGE_DIMENSIONS_OK(im->w, im->h))
|
if (!IMAGE_DIMENSIONS_OK(im->w, im->h))
|
||||||
{
|
{
|
||||||
ok = 0;
|
ok = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ilbm.depth = ilbm.bmhd.data[8];
|
ilbm.depth = ilbm.bmhd.data[8];
|
||||||
if (ilbm.depth < 1 || (ilbm.depth > 8 && ilbm.depth != 24 && ilbm.depth != 32)) ok = 0; /* Only 1 to 8, 24, or 32 planes. */
|
if (ilbm.depth < 1
|
||||||
|
|| (ilbm.depth > 8 && ilbm.depth != 24 && ilbm.depth != 32))
|
||||||
|
ok = 0; /* Only 1 to 8, 24, or 32 planes. */
|
||||||
|
|
||||||
ilbm.rle = ilbm.bmhd.data[10];
|
ilbm.rle = ilbm.bmhd.data[10];
|
||||||
if (ilbm.rle < 0 || ilbm.rle > 1) ok = 0; /* Only NONE or RLE compression. */
|
if (ilbm.rle < 0 || ilbm.rle > 1)
|
||||||
|
ok = 0; /* Only NONE or RLE compression. */
|
||||||
|
|
||||||
ilbm.mask = ilbm.bmhd.data[9];
|
ilbm.mask = ilbm.bmhd.data[9];
|
||||||
|
|
||||||
if (ilbm.mask || ilbm.depth == 32) SET_FLAG(im->flags, F_HAS_ALPHA);
|
if (ilbm.mask || ilbm.depth == 32)
|
||||||
else UNSET_FLAG(im->flags, F_HAS_ALPHA);
|
SET_FLAG(im->flags, F_HAS_ALPHA);
|
||||||
|
else
|
||||||
|
UNSET_FLAG(im->flags, F_HAS_ALPHA);
|
||||||
|
|
||||||
env = getenv("IMLIB2_LBM_NOMASK");
|
env = getenv("IMLIB2_LBM_NOMASK");
|
||||||
if (env && (!strcmp(env, "true") || !strcmp(env, "1") || !strcmp(env, "yes") || !strcmp(env, "on"))) UNSET_FLAG(im->flags, F_HAS_ALPHA);
|
if (env
|
||||||
|
&& (!strcmp(env, "true") || !strcmp(env, "1") || !strcmp(env, "yes")
|
||||||
|
|| !strcmp(env, "on")))
|
||||||
|
UNSET_FLAG(im->flags, F_HAS_ALPHA);
|
||||||
|
|
||||||
if (!im->format) im->format = strdup("lbm");
|
if (!im->format)
|
||||||
|
im->format = strdup("lbm");
|
||||||
|
|
||||||
ilbm.ham = 0;
|
ilbm.ham = 0;
|
||||||
ilbm.hbrite = 0;
|
ilbm.hbrite = 0;
|
||||||
if (ilbm.depth <= 8) {
|
if (ilbm.depth <= 8)
|
||||||
if (ilbm.camg.size == 4) {
|
{
|
||||||
if (ilbm.camg.data[2] & 0x08) ilbm.ham = 1;
|
if (ilbm.camg.size == 4)
|
||||||
if (ilbm.camg.data[3] & 0x80) ilbm.hbrite = 1;
|
{
|
||||||
}
|
if (ilbm.camg.data[2] & 0x08)
|
||||||
else { /* Only guess at ham and hbrite if CMAP is present. */
|
ilbm.ham = 1;
|
||||||
if (ilbm.depth == 6 && full && ilbm.cmap.size >= 3 * 16) ilbm.ham = 1;
|
if (ilbm.camg.data[3] & 0x80)
|
||||||
if (full && !ilbm.ham && ilbm.depth > 1 && ilbm.cmap.size == 3 * (1 << (ilbm.depth - 1))) ilbm.hbrite = 1;
|
ilbm.hbrite = 1;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
{ /* Only guess at ham and hbrite if CMAP is present. */
|
||||||
if (!full || !ok) {
|
if (ilbm.depth == 6 && full && ilbm.cmap.size >= 3 * 16)
|
||||||
|
ilbm.ham = 1;
|
||||||
|
if (full && !ilbm.ham && ilbm.depth > 1
|
||||||
|
&& ilbm.cmap.size == 3 * (1 << (ilbm.depth - 1)))
|
||||||
|
ilbm.hbrite = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!full || !ok)
|
||||||
|
{
|
||||||
im->w = im->h = 0;
|
im->w = im->h = 0;
|
||||||
freeilbm(&ilbm);
|
freeilbm(&ilbm);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------
|
/*----------
|
||||||
* The source data is planar. Each plane is an even number of bytes wide. If
|
* The source data is planar. Each plane is an even number of bytes wide. If
|
||||||
|
@ -448,88 +546,102 @@ ILBM ilbm;
|
||||||
* from each plane are interleaved, from top to bottom. The first plane is the
|
* from each plane are interleaved, from top to bottom. The first plane is the
|
||||||
* 0 bit.
|
* 0 bit.
|
||||||
*----------*/
|
*----------*/
|
||||||
ok = 0;
|
ok = 0;
|
||||||
cancel = 0;
|
cancel = 0;
|
||||||
plane[0] = NULL;
|
plane[0] = NULL;
|
||||||
|
|
||||||
im->data = malloc(im->w * im->h * sizeof(DATA32));
|
im->data = malloc(im->w * im->h * sizeof(DATA32));
|
||||||
n = ilbm.depth;
|
n = ilbm.depth;
|
||||||
if (ilbm.mask == 1) n++;
|
if (ilbm.mask == 1)
|
||||||
plane[0] = malloc(((im->w + 15) / 16) * 2 * n);
|
n++;
|
||||||
if (im->data && plane[0]) {
|
plane[0] = malloc(((im->w + 15) / 16) * 2 * n);
|
||||||
for (i = 1; i < n; i++) plane[i] = plane[i - 1] + ((im->w + 15) / 16) * 2;
|
if (im->data && plane[0])
|
||||||
|
{
|
||||||
|
for (i = 1; i < n; i++)
|
||||||
|
plane[i] = plane[i - 1] + ((im->w + 15) / 16) * 2;
|
||||||
|
|
||||||
z = ((im->w + 15) / 16) * 2 * n;
|
z = ((im->w + 15) / 16) * 2 * n;
|
||||||
|
|
||||||
if (progress) {
|
if (progress)
|
||||||
prevy = 0;
|
{
|
||||||
if (progress_granularity <= 0) progress_granularity = 1;
|
prevy = 0;
|
||||||
gran = progress_granularity;
|
if (progress_granularity <= 0)
|
||||||
nexty = ((im->h * gran) / 100);
|
progress_granularity = 1;
|
||||||
}
|
gran = progress_granularity;
|
||||||
|
nexty = ((im->h * gran) / 100);
|
||||||
|
}
|
||||||
|
|
||||||
scalecmap(&ilbm);
|
scalecmap(&ilbm);
|
||||||
|
|
||||||
for (y = 0; y < im->h; y++) {
|
for (y = 0; y < im->h; y++)
|
||||||
bodyrow(plane[0], z, &ilbm);
|
{
|
||||||
|
bodyrow(plane[0], z, &ilbm);
|
||||||
|
|
||||||
deplane(im->data + im->w * y, im->w, &ilbm, plane);
|
deplane(im->data + im->w * y, im->w, &ilbm, plane);
|
||||||
ilbm.row++;
|
ilbm.row++;
|
||||||
|
|
||||||
if (progress && (y >= nexty || y == im->h - 1)) {
|
if (progress && (y >= nexty || y == im->h - 1))
|
||||||
if (!progress(im, (char)((100 * (y + 1)) / im->h), 0, prevy, im->w, y + 1)) {
|
{
|
||||||
cancel = 1;
|
if (!progress
|
||||||
break;
|
(im, (char)((100 * (y + 1)) / im->h), 0, prevy, im->w,
|
||||||
}
|
y + 1))
|
||||||
prevy = y;
|
{
|
||||||
gran += progress_granularity;
|
cancel = 1;
|
||||||
nexty = ((im->h * gran) / 100);
|
break;
|
||||||
}
|
}
|
||||||
}
|
prevy = y;
|
||||||
|
gran += progress_granularity;
|
||||||
|
nexty = ((im->h * gran) / 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ok = !cancel;
|
ok = !cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------
|
/*----------
|
||||||
* We either had a successful decode, the user cancelled, or we couldn't get
|
* We either had a successful decode, the user cancelled, or we couldn't get
|
||||||
* the memory for im->data or plane[0].
|
* the memory for im->data or plane[0].
|
||||||
*----------*/
|
*----------*/
|
||||||
if (!ok) {
|
if (!ok)
|
||||||
|
{
|
||||||
im->w = im->h = 0;
|
im->w = im->h = 0;
|
||||||
if (im->data) free(im->data);
|
if (im->data)
|
||||||
|
free(im->data);
|
||||||
im->data = NULL;
|
im->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plane[0]) free(plane[0]);
|
if (plane[0])
|
||||||
|
free(plane[0]);
|
||||||
|
|
||||||
freeilbm(&ilbm);
|
freeilbm(&ilbm);
|
||||||
|
|
||||||
return (cancel)? 2: ok;
|
return (cancel) ? 2 : ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Perhaps save only in 32-bit format? The IFF ILBM format has pretty much gone
|
* Perhaps save only in 32-bit format? The IFF ILBM format has pretty much gone
|
||||||
* the way of the Amiga, who saves in this format any more?
|
* the way of the Amiga, who saves in this format any more?
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
#if 0
|
#if 0
|
||||||
char save(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity)
|
char
|
||||||
|
save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Identifies the file extensions this loader handles. Standard code from other
|
* Identifies the file extensions this loader handles. Standard code from other
|
||||||
* loaders.
|
* loaders.
|
||||||
*------------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------------*/
|
||||||
void formats(ImlibLoader *l)
|
void
|
||||||
|
formats(ImlibLoader * l)
|
||||||
{
|
{
|
||||||
char *list_formats[] = { "iff", "ilbm", "lbm" };
|
char *list_formats[] = { "iff", "ilbm", "lbm" };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
l->num_formats = sizeof(list_formats) / sizeof(list_formats[0]);
|
l->num_formats = sizeof(list_formats) / sizeof(list_formats[0]);
|
||||||
l->formats = malloc(l->num_formats * sizeof(list_formats[0]));
|
l->formats = malloc(l->num_formats * sizeof(list_formats[0]));
|
||||||
for (i = 0; i < l->num_formats; i++) l->formats[i] = strdup(list_formats[i]);
|
for (i = 0; i < l->num_formats; i++)
|
||||||
|
l->formats[i] = strdup(list_formats[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
}
|
}
|
||||||
rewind(f);
|
rewind(f);
|
||||||
png_ptr =
|
png_ptr =
|
||||||
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -110,7 +110,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
png_set_palette_to_rgb(png_ptr);
|
png_set_palette_to_rgb(png_ptr);
|
||||||
/* expand gray (w/reduced bits) -> 8-bit RGB if necessary */
|
/* expand gray (w/reduced bits) -> 8-bit RGB if necessary */
|
||||||
if ((color_type == PNG_COLOR_TYPE_GRAY) ||
|
if ((color_type == PNG_COLOR_TYPE_GRAY) ||
|
||||||
(color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
(color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
|
||||||
{
|
{
|
||||||
png_set_gray_to_rgb(png_ptr);
|
png_set_gray_to_rgb(png_ptr);
|
||||||
if (bit_depth < 8)
|
if (bit_depth < 8)
|
||||||
|
@ -166,7 +166,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
if (progress)
|
if (progress)
|
||||||
{
|
{
|
||||||
int y, count, prevy, pass, number_passes, per,
|
int y, count, prevy, pass, number_passes, per,
|
||||||
nrows = 1;
|
nrows = 1;
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
number_passes = png_set_interlace_handling(png_ptr);
|
number_passes = png_set_interlace_handling(png_ptr);
|
||||||
|
@ -278,7 +278,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
|
||||||
if ((tag = __imlib_GetTag(im, "interlacing")) && tag->val)
|
if ((tag = __imlib_GetTag(im, "interlacing")) && tag->val)
|
||||||
{
|
{
|
||||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||||
interlace = PNG_INTERLACE_ADAM7;
|
interlace = PNG_INTERLACE_ADAM7;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,51 +350,51 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
|
||||||
|
|
||||||
for (pass = 0; pass < num_passes; pass++)
|
for (pass = 0; pass < num_passes; pass++)
|
||||||
{
|
{
|
||||||
ptr = im->data;
|
ptr = im->data;
|
||||||
|
|
||||||
for (y = 0; y < im->h; y++)
|
for (y = 0; y < im->h; y++)
|
||||||
{
|
{
|
||||||
if (im->flags & F_HAS_ALPHA)
|
if (im->flags & F_HAS_ALPHA)
|
||||||
row_ptr = (png_bytep) ptr;
|
row_ptr = (png_bytep) ptr;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (j = 0, x = 0; x < im->w; x++)
|
for (j = 0, x = 0; x < im->w; x++)
|
||||||
{
|
{
|
||||||
data[j++] = (ptr[x] >> 16) & 0xff;
|
data[j++] = (ptr[x] >> 16) & 0xff;
|
||||||
data[j++] = (ptr[x] >> 8) & 0xff;
|
data[j++] = (ptr[x] >> 8) & 0xff;
|
||||||
data[j++] = (ptr[x]) & 0xff;
|
data[j++] = (ptr[x]) & 0xff;
|
||||||
}
|
}
|
||||||
row_ptr = (png_bytep) data;
|
row_ptr = (png_bytep) data;
|
||||||
}
|
}
|
||||||
png_write_rows(png_ptr, &row_ptr, 1);
|
png_write_rows(png_ptr, &row_ptr, 1);
|
||||||
if (progress)
|
if (progress)
|
||||||
{
|
{
|
||||||
char per;
|
char per;
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
per = 100 * (pass + y / (float) im->h) / num_passes;
|
per = 100 * (pass + y / (float)im->h) / num_passes;
|
||||||
if ((per - pper) >= progress_granularity)
|
if ((per - pper) >= progress_granularity)
|
||||||
{
|
{
|
||||||
l = y - pl;
|
l = y - pl;
|
||||||
if (!progress(im, per, 0, (y - l), im->w, l))
|
if (!progress(im, per, 0, (y - l), im->w, l))
|
||||||
{
|
{
|
||||||
if (data)
|
if (data)
|
||||||
free(data);
|
free(data);
|
||||||
png_write_end(png_ptr, info_ptr);
|
png_write_end(png_ptr, info_ptr);
|
||||||
png_destroy_write_struct(&png_ptr,
|
png_destroy_write_struct(&png_ptr,
|
||||||
(png_infopp) & info_ptr);
|
(png_infopp) & info_ptr);
|
||||||
png_destroy_info_struct(png_ptr,
|
png_destroy_info_struct(png_ptr,
|
||||||
(png_infopp) & info_ptr);
|
(png_infopp) & info_ptr);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
pper = per;
|
pper = per;
|
||||||
pl = y;
|
pl = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptr += im->w;
|
ptr += im->w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data)
|
if (data)
|
||||||
free(data);
|
free(data);
|
||||||
png_write_end(png_ptr, info_ptr);
|
png_write_end(png_ptr, info_ptr);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -156,7 +156,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
|
||||||
l = y - pl;
|
l = y - pl;
|
||||||
if (!progress(im, per, 0, (y - l), im->w, l))
|
if (!progress(im, per, 0, (y - l), im->w, l))
|
||||||
{
|
{
|
||||||
free(buf);
|
free(buf);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -192,13 +192,13 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
char progress_granularity, char immediate_load)
|
char progress_granularity, char immediate_load)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
void *seg, *filedata;
|
void *seg, *filedata;
|
||||||
struct stat ss;
|
struct stat ss;
|
||||||
int bpp, vinverted = 0;
|
int bpp, vinverted = 0;
|
||||||
int rle = 0, footer_present = 0;
|
int rle = 0, footer_present = 0;
|
||||||
|
|
||||||
tga_header *header;
|
tga_header *header;
|
||||||
tga_footer *footer;
|
tga_footer *footer;
|
||||||
|
|
||||||
if (im->data)
|
if (im->data)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -222,7 +222,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
if (seg == MAP_FAILED)
|
if (seg == MAP_FAILED)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
filedata = seg;
|
filedata = seg;
|
||||||
|
@ -239,10 +239,10 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
|
|
||||||
/* skip over header */
|
/* skip over header */
|
||||||
filedata = (char *)filedata + sizeof(tga_header);
|
filedata = (char *)filedata + sizeof(tga_header);
|
||||||
|
|
||||||
/* skip over alphanumeric ID field */
|
/* skip over alphanumeric ID field */
|
||||||
if (header->idLength)
|
if (header->idLength)
|
||||||
filedata = (char *)filedata + header->idLength;
|
filedata = (char *)filedata + header->idLength;
|
||||||
|
|
||||||
/* now parse the header */
|
/* now parse the header */
|
||||||
|
|
||||||
|
@ -251,20 +251,20 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
|
|
||||||
switch (header->imageType)
|
switch (header->imageType)
|
||||||
{
|
{
|
||||||
case TGA_TYPE_COLOR_RLE:
|
case TGA_TYPE_COLOR_RLE:
|
||||||
case TGA_TYPE_GRAY_RLE:
|
case TGA_TYPE_GRAY_RLE:
|
||||||
rle = 1;
|
rle = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGA_TYPE_COLOR:
|
case TGA_TYPE_COLOR:
|
||||||
case TGA_TYPE_GRAY:
|
case TGA_TYPE_GRAY:
|
||||||
rle = 0;
|
rle = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
munmap(seg, ss.st_size);
|
munmap(seg, ss.st_size);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bits per pixel */
|
/* bits per pixel */
|
||||||
|
@ -272,7 +272,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
|
|
||||||
if (!((bpp == 32) || (bpp == 24) || (bpp == 8)))
|
if (!((bpp == 32) || (bpp == 24) || (bpp == 8)))
|
||||||
{
|
{
|
||||||
munmap(seg, ss.st_size);
|
munmap(seg, ss.st_size);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
|
|
||||||
if (!IMAGE_DIMENSIONS_OK(im->w, im->h))
|
if (!IMAGE_DIMENSIONS_OK(im->w, im->h))
|
||||||
{
|
{
|
||||||
munmap(seg, ss.st_size);
|
munmap(seg, ss.st_size);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
if (!im->data)
|
if (!im->data)
|
||||||
{
|
{
|
||||||
im->w = 0;
|
im->w = 0;
|
||||||
munmap(seg, ss.st_size);
|
munmap(seg, ss.st_size);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -323,13 +323,13 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
/* (this is NOT simply width*height*4, due to compression) */
|
/* (this is NOT simply width*height*4, due to compression) */
|
||||||
|
|
||||||
datasize = ss.st_size - sizeof(tga_header) - header->idLength -
|
datasize = ss.st_size - sizeof(tga_header) - header->idLength -
|
||||||
(footer_present ? sizeof(tga_footer) : 0);
|
(footer_present ? sizeof(tga_footer) : 0);
|
||||||
|
|
||||||
/* buffer is ready for parsing */
|
/* buffer is ready for parsing */
|
||||||
|
|
||||||
/* bufptr is the next byte to be read from the buffer */
|
/* bufptr is the next byte to be read from the buffer */
|
||||||
bufptr = filedata;
|
bufptr = filedata;
|
||||||
bufend = filedata + datasize;
|
bufend = filedata + datasize;
|
||||||
|
|
||||||
/* dataptr is the next 32-bit pixel to be filled in */
|
/* dataptr is the next 32-bit pixel to be filled in */
|
||||||
dataptr = im->data;
|
dataptr = im->data;
|
||||||
|
@ -348,56 +348,50 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
else
|
else
|
||||||
dataptr = im->data + (y * im->w);
|
dataptr = im->data + (y * im->w);
|
||||||
|
|
||||||
for (x = 0;
|
for (x = 0; (x < im->w) && (bufptr + bpp / 8 <= bufend); x++) /* for each pixel in the row */
|
||||||
(x < im->w) && (bufptr + bpp / 8 <= bufend);
|
|
||||||
x++) /* for each pixel in the row */
|
|
||||||
{
|
{
|
||||||
switch (bpp)
|
switch (bpp)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* 32-bit BGRA pixels */
|
/* 32-bit BGRA pixels */
|
||||||
case 32:
|
case 32:
|
||||||
WRITE_RGBA(dataptr,
|
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
||||||
*(bufptr + 2), /* R */
|
*(bufptr + 1), /* G */
|
||||||
*(bufptr + 1), /* G */
|
*(bufptr + 0), /* B */
|
||||||
*(bufptr + 0), /* B */
|
*(bufptr + 3) /* A */
|
||||||
*(bufptr + 3) /* A */
|
);
|
||||||
);
|
dataptr++;
|
||||||
dataptr++;
|
bufptr += 4;
|
||||||
bufptr += 4;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
/* 24-bit BGR pixels */
|
/* 24-bit BGR pixels */
|
||||||
case 24:
|
case 24:
|
||||||
WRITE_RGBA(dataptr,
|
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
||||||
*(bufptr + 2), /* R */
|
*(bufptr + 1), /* G */
|
||||||
*(bufptr + 1), /* G */
|
*(bufptr + 0), /* B */
|
||||||
*(bufptr + 0), /* B */
|
(char)0xff /* A */
|
||||||
(char)0xff /* A */
|
);
|
||||||
);
|
dataptr++;
|
||||||
dataptr++;
|
bufptr += 3;
|
||||||
bufptr += 3;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
/* 8-bit grayscale */
|
/* 8-bit grayscale */
|
||||||
case 8:
|
case 8:
|
||||||
WRITE_RGBA(dataptr, /* grayscale */
|
WRITE_RGBA(dataptr, /* grayscale */
|
||||||
*bufptr,
|
*bufptr, *bufptr, *bufptr, (char)0xff);
|
||||||
*bufptr,
|
dataptr++;
|
||||||
*bufptr, (char)0xff);
|
bufptr += 1;
|
||||||
dataptr++;
|
break;
|
||||||
bufptr += 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* end for (each pixel) */
|
} /* end for (each pixel) */
|
||||||
}
|
}
|
||||||
if (progress)
|
if (progress)
|
||||||
{
|
{
|
||||||
progress(im, 100, 0, 0, im->w, im->h);
|
progress(im, 100, 0, 0, im->w, im->h);
|
||||||
} /* end for (each row) */
|
} /* end for (each row) */
|
||||||
}
|
}
|
||||||
/* end if (!RLE) */
|
/* end if (!RLE) */
|
||||||
/* decode RLE compressed data */
|
/* decode RLE compressed data */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -405,9 +399,9 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
DATA32 *final_pixel = dataptr + im->w * im->h;
|
DATA32 *final_pixel = dataptr + im->w * im->h;
|
||||||
|
|
||||||
/* loop until we've got all the pixels or run out of input */
|
/* loop until we've got all the pixels or run out of input */
|
||||||
while ((dataptr < final_pixel) &&
|
while ((dataptr < final_pixel) &&
|
||||||
((bufptr + 1 + (bpp / 8)) <= bufend))
|
((bufptr + 1 + (bpp / 8)) <= bufend))
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
curbyte = *bufptr++;
|
curbyte = *bufptr++;
|
||||||
|
@ -419,39 +413,42 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
|
|
||||||
switch (bpp)
|
switch (bpp)
|
||||||
{
|
{
|
||||||
case 32:
|
case 32:
|
||||||
blue = *bufptr++;
|
blue = *bufptr++;
|
||||||
green = *bufptr++;
|
green = *bufptr++;
|
||||||
red = *bufptr++;
|
red = *bufptr++;
|
||||||
alpha = *bufptr++;
|
alpha = *bufptr++;
|
||||||
for (i = 0; (i < count) && (dataptr < final_pixel); i++)
|
for (i = 0; (i < count) && (dataptr < final_pixel);
|
||||||
{
|
i++)
|
||||||
WRITE_RGBA(dataptr, red, green, blue, alpha);
|
{
|
||||||
dataptr++;
|
WRITE_RGBA(dataptr, red, green, blue, alpha);
|
||||||
}
|
dataptr++;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
blue = *bufptr++;
|
blue = *bufptr++;
|
||||||
green = *bufptr++;
|
green = *bufptr++;
|
||||||
red = *bufptr++;
|
red = *bufptr++;
|
||||||
for (i = 0; (i < count) && (dataptr < final_pixel); i++)
|
for (i = 0; (i < count) && (dataptr < final_pixel);
|
||||||
{
|
i++)
|
||||||
WRITE_RGBA(dataptr, red, green, blue,
|
{
|
||||||
(char)0xff);
|
WRITE_RGBA(dataptr, red, green, blue,
|
||||||
dataptr++;
|
(char)0xff);
|
||||||
}
|
dataptr++;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
alpha = *bufptr++;
|
alpha = *bufptr++;
|
||||||
for (i = 0; (i < count) && (dataptr < final_pixel); i++)
|
for (i = 0; (i < count) && (dataptr < final_pixel);
|
||||||
{
|
i++)
|
||||||
WRITE_RGBA(dataptr, alpha, alpha, alpha,
|
{
|
||||||
(char)0xff);
|
WRITE_RGBA(dataptr, alpha, alpha, alpha,
|
||||||
dataptr++;
|
(char)0xff);
|
||||||
}
|
dataptr++;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* end if (RLE packet) */
|
} /* end if (RLE packet) */
|
||||||
|
@ -465,47 +462,48 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
switch (bpp)
|
switch (bpp)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* 32-bit BGRA pixels */
|
/* 32-bit BGRA pixels */
|
||||||
case 32:
|
case 32:
|
||||||
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
||||||
*(bufptr + 1), /* G */
|
*(bufptr + 1), /* G */
|
||||||
*(bufptr + 0), /* B */
|
*(bufptr + 0), /* B */
|
||||||
*(bufptr + 3) /* A */
|
*(bufptr + 3) /* A */
|
||||||
);
|
);
|
||||||
dataptr++;
|
dataptr++;
|
||||||
bufptr += 4;
|
bufptr += 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* 24-bit BGR pixels */
|
/* 24-bit BGR pixels */
|
||||||
case 24:
|
case 24:
|
||||||
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
||||||
*(bufptr + 1), /* G */
|
*(bufptr + 1), /* G */
|
||||||
*(bufptr + 0), /* B */
|
*(bufptr + 0), /* B */
|
||||||
(char)0xff /* A */
|
(char)0xff /* A */
|
||||||
);
|
);
|
||||||
dataptr++;
|
dataptr++;
|
||||||
bufptr += 3;
|
bufptr += 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* 8-bit grayscale */
|
/* 8-bit grayscale */
|
||||||
case 8:
|
case 8:
|
||||||
WRITE_RGBA(dataptr, *bufptr, /* pseudo-grayscale */
|
WRITE_RGBA(dataptr, *bufptr, /* pseudo-grayscale */
|
||||||
*bufptr, *bufptr, (char)0xff);
|
*bufptr, *bufptr, (char)0xff);
|
||||||
dataptr++;
|
dataptr++;
|
||||||
bufptr += 1;
|
bufptr += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* end if (raw packet) */
|
} /* end if (raw packet) */
|
||||||
} /* end for (each packet) */
|
} /* end for (each packet) */
|
||||||
/* must now flip a bottom-up image */
|
/* must now flip a bottom-up image */
|
||||||
if (vinverted) tgaflip(im->data, im->w, im->h);
|
if (vinverted)
|
||||||
if (progress)
|
tgaflip(im->data, im->w, im->h);
|
||||||
{
|
if (progress)
|
||||||
progress(im, 100, 0, 0, im->w, im->h);
|
{
|
||||||
} /* end for (each row) */
|
progress(im, 100, 0, 0, im->w, im->h);
|
||||||
|
} /* end for (each row) */
|
||||||
}
|
}
|
||||||
/* end if (image is RLE) */
|
/* end if (image is RLE) */
|
||||||
}
|
}
|
||||||
/* end if (loading pixel data) */
|
/* end if (loading pixel data) */
|
||||||
|
|
||||||
|
@ -534,23 +532,24 @@ formats(ImlibLoader * l)
|
||||||
/* flip a DATA32 image block vertically in place */
|
/* flip a DATA32 image block vertically in place */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tgaflip (DATA32 * in, int w, int h)
|
tgaflip(DATA32 * in, int w, int h)
|
||||||
{
|
{
|
||||||
DATA32 *adv, *adv2;
|
DATA32 *adv, *adv2;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
adv = in;
|
adv = in;
|
||||||
adv2 = in + (w * (h - 1));
|
adv2 = in + (w * (h - 1));
|
||||||
|
|
||||||
for (y = 0; y < (h / 2); y++)
|
for (y = 0; y < (h / 2); y++)
|
||||||
{
|
{
|
||||||
DATA32 tmp;
|
DATA32 tmp;
|
||||||
for (x = 0; x < w; x++)
|
|
||||||
{
|
for (x = 0; x < w; x++)
|
||||||
tmp = adv[x];
|
{
|
||||||
adv[x] = adv2[x];
|
tmp = adv[x];
|
||||||
adv2[x] = tmp;
|
adv[x] = adv2[x];
|
||||||
}
|
adv2[x] = tmp;
|
||||||
|
}
|
||||||
adv2 -= w;
|
adv2 -= w;
|
||||||
adv += w;
|
adv += w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,113 +7,125 @@
|
||||||
|
|
||||||
#define OUTBUF_SIZE 16484
|
#define OUTBUF_SIZE 16484
|
||||||
|
|
||||||
static int uncompress_file (int src, int dest)
|
static int
|
||||||
|
uncompress_file(int src, int dest)
|
||||||
{
|
{
|
||||||
gzFile gf;
|
gzFile gf;
|
||||||
DATA8 outbuf[OUTBUF_SIZE];
|
DATA8 outbuf[OUTBUF_SIZE];
|
||||||
int ret = 1, bytes;
|
int ret = 1, bytes;
|
||||||
|
|
||||||
gf = gzdopen (dup (src), "rb");
|
gf = gzdopen(dup(src), "rb");
|
||||||
if (!gf)
|
if (!gf)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (1) {
|
while (1)
|
||||||
bytes = gzread (gf, outbuf, OUTBUF_SIZE);
|
{
|
||||||
|
bytes = gzread(gf, outbuf, OUTBUF_SIZE);
|
||||||
|
|
||||||
if (!bytes)
|
if (!bytes)
|
||||||
break;
|
break;
|
||||||
else if (bytes == -1) {
|
else if (bytes == -1)
|
||||||
ret = 0;
|
{
|
||||||
break;
|
ret = 0;
|
||||||
} else
|
break;
|
||||||
write (dest, outbuf, bytes);
|
}
|
||||||
}
|
else
|
||||||
|
write(dest, outbuf, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
gzclose (gf);
|
gzclose(gf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char load (ImlibImage *im, ImlibProgressFunction progress,
|
char
|
||||||
char progress_granularity, char immediate_load)
|
load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
|
char progress_granularity, char immediate_load)
|
||||||
{
|
{
|
||||||
ImlibLoader *loader;
|
ImlibLoader *loader;
|
||||||
int src, dest, res;
|
int src, dest, res;
|
||||||
char *file, *p, tmp[] = "/tmp/imlib2_loader_zlib-XXXXXX";
|
char *file, *p, tmp[] = "/tmp/imlib2_loader_zlib-XXXXXX";
|
||||||
char real_ext[16];
|
char real_ext[16];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
assert (im);
|
assert(im);
|
||||||
|
|
||||||
/* check that this file ends in *.gz and that there's another ext
|
/* check that this file ends in *.gz and that there's another ext
|
||||||
* (e.g. "foo.png.gz"
|
* (e.g. "foo.png.gz"
|
||||||
*/
|
*/
|
||||||
p = strrchr(im->real_file, '.');
|
p = strrchr(im->real_file, '.');
|
||||||
if (p && p != im->real_file) {
|
if (p && p != im->real_file)
|
||||||
if (strcasecmp(p + 1, "gz"))
|
{
|
||||||
return 0;
|
if (strcasecmp(p + 1, "gz"))
|
||||||
} else
|
return 0;
|
||||||
return 0;
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
strncpy (real_ext, p - sizeof (real_ext) + 1, sizeof (real_ext));
|
strncpy(real_ext, p - sizeof(real_ext) + 1, sizeof(real_ext));
|
||||||
real_ext[sizeof (real_ext) - 1] = '\0';
|
real_ext[sizeof(real_ext) - 1] = '\0';
|
||||||
|
|
||||||
/* abort if there's no dot in the "real" filename */
|
/* abort if there's no dot in the "real" filename */
|
||||||
if (!strrchr (real_ext, '.'))
|
if (!strrchr(real_ext, '.'))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (stat (im->real_file, &st) < 0)
|
if (stat(im->real_file, &st) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((src = open (im->real_file, O_RDONLY)) < 0) {
|
if ((src = open(im->real_file, O_RDONLY)) < 0)
|
||||||
return 0;
|
{
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((dest = mkstemp (tmp)) < 0) {
|
if ((dest = mkstemp(tmp)) < 0)
|
||||||
close (src);
|
{
|
||||||
return 0;
|
close(src);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
res = uncompress_file (src, dest);
|
res = uncompress_file(src, dest);
|
||||||
close (src);
|
close(src);
|
||||||
close (dest);
|
close(dest);
|
||||||
|
|
||||||
if (!res) {
|
if (!res)
|
||||||
unlink (tmp);
|
{
|
||||||
return 0;
|
unlink(tmp);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(loader = __imlib_FindBestLoaderForFile (real_ext, 0))) {
|
if (!(loader = __imlib_FindBestLoaderForFile(real_ext, 0)))
|
||||||
unlink (tmp);
|
{
|
||||||
return 0;
|
unlink(tmp);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* remember the original filename */
|
/* remember the original filename */
|
||||||
file = strdup (im->real_file);
|
file = strdup(im->real_file);
|
||||||
|
|
||||||
free (im->real_file);
|
free(im->real_file);
|
||||||
im->real_file = strdup (tmp);
|
im->real_file = strdup(tmp);
|
||||||
loader->load (im, progress, progress_granularity, immediate_load);
|
loader->load(im, progress, progress_granularity, immediate_load);
|
||||||
|
|
||||||
free (im->real_file);
|
free(im->real_file);
|
||||||
im->real_file = file;
|
im->real_file = file;
|
||||||
unlink (tmp);
|
unlink(tmp);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void formats (ImlibLoader *l)
|
void
|
||||||
|
formats(ImlibLoader * l)
|
||||||
{
|
{
|
||||||
/* this is the only bit you have to change... */
|
/* this is the only bit you have to change... */
|
||||||
char *list_formats[] = {"gz"};
|
char *list_formats[] = { "gz" };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* don't bother changing any of this - it just reads this in
|
/* don't bother changing any of this - it just reads this in
|
||||||
* and sets the struct values and makes copies
|
* and sets the struct values and makes copies
|
||||||
*/
|
*/
|
||||||
l->num_formats = sizeof (list_formats) / sizeof (char *);
|
l->num_formats = sizeof(list_formats) / sizeof(char *);
|
||||||
l->formats = malloc (sizeof (char *) * l->num_formats);
|
l->formats = malloc(sizeof(char *) * l->num_formats);
|
||||||
|
|
||||||
for (i = 0; i < l->num_formats; i++)
|
for (i = 0; i < l->num_formats; i++)
|
||||||
l->formats[i] = strdup (list_formats[i]);
|
l->formats[i] = strdup(list_formats[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue