summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-25 19:29:23 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-25 19:29:23 +0000
commitbfca9b37987a37138cbf7a1da98bc48675ff28ab (patch)
tree247c27caca43cc06a27cdaee28e27cbcd7f5dd51
parent3160fb8048b7ecd003548d4424e012a8b600c65b (diff)
XFree86 4.3.99.16 Bring the tree up to date for the Cygwin folksxf86-4_3_99_903_specialxf86-4_3_99_902xf86-4_3_99_901xf86-4_3_99_16xf86-012804-2330
-rw-r--r--xwud.c94
-rw-r--r--xwud.man41
2 files changed, 109 insertions, 26 deletions
diff --git a/xwud.c b/xwud.c
index c928120..b0e911a 100644
--- a/xwud.c
+++ b/xwud.c
@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/programs/xwud/xwud.c,v 3.7 2001/12/14 20:02:35 dawes Exp $ */
+/* $XFree86: xc/programs/xwud/xwud.c,v 3.11 2003/11/17 15:18:08 tsi Exp $ */
/* xwud - marginally useful raster image undumper */
@@ -70,11 +70,12 @@ 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,
- XImage *in_image, XImage *out_image);
+ XImage *in_image, XImage *out_image, XVisualInfo *vinfo);
static unsigned int Image_Size(XImage *image);
static void Error(char *string);
static void _swapshort(char *bp, unsigned int n);
static void _swaplong(char *bp, unsigned int n);
+static void DumpHeader(const XWDFileHeader *header, const char *win_name);
static void
usage(void)
@@ -148,6 +149,7 @@ main(int argc, char *argv[])
XStandardColormap *stdmaps, *stdmap = NULL;
char c;
int win_width, win_height;
+ Bool dump_header = False;
progname = argv[0];
@@ -162,6 +164,10 @@ main(int argc, char *argv[])
display_name = argv[i];
continue;
}
+ if (strcmp(argv[i], "-dumpheader") == 0) {
+ dump_header = True;
+ continue;
+ }
if (strcmp(argv[i], "-fg") == 0) {
if (++i >= argc) usage();
fgname = argv[i];
@@ -276,6 +282,11 @@ main(int argc, char *argv[])
if(!Read(win_name + 6, sizeof(char), win_name_size, in_file))
Error("Unable to read window name from dump file.");
+ if (dump_header) {
+ DumpHeader(&header, win_name);
+ exit(0);
+ }
+
/* initialize the input image */
in_image = &in_image_struct;
@@ -397,7 +408,7 @@ main(int argc, char *argv[])
mask |= VisualIDMask;
sscanf(vis, "0x%lx", &vinfo.visualid);
if (!vinfo.visualid)
- sscanf(vis, "%ld", &vinfo.visualid);
+ sscanf(vis, "%lu", &vinfo.visualid);
if (!vinfo.visualid)
Error("invalid visual specifier");
}
@@ -530,7 +541,7 @@ main(int argc, char *argv[])
} else if ((header.visual_class == TrueColor) ||
(header.visual_class == DirectColor))
Do_Direct(dpy, &header, &colormap, ncolors, colors,
- in_image, out_image);
+ in_image, out_image, &vinfo);
else
Do_Pseudo(dpy, &colormap, ncolors, colors, in_image, out_image);
}
@@ -871,9 +882,9 @@ VisualRank(int class)
switch (class) {
case PseudoColor:
return 5;
- case DirectColor:
- return 4;
case TrueColor:
+ return 4;
+ case DirectColor:
return 3;
case StaticColor:
return 2;
@@ -981,12 +992,15 @@ Do_Pseudo(Display *dpy, Colormap *colormap,
static void
Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap,
- int ncolors, XColor *colors, XImage *in_image, XImage *out_image)
+ int ncolors, XColor *colors, XImage *in_image, XImage *out_image,
+ XVisualInfo *vinfo)
{
register int x, y;
XColor color;
unsigned long rmask, gmask, bmask;
- int rshift = 0, gshift = 0, bshift = 0;
+ unsigned long ormask, ogmask, obmask;
+ unsigned long rshift = 0, gshift = 0, bshift = 0;
+ unsigned long orshift = 0, ogshift = 0, obshift = 0;
int i;
unsigned long pix, xpix;
unsigned long *pixels, *rpixels;
@@ -1040,7 +1054,38 @@ Do_Direct(Display *dpy, XWDFileHeader *header, Colormap *colormap,
XPutPixel(out_image, x, y, color.pixel);
}
}
+ } else if (header->visual_class == TrueColor &&
+ vinfo->class == TrueColor) {
+ ormask = vinfo->red_mask;
+ while (!(ormask & 1)) {
+ ormask >>= 1;
+ orshift++;
+ }
+ ogmask = vinfo->green_mask;
+ while (!(ogmask & 1)) {
+ ogmask >>= 1;
+ ogshift++;
+ }
+ obmask = vinfo->blue_mask;
+ while (!(obmask & 1)) {
+ obmask >>= 1;
+ obshift++;
+ }
+ for (y = 0; y < in_image->height; y++) {
+ for (x = 0; x < in_image->width; x++) {
+ pix = XGetPixel(in_image, x, y);
+ xpix = (((((pix >> rshift) & rmask) * 65535 / rmask)
+ * ormask / 65535) << orshift) |
+ (((((pix >> gshift) & gmask) * 65535 / gmask)
+ * ogmask / 65535) << ogshift) |
+ (((((pix >> bshift) & bmask) * 65535 / bmask)
+ * obmask / 65535) << obshift);
+ XPutPixel(out_image, x, y, xpix);
+ }
+ }
} else {
+ if (header->visual_class == TrueColor)
+ ncolors = 0;
pix = 1 << 12;
pixels = (unsigned long *)malloc(sizeof(unsigned long) * pix);
rpixels = (unsigned long *)malloc(sizeof(unsigned long) * pix);
@@ -1136,3 +1181,36 @@ _swaplong(char *bp, unsigned int n)
bp += 2;
}
}
+
+static void
+DumpHeader(const XWDFileHeader *header, const char *win_name)
+{
+ printf("window name: %s\n", win_name);
+ printf("sizeof(XWDheader): %d\n", (int)sizeof(*header));
+ printf("header size: %d\n", (int)header->header_size);
+ printf("file version: %d\n", (int)header->file_version);
+ printf("pixmap format: %d\n", (int)header->pixmap_format);
+ printf("pixmap depth: %d\n", (int)header->pixmap_depth);
+ printf("pixmap width: %d\n", (int)header->pixmap_width);
+ printf("pixmap height: %d\n", (int)header->pixmap_height);
+ printf("x offset: %d\n", (int)header->xoffset);
+ printf("byte order: %d\n", (int)header->byte_order);
+ printf("bitmap unit: %d\n", (int)header->bitmap_unit);
+ printf("bitmap bit order: %d\n", (int)header->bitmap_bit_order);
+ printf("bitmap pad: %d\n", (int)header->bitmap_pad);
+ printf("bits per pixel: %d\n", (int)header->bits_per_pixel);
+ printf("bytes per line: %d\n", (int)header->bytes_per_line);
+ printf("visual class: %d\n", (int)header->visual_class);
+ printf("red mask: %d\n", (int)header->red_mask);
+ printf("green mask: %d\n", (int)header->green_mask);
+ printf("blue mask: %d\n", (int)header->blue_mask);
+ printf("bits per rgb: %d\n", (int)header->bits_per_rgb);
+ printf("colormap entries: %d\n", (int)header->colormap_entries);
+ printf("num colors: %d\n", (int)header->ncolors);
+ printf("window width: %d\n", (int)header->window_width);
+ printf("window height: %d\n", (int)header->window_height);
+ printf("window x: %d\n", (int)header->window_x);
+ printf("window y: %d\n", (int)header->window_y);
+ printf("border width: %d\n", (int)header->window_bdrwidth);
+}
+
diff --git a/xwud.man b/xwud.man
index aa905ce..23877cf 100644
--- a/xwud.man
+++ b/xwud.man
@@ -23,16 +23,17 @@
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
.\"
-.\" $XFree86: xc/programs/xwud/xwud.man,v 1.9 2002/04/22 20:53:11 herrb Exp $
+.\" $XFree86: xc/programs/xwud/xwud.man,v 1.10 2003/11/15 02:40:28 dawes Exp $
.\"
.TH XWUD 1 __xorgversion__
.SH NAME
xwud - image displayer for X
.SH SYNOPSIS
.B "xwud"
-[-in \fIfile\fP] [-noclick] [-geometry \fIgeom\fP] [-display \fIdisplay\fP]
-[-new] [-std <maptype>] [-raw] [-vis <vis-type-or-id>] [-scale]
-[-help] [-rv] [-plane \fInumber\fP] [-fg \fIcolor\fP] [-bg \fIcolor\fP]
+[\-in \fIfile\fP] [\-noclick] [\-geometry \fIgeom\fP] [\-display \fIdisplay\fP]
+[\-new] [\-std <maptype>] [\-raw] [\-vis <vis-type-or-id>] [\-scale]
+[\-help] [\-rv] [\-plane \fInumber\fP] [\-fg \fIcolor\fP] [\-bg \fIcolor\fP]
+[\-dumpheader]
.SH DESCRIPTION
.PP
.I Xwud
@@ -43,37 +44,41 @@ in a specially formatted dump file, such as produced by \fIxwd(1)\fP.
.SH OPTIONS
.PP
.TP 8
-.B "-bg \fIcolor\fP"
+.B "\-bg \fIcolor\fP"
If a bitmap image (or a single plane of an image) is displayed, this option
can be used to specify the color to display for the "0" bits in the image.
.PP
.TP 8
-.B "-display \fIdisplay\fP"
+.B "\-display \fIdisplay\fP"
This option allows you to specify the server to connect to; see \fIX(__miscmansuffix__)\fP.
.PP
.TP 8
-.B "-fg \fIcolor\fP"
+.B \-dumpheader
+This option prints out the XWD header information only. Nothing is displayed.
+.PP
+.TP 8
+.B "\-fg \fIcolor\fP"
If a bitmap image (or a single plane of an image) is displayed, this option
can be used to specify the color to display for the "1" bits in the image.
.PP
.TP 8
-.B "-geometry \fIgeom\fP"
+.B "\-geometry \fIgeom\fP"
This option allows you to specify the size and position of the window.
Typically you will only want to specify the position, and let the size
default to the actual size of the image.
.PP
.TP 8
-.B "-help"
+.B "\-help"
Print out a short description of the allowable options.
.PP
.TP 8
-.B "-in \fIfile\fP"
+.B "\-in \fIfile\fP"
This option allows the user to explicitly specify the input
file on the command line. If no input file is given, the standard input
is assumed.
.PP
.TP 8
-.B -new
+.B \-new
This option forces creation of a new colormap for displaying the image.
If the image characteristics happen to match those of the display, this
can get the image on the screen faster, but at the cost of using a new
@@ -81,19 +86,19 @@ colormap (which on most displays will cause other windows to go
technicolor).
.PP
.TP 8
-.B "-noclick"
+.B "\-noclick"
Clicking any button in the window will terminate the application,
unless this option is specified. Termination can always be achieved
by typing 'q', 'Q', or ctrl-c.
.PP
.TP 8
-.B "-plane \fInumber\fP"
+.B "\-plane \fInumber\fP"
You can select a single bit plane of the image to display
with this option. Planes are numbered with zero being the least
significant bit.
.PP
.TP 8
-.B -raw
+.B \-raw
This option forces the image to be displayed with whatever color values
happen to currently exist on the screen. This option is mostly useful when
undumping an image back onto the same screen that the image originally
@@ -101,18 +106,18 @@ came from, while the original windows are still on the screen, and results
in getting the image on the screen faster.
.PP
.TP 8
-.B -rv
+.B \-rv
If a bitmap image (or a single plane of an image) is displayed, this option
forces the foreground and background colors to be swapped. This may be
needed when displaying a bitmap image which has the color sense of pixel
values "0" and "1" reversed from what they are on your display.
.PP
.TP 8
-.B -scale
+.B \-scale
Allow the window to be resized, and scale the image to the size of the window.
.PP
.TP 8
-.B "-std \fImaptype\fP"
+.B "\-std \fImaptype\fP"
This option causes the image to be displayed using the specified
Standard Colormap. The property name is obtained by converting the
type to upper case, prepending "RGB_", and appending "_MAP".
@@ -120,7 +125,7 @@ Typical types are "best", "default", and "gray". See \fIxstdcmap(1)\fP
for one way of creating Standard Colormaps.
.PP
.TP 8
-.B "-vis \fIvis-type-or-id\fP"
+.B "\-vis \fIvis-type-or-id\fP"
This option allows you to specify a particular visual or visual class.
The default is to pick the "best" one. A particular class can be
specified: "StaticGray", "GrayScale", "StaticColor", "PseudoColor",