Graphics \ Textures

DDS file format

//ENGLISH
//size of the header is 128 bytes
DWORD magic \\ 'DDS ’
DWORD size \\ size of the header without magic
DWORD flags
DWORD height in pixels
DWORD width in pixels
DWORD Pitch \\ we can calculate it from special equasion (below)
DWORD Depth \\ can be unused
DWORD Number of mipmaps
DWORD*11 \\ reserved 44 bytes (4*11)

// Pixel format
DWORD size of the structure \\ always 32 bytes
DWORD flags
DWORD FourCC \\ compression method (DXT1, DXT3, … or unused)
DWORD RGBBitCount \\ number of bits per pixel (in RGB 24)
DWORD RBitMask
DWORD GBitMask
DWORD BBitMask
DWORD ABitMask

// flags sector
DWORD Caps // flags
DWORD Caps2 // flags2
DWORD Caps3 // unused
DWORD Caps4 // unused
DWORD Reserved2 // unused

// Pitch calculating
For block-compressed formats, compute the pitch as:
max( 1, ((width+3)/4) ) * block-size
The block-size is 8 bytes for DXT1, BC1 and BC4 formats
but 16 bytes for other block-compressed formats.

For R8G8_B8G8, G8R8_G8B8, legacy UYVY-packed, and legacy YUY2-packed formats, compute the pitch as:
((width+1) >> 1) * 4

For other formats, compute the pitch as:
( width * bits-per-pixel + 7 ) / 8

// Flags1
0x1 + 0x2 + 0x4 + 0x8 + 0x1000 = 4111 = 0F100000

// Flags2
0x40 – uncompressed rgb

https://msdn.microsoft.com/en-us/library/windows/desktop/bb943982(v=vs.85).aspx
https://fossies.org/linux/wine/dlls/ddraw/utils.c
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

// POLISH
#rozmiar całego nagłówka 128 bajtów
DWORD magic \\ 'DDS ’
DWORD rozmiar \\ rozmiar nagłówka bez magic
DWORD flagi
DWORD wysokość w pikselach
DWORD szerokość w pikselach
DWORD Pitch \\ obliczany ze specjalnego wzoru
DWORD Głębia \\ może być nieużywane
DWORD Liczba mipmap
DWORD*11 Zarezerwowane 44 bajty (4*11)

// Format pikseli
DWORD rozmiar struktury \\ zawsze 32 bajty
DWORD flagi
DWORD FourCC \\ rodzaj kompresji (DXT1, DXT3, … lub nieużywane)
DWORD RGBBitCount \\ ilość bitów na piksel (w RGB 24)
DWORD RBitMask
DWORD GBitMask
DWORD BBitMask
DWORD ABitMask

// końcówka z flagami
DWORD Caps // flagi
DWORD Caps2 // flagi2
DWORD Caps3 // nieużywane
DWORD Caps4 // nieużywane
DWORD Reserved2 // nieużywane

// Obliczanie pitcha
For block-compressed formats, compute the pitch as:
max( 1, ((width+3)/4) ) * block-size
The block-size is 8 bytes for DXT1, BC1 and BC4 formats
but 16 bytes for other block-compressed formats.

For R8G8_B8G8, G8R8_G8B8, legacy UYVY-packed, and legacy YUY2-packed formats, compute the pitch as:
((width+1) >> 1) * 4

For other formats, compute the pitch as:
( width * bits-per-pixel + 7 ) / 8

// Flagi1
0x1 + 0x2 + 0x4 + 0x8 + 0x1000 = 4111 = 0F100000

// Flagi2
0x40 – nieskompresowane rgb

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *

five × = fifteen