Truevision TGA
TGA (Targa) is a raster image format created by Truevision in 1984, supporting up to 32-bit color with an 8-bit alpha channel. It remains widely used in game development, 3D rendering, and video post-production for its simplicity and lossless alpha transparency.
Truevision TGA lacks browser codec support and modern WASM image libraries prioritize web-native formats.
تبحث عن تحويل؟ جرّب صيغة ذات صلة:
أسئلة شائعة
How do I open and inspect a TGA file?
Use IrfanView or XnView for quick viewing on Windows. On Linux/macOS, GIMP opens TGA files natively. For CLI inspection without rendering, use exiftool -ImageWidth -ImageHeight -BitsPerPixel input.tga to read header fields.
Why does my TGA image appear upside down?
TGA supports both bottom-up (default, legacy) and top-down scan order, controlled by bit 5 of the image descriptor byte at offset 0x11. Some viewers ignore this flag. Re-save the file with the correct orientation in GIMP or ImageMagick: magick input.tga -flip output.tga.
Should I use TGA or PNG for game textures?
Use PNG for new projects. PNG offers lossless compression (30-60% smaller files), identical quality, full alpha support, and universal tool compatibility. TGA remains in use primarily for legacy pipelines and some texture tools that expect uncompressed pixel data.
Why does TGA have no magic bytes?
TGA was designed in 1984 before file signatures became standard practice. The 18-byte header starts directly with data fields (ID length, color map type, image type). TGA v2.0 (1991) added the optional TRUEVISION-XFILE footer at the end of the file, but it is not mandatory.
ما يميز .TGA
What is a TGA file?
TGA (Targa) is a raster graphics format created by Truevision in 1984. It supports up to 32-bit color with an 8-bit alpha channel for transparency. TGA became a standard in the video game and video editing industries due to its simplicity, alpha support, and minimal compression overhead.
اكتشف التفاصيل التقنية
How to open TGA files
- Adobe Photoshop (Windows, macOS) — Full support
- GIMP (Windows, macOS, Linux) — Free, full support
- IrfanView (Windows) — Lightweight viewer
- XnView (Windows, macOS, Linux) — Free viewer
Technical specifications
| Property | Value |
|---|---|
| Color Depth | 8, 16, 24, 32 bit |
| Alpha Channel | 8-bit (in 32-bit mode) |
| Compression | None or RLE |
| Max Resolution | 65,535 x 65,535 px |
| Orientation | Bottom-up or top-down |
Common use cases
- Game development: Texture files for 3D models and sprites.
- Video editing: Frame sequences with alpha channels.
- 3D rendering: Texture maps for 3D applications.
- Legacy workflows: Older animation and VFX pipelines.
المرجع التقني
- نوع MIME
image/x-tga- المطوّر
- Truevision (now Avid)
- سنة التقديم
- 1984
- معيار مفتوح
- نعم
البنية الثنائية
TGA files have an 18-byte fixed header with no mandatory magic bytes at offset 0 — identification relies on header field validation. Byte 0 is the ID length (0-255 bytes of optional image identification following the header). Byte 1 is the color map type: 0 = no palette, 1 = palette present. Byte 2 is the image type: 0 = no data, 1 = uncompressed color-mapped, 2 = uncompressed true-color, 3 = uncompressed grayscale, 9 = RLE color-mapped, 10 = RLE true-color, 11 = RLE grayscale. Bytes 3-7 are the color map specification: 2-byte first entry index, 2-byte color map length, 1-byte bits per entry (15, 16, 24, or 32). Bytes 8-9 are the X origin, bytes 10-11 are the Y origin (both 16-bit little-endian). Bytes 12-13 are the image width, bytes 14-15 are the image height (both 16-bit LE, max 65535). Byte 16 is the pixel depth (8, 16, 24, or 32 bits). Byte 17 is the image descriptor: bits 0-3 specify the number of alpha/attribute bits, bit 4 is the left-to-right flag, and bit 5 is the top-to-bottom flag (0 = bottom-up, the default and legacy convention; 1 = top-down). Pixel data follows in BGRA order (not RGBA). For RLE types, each run begins with a packet header byte: bit 7 set = run-length packet (repeat next pixel N+1 times), bit 7 clear = raw packet (N+1 literal pixels follow). TGA v2.0 adds an optional footer at the last 26 bytes: 4-byte extension area offset, 4-byte developer directory offset, and the 18-byte signature 'TRUEVISION-XFILE.\0'. The extension area (if present) contains author, comments, date, job time, software ID, gamma, and color correction data.
| Offset | Length | Field | Example | Description |
|---|---|---|---|---|
0x00 | 1 byte | ID length | 00 | Length of the optional image identification field (0 = no ID). This field immediately follows the 18-byte header. |
0x01 | 1 byte | Color map type | 00 | 0 = no color map (true-color/grayscale), 1 = color map present (paletted image). |
0x02 | 1 byte | Image type | 02 | 2 = uncompressed true-color, 10 = RLE true-color, 3 = grayscale, 9 = RLE color-mapped. |
0x03 | 5 bytes | Color map specification | 00 00 00 00 00 | First entry index (2B), length (2B), bits per entry (1B). All zeros when no palette. |
0x08 | 4 bytes | X/Y origin | 00 00 00 00 | Image origin coordinates (little-endian). Usually (0,0). Y origin meaning depends on scan direction. |
0x0C | 4 bytes | Width / Height | 00 04 00 03 | Image dimensions in pixels (16-bit LE each). Example: 1024 x 768. |
0x10 | 1 byte | Pixel depth | 20 | Bits per pixel: 0x08=8-bit, 0x10=16-bit, 0x18=24-bit, 0x20=32-bit (with alpha). |
0x11 | 1 byte | Image descriptor | 28 | Bits 0-3: alpha bits (8 for 32bpp). Bit 4: L-R order. Bit 5: top-down (1) or bottom-up (0). |
نقاط الضعف
- Malformed header fields (pixel depth, dimensions) can trigger integer overflows in decoders that allocate width * height * bpp bytes without validation
- RLE packet length exceeding image bounds causes buffer overreads in parsers without bounds checking
الحماية: FileDex does not open, execute, or parse TGA files. Reference page only.