TGA (AKA Truevision TGA, AKA TARGA) raster image file format: GraphViz block diagram (.dot) source

TGA (AKA Truevision TGA, AKA TARGA), is a raster image file format created by Truevision. It supports up to 32 bits per pixel (three 8-bit RGB channels + 8-bit alpha channel), color mapping and optional lossless RLE compression.

File extension

["tga", "icb", "vda", "vst"]

KS implementation details

License: CC0-1.0

References

This page hosts a formal specification of TGA (AKA Truevision TGA, AKA TARGA) raster image file format using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

GraphViz block diagram source

tga.dot

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

		tga__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="image_id_len_pos">0</TD><TD PORT="image_id_len_size">1</TD><TD>u1</TD><TD PORT="image_id_len_type">image_id_len</TD></TR>
			<TR><TD PORT="color_map_type_pos">1</TD><TD PORT="color_map_type_size">1</TD><TD>u1→ColorMapEnum</TD><TD PORT="color_map_type_type">color_map_type</TD></TR>
			<TR><TD PORT="image_type_pos">2</TD><TD PORT="image_type_size">1</TD><TD>u1→ImageTypeEnum</TD><TD PORT="image_type_type">image_type</TD></TR>
			<TR><TD PORT="color_map_ofs_pos">3</TD><TD PORT="color_map_ofs_size">2</TD><TD>u2le</TD><TD PORT="color_map_ofs_type">color_map_ofs</TD></TR>
			<TR><TD PORT="num_color_map_pos">5</TD><TD PORT="num_color_map_size">2</TD><TD>u2le</TD><TD PORT="num_color_map_type">num_color_map</TD></TR>
			<TR><TD PORT="color_map_depth_pos">7</TD><TD PORT="color_map_depth_size">1</TD><TD>u1</TD><TD PORT="color_map_depth_type">color_map_depth</TD></TR>
			<TR><TD PORT="x_offset_pos">8</TD><TD PORT="x_offset_size">2</TD><TD>u2le</TD><TD PORT="x_offset_type">x_offset</TD></TR>
			<TR><TD PORT="y_offset_pos">10</TD><TD PORT="y_offset_size">2</TD><TD>u2le</TD><TD PORT="y_offset_type">y_offset</TD></TR>
			<TR><TD PORT="width_pos">12</TD><TD PORT="width_size">2</TD><TD>u2le</TD><TD PORT="width_type">width</TD></TR>
			<TR><TD PORT="height_pos">14</TD><TD PORT="height_size">2</TD><TD>u2le</TD><TD PORT="height_type">height</TD></TR>
			<TR><TD PORT="image_depth_pos">16</TD><TD PORT="image_depth_size">1</TD><TD>u1</TD><TD PORT="image_depth_type">image_depth</TD></TR>
			<TR><TD PORT="img_descriptor_pos">17</TD><TD PORT="img_descriptor_size">1</TD><TD>u1</TD><TD PORT="img_descriptor_type">img_descriptor</TD></TR>
			<TR><TD PORT="image_id_pos">18</TD><TD PORT="image_id_size">image_id_len</TD><TD></TD><TD PORT="image_id_type">image_id</TD></TR>
			<TR><TD PORT="color_map_pos">...</TD><TD PORT="color_map_size">((color_map_depth + 7) / 8)</TD><TD></TD><TD PORT="color_map_type">color_map</TD></TR>
			<TR><TD COLSPAN="4" PORT="color_map__repeat">repeat num_color_map times</TD></TR>
		</TABLE>>];
		tga__inst__footer [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="footer_pos">(_io.size - 26)</TD><TD PORT="footer_size">26</TD><TD>TgaFooter</TD><TD PORT="footer_type">footer</TD></TR>
		</TABLE>>];
		subgraph cluster__tga_footer {
			label="Tga::TgaFooter";
			graph[style=dotted];

			tga_footer__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="ext_area_ofs_pos">0</TD><TD PORT="ext_area_ofs_size">4</TD><TD>u4le</TD><TD PORT="ext_area_ofs_type">ext_area_ofs</TD></TR>
				<TR><TD PORT="dev_dir_ofs_pos">4</TD><TD PORT="dev_dir_ofs_size">4</TD><TD>u4le</TD><TD PORT="dev_dir_ofs_type">dev_dir_ofs</TD></TR>
				<TR><TD PORT="version_magic_pos">8</TD><TD PORT="version_magic_size">18</TD><TD></TD><TD PORT="version_magic_type">version_magic</TD></TR>
			</TABLE>>];
			tga_footer__inst__is_valid [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
				<TR><TD BGCOLOR="#E0FFE0">id</TD><TD BGCOLOR="#E0FFE0">value</TD></TR>
				<TR><TD>is_valid</TD><TD>version_magic == [84, 82, 85, 69, 86, 73, 83, 73, 79, 78, 45, 88, 70, 73, 76, 69, 46, 0].pack('C*')</TD></TR>
			</TABLE>>];
			tga_footer__inst__ext_area [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="ext_area_pos">ext_area_ofs</TD><TD PORT="ext_area_size">495</TD><TD>TgaExtArea</TD><TD PORT="ext_area_type">ext_area</TD></TR>
			</TABLE>>];
		}
		subgraph cluster__tga_ext_area {
			label="Tga::TgaExtArea";
			graph[style=dotted];

			tga_ext_area__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="ext_area_size_pos">0</TD><TD PORT="ext_area_size_size">2</TD><TD>u2le</TD><TD PORT="ext_area_size_type">ext_area_size</TD></TR>
				<TR><TD PORT="author_name_pos">2</TD><TD PORT="author_name_size">41</TD><TD>str(ASCII)</TD><TD PORT="author_name_type">author_name</TD></TR>
				<TR><TD PORT="comments_pos">43</TD><TD PORT="comments_size">81</TD><TD>str(ASCII)</TD><TD PORT="comments_type">comments</TD></TR>
				<TR><TD COLSPAN="4" PORT="comments__repeat">repeat 4 times</TD></TR>
				<TR><TD PORT="timestamp_pos">367</TD><TD PORT="timestamp_size">12</TD><TD></TD><TD PORT="timestamp_type">timestamp</TD></TR>
				<TR><TD PORT="job_id_pos">379</TD><TD PORT="job_id_size">41</TD><TD>str(ASCII)</TD><TD PORT="job_id_type">job_id</TD></TR>
				<TR><TD PORT="job_time_pos">420</TD><TD PORT="job_time_size">6</TD><TD>str(ASCII)</TD><TD PORT="job_time_type">job_time</TD></TR>
				<TR><TD PORT="software_id_pos">426</TD><TD PORT="software_id_size">41</TD><TD>str(ASCII)</TD><TD PORT="software_id_type">software_id</TD></TR>
				<TR><TD PORT="software_version_pos">467</TD><TD PORT="software_version_size">3</TD><TD></TD><TD PORT="software_version_type">software_version</TD></TR>
				<TR><TD PORT="key_color_pos">470</TD><TD PORT="key_color_size">4</TD><TD>u4le</TD><TD PORT="key_color_type">key_color</TD></TR>
				<TR><TD PORT="pixel_aspect_ratio_pos">474</TD><TD PORT="pixel_aspect_ratio_size">4</TD><TD>u4le</TD><TD PORT="pixel_aspect_ratio_type">pixel_aspect_ratio</TD></TR>
				<TR><TD PORT="gamma_value_pos">478</TD><TD PORT="gamma_value_size">4</TD><TD>u4le</TD><TD PORT="gamma_value_type">gamma_value</TD></TR>
				<TR><TD PORT="color_corr_ofs_pos">482</TD><TD PORT="color_corr_ofs_size">4</TD><TD>u4le</TD><TD PORT="color_corr_ofs_type">color_corr_ofs</TD></TR>
				<TR><TD PORT="postage_stamp_ofs_pos">486</TD><TD PORT="postage_stamp_ofs_size">4</TD><TD>u4le</TD><TD PORT="postage_stamp_ofs_type">postage_stamp_ofs</TD></TR>
				<TR><TD PORT="scan_line_ofs_pos">490</TD><TD PORT="scan_line_ofs_size">4</TD><TD>u4le</TD><TD PORT="scan_line_ofs_type">scan_line_ofs</TD></TR>
				<TR><TD PORT="attributes_pos">494</TD><TD PORT="attributes_size">1</TD><TD>u1</TD><TD PORT="attributes_type">attributes</TD></TR>
			</TABLE>>];
		}
	}
	tga__seq:image_id_len_type -> tga__seq:image_id_size [color="#404040"];
	tga__seq:color_map_depth_type -> tga__seq:color_map_size [color="#404040"];
	tga__seq:num_color_map_type -> tga__seq:color_map__repeat [color="#404040"];
	tga__inst__footer:footer_type -> tga_footer__seq [style=bold];
	tga_footer__seq:version_magic_type -> tga_footer__inst__is_valid [color="#404040"];
	tga_footer__seq:ext_area_ofs_type -> tga_footer__inst__ext_area:ext_area_pos [color="#404040"];
	tga_footer__inst__ext_area:ext_area_type -> tga_ext_area__seq [style=bold];
}