This commit is contained in:
purplerain 2024-10-06 22:00:57 +00:00
parent 50c8bafd9f
commit ac06c97e30
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
820 changed files with 467502 additions and 386453 deletions

View file

@ -50,26 +50,26 @@ static int split;
static char *progname;
static Bool Read(char *ptr, int size, int nitems, FILE *stream);
static void putImage(Display *dpy, Window image_win, GC gc,
static void putImage(Display *dpy, Window image_win, GC gc,
XImage *out_image, int x, int y, int w, int h);
static void putScaledImage(Display *display, Drawable d, GC gc,
XImage *src_image, int exp_x, int exp_y,
unsigned int exp_width, unsigned int exp_height,
static void putScaledImage(Display *display, Drawable d, GC gc,
XImage *src_image, int exp_x, int exp_y,
unsigned int exp_width, unsigned int exp_height,
unsigned int dest_width, unsigned dest_height);
static void Latin1Upper(char *s);
static void Extract_Plane(XImage *in_image, XImage *out_image, int plane);
static int EffectiveSize(XVisualInfo *vinfo);
static int VisualRank(int class);
static int IsGray(Display *dpy, XStandardColormap *stdmap);
static void Do_StdGray(Display *dpy, XStandardColormap *stdmap, int ncolors,
static void Do_StdGray(Display *dpy, XStandardColormap *stdmap, int ncolors,
XColor *colors, XImage *in_image, XImage *out_image);
static void Do_StdCol(Display *dpy, XStandardColormap *stdmap, int ncolors,
static void Do_StdCol(Display *dpy, XStandardColormap *stdmap, int ncolors,
XColor *colors, XImage *in_image, XImage *out_image);
static Colormap CopyColormapAndFree(Display *dpy, Colormap colormap);
static void Do_Pseudo(Display *dpy, Colormap *colormap, int ncolors,
static void Do_Pseudo(Display *dpy, Colormap *colormap, int ncolors,
XColor *colors, XImage *in_image, XImage *out_image);
static void Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap,
int ncolors, XColor *colors,
static void Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap,
int ncolors, XColor *colors,
XImage *in_image, XImage *out_image, XVisualInfo *vinfo);
static unsigned int Image_Size(XImage *image);
static void Error(const char *string) _X_NORETURN;
@ -107,7 +107,7 @@ Read(char *ptr, int size, int nitems, FILE *stream)
return True;
}
int
int
main(int argc, char *argv[])
{
Display *dpy;
@ -247,7 +247,7 @@ main(int argc, char *argv[])
progname, argv[i]);
usage(NULL);
}
if (file_name) {
in_file = fopen(file_name, "rb");
if (in_file == NULL)
@ -257,7 +257,7 @@ main(int argc, char *argv[])
else
_setmode(fileno(in_file), _O_BINARY);
#endif
dpy = XOpenDisplay(display_name);
if (dpy == NULL) {
fprintf(stderr, "%s: unable to open display \"%s\"\n",
@ -302,7 +302,7 @@ main(int argc, char *argv[])
DumpHeader(&header, win_name);
exit(0);
}
/* initialize the input image */
in_image = &in_image_struct;
@ -616,7 +616,7 @@ main(int argc, char *argv[])
hints.height : out_image->height;
}
if ((gbits & XValue) && (gbits & XNegative))
hints.x += DisplayWidth(dpy, screen) - hints.width;
hints.x += DisplayWidth(dpy, screen) - hints.width;
if ((gbits & YValue) && (gbits & YNegative))
hints.y += DisplayHeight(dpy, screen) - hints.height;
@ -633,7 +633,7 @@ main(int argc, char *argv[])
wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", False);
wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
(void) XSetWMProtocols (dpy, image_win, &wm_delete_window, 1);
textprop.value = (unsigned char *) win_name;
textprop.encoding = XA_STRING;
textprop.format = 8;
@ -654,7 +654,7 @@ main(int argc, char *argv[])
XNextEvent(dpy, &event);
switch(event.type) {
case ClientMessage:
if (event.xclient.message_type == wm_protocols &&
if (event.xclient.message_type == wm_protocols &&
event.xclient.data.l[0] == wm_delete_window) {
XCloseDisplay(dpy);
exit(0); /* ICCCM delete window */
@ -702,7 +702,7 @@ main(int argc, char *argv[])
}
static void
putImage(Display *dpy, Window image_win, GC gc, XImage *out_image,
putImage(Display *dpy, Window image_win, GC gc, XImage *out_image,
int x, int y, int w, int h)
{
#define SPLIT_SIZE 100
@ -737,29 +737,29 @@ typedef struct {
} Table;
static void
putScaledImage(Display *display, Drawable d, GC gc, XImage *src_image,
putScaledImage(Display *display, Drawable d, GC gc, XImage *src_image,
int exp_x, int exp_y,
unsigned int exp_width, unsigned int exp_height,
unsigned int exp_width, unsigned int exp_height,
unsigned int dest_width, unsigned dest_height)
{
XImage *dest_image;
Position x, y, min_y, max_y, exp_max_y, src_x, src_max_x, src_y;
Dimension w, h, strip_height;
Table table;
Table table;
Pixel pixel;
double ratio_x, ratio_y;
Bool fast8;
if (dest_width == src_image->width && dest_height == src_image->height) {
/* same for x and y, just send it out */
XPutImage(display, d, gc, src_image, exp_x, exp_y,
exp_x, exp_y, exp_width, exp_height);
XPutImage(display, d, gc, src_image, exp_x, exp_y,
exp_x, exp_y, exp_width, exp_height);
return;
}
ratio_x = (double)dest_width / (double)src_image->width;
ratio_y = (double)dest_height / (double)src_image->height;
src_x = exp_x / ratio_x;
if (src_x >= src_image->width)
src_x = src_image->width - 1;
@ -781,7 +781,7 @@ putScaledImage(Display *display, Drawable d, GC gc, XImage *src_image,
dest_image = XCreateImage(display,
DefaultVisualOfScreen(
DefaultScreenOfDisplay(display)),
src_image->depth, src_image->format,
src_image->depth, src_image->format,
0, NULL,
dest_width, h,
src_image->bitmap_pad, 0);
@ -793,7 +793,7 @@ putScaledImage(Display *display, Drawable d, GC gc, XImage *src_image,
table.y = (Position *) malloc(sizeof(Position) * (src_image->height + 1));
table.width = (Dimension *) malloc(sizeof(Dimension) * src_image->width);
table.height = (Dimension *) malloc(sizeof(Dimension)*src_image->height);
table.x[0] = 0;
for (x = 1; x <= src_image->width; x++) {
table.x[x] = roundint(ratio_x * x);
@ -844,7 +844,7 @@ putScaledImage(Display *display, Drawable d, GC gc, XImage *src_image,
if (y >= src_image->height)
break;
}
XFree((char *)table.x);
XFree((char *)table.y);
XFree((char *)table.width);
@ -921,8 +921,8 @@ IsGray(Display *dpy, XStandardColormap *stdmap)
return (color.green || color.blue);
}
static void
Do_StdGray(Display *dpy, XStandardColormap *stdmap,
static void
Do_StdGray(Display *dpy, XStandardColormap *stdmap,
int ncolors, XColor *colors, XImage *in_image, XImage *out_image)
{
register int i, x, y;
@ -947,7 +947,7 @@ Do_StdGray(Display *dpy, XStandardColormap *stdmap,
#define MapVal(val,lim,mult) ((((val * lim) + 32768) / 65535) * mult)
static void
Do_StdCol(Display *dpy, XStandardColormap *stdmap,
Do_StdCol(Display *dpy, XStandardColormap *stdmap,
int ncolors, XColor *colors, XImage *in_image, XImage *out_image)
{
register int i, x, y;
@ -981,7 +981,7 @@ CopyColormapAndFree(Display *dpy, Colormap colormap)
}
static void
Do_Pseudo(Display *dpy, Colormap *colormap,
Do_Pseudo(Display *dpy, Colormap *colormap,
int ncolors, XColor *colors, XImage *in_image, XImage *out_image)
{
register int i, x, y;
@ -1005,7 +1005,7 @@ Do_Pseudo(Display *dpy, Colormap *colormap,
}
static void
Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap,
Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap,
int ncolors, XColor *colors, XImage *in_image, XImage *out_image,
XVisualInfo *vinfo)
{
@ -1149,7 +1149,7 @@ Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap,
}
}
static unsigned int
static unsigned int
Image_Size(XImage *image)
{
if (image->format != ZPixmap)