XWD

From MultimediaWiki
Jump to: navigation, search

XWD is used to store images of captured X window displays.

The XWD (X Window Dump) format is used specifically to store screen dumps created by the X Window System. Under X11, screen dumps are created by the xwd client. Using xwd, the window or background is selected to dump and an XWD file is produced containing an image of the window. If you issue the following command:

% xwd -root > output.xwd

the entire contents of the current display are saved to the file output.xwd. The id of the window to dump may also be specified by using the -id command-line flag on versions of xwd prior to Release 5.

Contents: File Organization For Further Information File Organization

The first version of the X Window System to support window dumps was X10. Only gray-scale and color-mapped dumps were supported, and the bitmapped data was never compressed. The X10 version of XWD contains the following header:

typedef struct _X10WindowDump
{
 LONG  HeaderSize;         /* Header size in bytes */
 LONG  FileVersion;        /* X10 XWD file version (always 06h) */
 LONG  DisplayType;        /* Display type */
 LONG  DisplayPlanes;      /* Number of display planes */
 LONG  PixmapFormat;       /* Pixmap format */
 LONG  PixmapWidth;        /* Pixmap width */
 LONG  PixmapHeight;       /* Pixmap height */
 SHORT WindowWidth;        /* Window width */
 SHORT WindowHeight;       /* Window height */
 SHORT WindowX;            /* Window upper left X coordinate */
 SHORT WindowY;            /* Window upper left Y coordinate */
 SHORT WindowBorderWidth;  /* Window border width */
 SHORT WindowNumColors;    /* Number of color entries in window */
} X10WINDOWDUMP;

HeaderSize is the size of the header in bytes. This value is always 40.

FileVersion contains the version number of the XWD file. This value is always 06h.

DisplayType is the type of the display from which the image was dumped.

DisplayPlanes is the number of color planes in the image data. This value is typically 01h or 03h.

PixmapFormat indicates the format of the bitmap. A value of 00h indicates a single-plane bitmap (XYFormat), and a value of 01h indicates a bitmap with two or more planes (ZFormat).

PixmapWidth and PixmapHeight represent the size of the image in pixels.

WindowWidth and WindowHeight represent the size of the window to display.

WindowX and WindowY represent the position of the window on the display.

WindowBorderWidth indicates the width of the window border in pixels.

WindowNumColors specifies the number of colors that can be displayed in the window.

If the image is a PseudoColor image, a color map immediately follows the header. The color map contains one entry per color in the image, and each entry has the following format:

typedef struct _X10ColorMap
{
 WORD EntryNumber;     /* Number of the color-map entry */
 WORD Red;             /* Red-channel value */
 WORD Green;           /* Green-channel value */
 WORD Blue;            /* Blue-channel value */
} X10COLORMAP[WindowNumColors];

EntryNumber is the number of the color-map entry. This value starts at 00h. Color maps typically do not exceed 256 entries in size.

Red, Green, and Blue are the RGB channel values for this entry. The range of each of these values is typically 0 to 65535; often, only the high byte of the value is set (i.e., the value is 0-255 shifted left eight bits.)

The XWD format was revised for Version 11 of the X Window System. The new format can store more types of image data and many fields have been added to the header and to the color map, reflecting the increased graphics capabilities of X11 over X10.

The Version 11 XWD file format contains the following header:

typedef struct _X11WindowDump
{
 DWORD HeaderSize;     /* Size of the header in bytes */
 DWORD FileVersion;    /* X11WD file version (always 07h) */
 DWORD PixmapFormat;   /* Pixmap format */
 DWORD PixmapDepth;    /* Pixmap depth in pixels */
 DWORD PixmapWidth;    /* Pixmap width in pixels */ /
 DWORD PixmapHeight;   /* Pixmap height in pixels */
 DWORD XOffset;        /* Bitmap X offset */
 DWORD ByteOrder;      /* Byte order of image data */
 DWORD BitmapUnit;     /* Bitmap base data size */
 DWORD BitmapBitOrder; /* Bit-order of image data */
 DWORD BitmapPad;      /* Bitmap scan-line pad*/
 DWORD BitsPerPixel;   /* Bits per pixel */
 DWORD BytesPerLine;   /* Bytes per scan-line */
 DWORD VisualClass;    /* Class of the image */
 DWORD RedMask;        /* Red mask */
 DWORD GreenMask;      /* Green mask */
 DWORD BlueMask;       /* Blue mask */
 DWORD BitsPerRgb;     /* Size of each color mask in bits */
 DWORD NumberOfColors;         /* Number of colors in image */
 DWORD ColorMapEntries;        /* Number of entries in color map */
 DWORD WindowWidth;    /* Window width */
 DWORD WindowHeight;   /* Window height */
 LONG  WindowX;        /* Window upper left X coordinate */
 LONG  WindowY;        /* Window upper left Y coordinate */
 DWORD WindowBorderWidth;      /* Window border width */
} X11WINDOWDUMP;

HeaderSize is the size of the header in bytes. This value is always 40.

FileVersion contains the version number of the XWD file. This value is always 07h.

PixmapFormat is the format of the image data. A value of 00h indicates a 1-bit (XYBitmap) format. A value of 01h indicates a single-plane bitmap (XYPixmap). A value of 02h indicates a bitmap with two or more planes (ZPixmap).

PixmapDepth is the depth of the bitmap in pixels. This value is 1 to 32.

PixmapWidth and PixmapHeight represent the size of the image in pixels.

XOffset specifies the number of pixels to ignore at the beginning of each scan-line.

ByteOrder indicates the byte order of the image data. Values for this field are 00h for least significant byte first, and 0 for most significant byte first.

BitmapUnit is the size of each data unit in each scan line. This value may be 8, 16, or 32.

BitmapBitOrder indicates the order of the bits within each byte of image data. Values for this field are 00h for least significant byte first, and 0 for most significant byte first.

BitmapPad is the number of bits of padding added to each scan line. This value may be 8, 16, or 32.

BitsPerPixel contains the size of each pixel in bits. For StaticGray and GrayScale images, this value is 1. For StaticColor and PseudoColor images, this value is 2 to 15 (typically 8). For TrueColor and DirectColor images, this value is 16, 24, or 32.

BytesPerLine is the size of each scan line in bytes.

VisualClass indicates the format of the image data:

  • Even-numbered values indicate fixed-image data that cannot be changed in memory.
  • Odd-numbered values indicate dynamic image data that may be altered.
  • The values 00h (StaticGray) and 01h (GrayScale) specify a gray-scale image.
  • The values 02h (StaticColor) and 03h (PseudoColor) indicate a color mapped image.
  • The values 04h (TrueColor) and 05h (DirectColor) indicate true-color image data.

RedMask, GreenMask, and BlueMask are the RGB mask values used by ZPixmaps.

BitsPerRgb is the size of each RedMask, GreenMask, and BlueMask in bits.

NumberOfColors specifies the number of colors in the image. This value also indicates the number of colors for colormapped images as well.

ColorMapEntries contains the number of entries in the color map. This value is 00h if there is no color map.

WindowWidth and WindowHeight are the size of the window to display.

WindowX and WindowY contain the position of the window on the display.

WindowBorderWidth is the width of the X Window border in pixels. If the border has not been captured in the dump, this value is 00h.

The color map immediately follows the header. Each entry in the color map is 12 bytes in size and has the following format:

typedef struct _X11ColorMap
{
 DWORD EntryNumber;    /* Number of the color map entry */
 WORD  Red;            /* Red-channel value */
 WORD  Green;          /* Green-channel value */
 WORD  Blue;           /* Blue-channel value */
 CHAR  Flags;          /* Flag for this entry */
 CHAR  Padding;        /* WORD-align padding */
} X11COLORMAP[ColorMapEntries];

EntryNumber is the number of the color map entry. This value starts at 00h. Color maps typically do not exceed 256 entries in size.

Red, Green, and Blue are the RGB channel values for this entry. The range of each of these values is typically 0 to 65535; often, only the high byte of the value is set (i.e., the value is 0-255 shifted left eight bits.)

Flags indicates which of the color channels in the color map are actually used. The value of this field is typically 07h, indicating that all three channels are used.

Padding is a byte set to a value of 00h and used to pad the color map entry out to an even WORD boundary in size. For Further Information

This page is taken from the Encyclopedia of Graphics File Formats and is licensed by O'Reilly under the Creative Common/Attribution license.