xwd (X Window Dump) bitmap image: GraphViz block diagram (.dot) source

xwd is a file format written by eponymous X11 screen capture application (xwd stands for "X Window Dump"). Typically, an average user transforms xwd format into something more widespread by any of xwdtopnm and pnmto... utilities right away.

xwd format itself provides a raw uncompressed bitmap with some metainformation, like pixel format, width, height, bit depth, etc. Note that technically format includes machine-dependent fields and thus is probably a poor choice for true cross-platform usage.

Application

xwd

File extension

xwd

KS implementation details

License: CC0-1.0

References

This page hosts a formal specification of xwd (X Window Dump) bitmap image using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

GraphViz block diagram source

xwd.dot

digraph {
	rankdir=LR;
	node [shape=plaintext];
	subgraph cluster__xwd {
		label="Xwd";
		graph[style=dotted];

		xwd__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
			<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
			<TR><TD PORT="len_header_pos">0</TD><TD PORT="len_header_size">4</TD><TD>u4be</TD><TD PORT="len_header_type">len_header</TD></TR>
			<TR><TD PORT="hdr_pos">4</TD><TD PORT="hdr_size">(len_header - 4)</TD><TD>Header</TD><TD PORT="hdr_type">hdr</TD></TR>
			<TR><TD PORT="color_map_pos">...</TD><TD PORT="color_map_size">12</TD><TD>ColorMapEntry</TD><TD PORT="color_map_type">color_map</TD></TR>
			<TR><TD COLSPAN="4" PORT="color_map__repeat">repeat hdr.color_map_entries times</TD></TR>
		</TABLE>>];
		subgraph cluster__header {
			label="Xwd::Header";
			graph[style=dotted];

			header__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="file_version_pos">0</TD><TD PORT="file_version_size">4</TD><TD>u4be</TD><TD PORT="file_version_type">file_version</TD></TR>
				<TR><TD PORT="pixmap_format_pos">4</TD><TD PORT="pixmap_format_size">4</TD><TD>u4be→PixmapFormat</TD><TD PORT="pixmap_format_type">pixmap_format</TD></TR>
				<TR><TD PORT="pixmap_depth_pos">8</TD><TD PORT="pixmap_depth_size">4</TD><TD>u4be</TD><TD PORT="pixmap_depth_type">pixmap_depth</TD></TR>
				<TR><TD PORT="pixmap_width_pos">12</TD><TD PORT="pixmap_width_size">4</TD><TD>u4be</TD><TD PORT="pixmap_width_type">pixmap_width</TD></TR>
				<TR><TD PORT="pixmap_height_pos">16</TD><TD PORT="pixmap_height_size">4</TD><TD>u4be</TD><TD PORT="pixmap_height_type">pixmap_height</TD></TR>
				<TR><TD PORT="x_offset_pos">20</TD><TD PORT="x_offset_size">4</TD><TD>u4be</TD><TD PORT="x_offset_type">x_offset</TD></TR>
				<TR><TD PORT="byte_order_pos">24</TD><TD PORT="byte_order_size">4</TD><TD>u4be→ByteOrder</TD><TD PORT="byte_order_type">byte_order</TD></TR>
				<TR><TD PORT="bitmap_unit_pos">28</TD><TD PORT="bitmap_unit_size">4</TD><TD>u4be</TD><TD PORT="bitmap_unit_type">bitmap_unit</TD></TR>
				<TR><TD PORT="bitmap_bit_order_pos">32</TD><TD PORT="bitmap_bit_order_size">4</TD><TD>u4be</TD><TD PORT="bitmap_bit_order_type">bitmap_bit_order</TD></TR>
				<TR><TD PORT="bitmap_pad_pos">36</TD><TD PORT="bitmap_pad_size">4</TD><TD>u4be</TD><TD PORT="bitmap_pad_type">bitmap_pad</TD></TR>
				<TR><TD PORT="bits_per_pixel_pos">40</TD><TD PORT="bits_per_pixel_size">4</TD><TD>u4be</TD><TD PORT="bits_per_pixel_type">bits_per_pixel</TD></TR>
				<TR><TD PORT="bytes_per_line_pos">44</TD><TD PORT="bytes_per_line_size">4</TD><TD>u4be</TD><TD PORT="bytes_per_line_type">bytes_per_line</TD></TR>
				<TR><TD PORT="visual_class_pos">48</TD><TD PORT="visual_class_size">4</TD><TD>u4be→VisualClass</TD><TD PORT="visual_class_type">visual_class</TD></TR>
				<TR><TD PORT="red_mask_pos">52</TD><TD PORT="red_mask_size">4</TD><TD>u4be</TD><TD PORT="red_mask_type">red_mask</TD></TR>
				<TR><TD PORT="green_mask_pos">56</TD><TD PORT="green_mask_size">4</TD><TD>u4be</TD><TD PORT="green_mask_type">green_mask</TD></TR>
				<TR><TD PORT="blue_mask_pos">60</TD><TD PORT="blue_mask_size">4</TD><TD>u4be</TD><TD PORT="blue_mask_type">blue_mask</TD></TR>
				<TR><TD PORT="bits_per_rgb_pos">64</TD><TD PORT="bits_per_rgb_size">4</TD><TD>u4be</TD><TD PORT="bits_per_rgb_type">bits_per_rgb</TD></TR>
				<TR><TD PORT="number_of_colors_pos">68</TD><TD PORT="number_of_colors_size">4</TD><TD>u4be</TD><TD PORT="number_of_colors_type">number_of_colors</TD></TR>
				<TR><TD PORT="color_map_entries_pos">72</TD><TD PORT="color_map_entries_size">4</TD><TD>u4be</TD><TD PORT="color_map_entries_type">color_map_entries</TD></TR>
				<TR><TD PORT="window_width_pos">76</TD><TD PORT="window_width_size">4</TD><TD>u4be</TD><TD PORT="window_width_type">window_width</TD></TR>
				<TR><TD PORT="window_height_pos">80</TD><TD PORT="window_height_size">4</TD><TD>u4be</TD><TD PORT="window_height_type">window_height</TD></TR>
				<TR><TD PORT="window_x_pos">84</TD><TD PORT="window_x_size">4</TD><TD>s4be</TD><TD PORT="window_x_type">window_x</TD></TR>
				<TR><TD PORT="window_y_pos">88</TD><TD PORT="window_y_size">4</TD><TD>s4be</TD><TD PORT="window_y_type">window_y</TD></TR>
				<TR><TD PORT="window_border_width_pos">92</TD><TD PORT="window_border_width_size">4</TD><TD>u4be</TD><TD PORT="window_border_width_type">window_border_width</TD></TR>
				<TR><TD PORT="creator_pos">96</TD><TD PORT="creator_size">...</TD><TD>str(UTF-8)</TD><TD PORT="creator_type">creator</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__color_map_entry {
			label="Xwd::ColorMapEntry";
			graph[style=dotted];

			color_map_entry__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
				<TR><TD PORT="entry_number_pos">0</TD><TD PORT="entry_number_size">4</TD><TD>u4be</TD><TD PORT="entry_number_type">entry_number</TD></TR>
				<TR><TD PORT="red_pos">4</TD><TD PORT="red_size">2</TD><TD>u2be</TD><TD PORT="red_type">red</TD></TR>
				<TR><TD PORT="green_pos">6</TD><TD PORT="green_size">2</TD><TD>u2be</TD><TD PORT="green_type">green</TD></TR>
				<TR><TD PORT="blue_pos">8</TD><TD PORT="blue_size">2</TD><TD>u2be</TD><TD PORT="blue_type">blue</TD></TR>
				<TR><TD PORT="flags_pos">10</TD><TD PORT="flags_size">1</TD><TD>u1</TD><TD PORT="flags_type">flags</TD></TR>
				<TR><TD PORT="padding_pos">11</TD><TD PORT="padding_size">1</TD><TD>u1</TD><TD PORT="padding_type">padding</TD></TR>
			</TABLE>>];
		}
	}
	xwd__seq:len_header_type -> xwd__seq:hdr_size [color="#404040"];
	xwd__seq:hdr_type -> header__seq [style=bold];
	xwd__seq:color_map_type -> color_map_entry__seq [style=bold];
	header__seq:color_map_entries_type -> xwd__seq:color_map__repeat [color="#404040"];
}