The dds Module

Warning

This module is not yet ready and some changes should be expected.

Helper utilities for .dds-file processing.

See also

Wikipedia: DirectDraw Surface
Information and links.
MSDN: DDS
Reference material.

Functions

make4CC(int code) → str

Creates a 4CC string from an int.

get4CC(str code) → int

Creates a 4CC int from a string.

Classes

DDSFile

This class can load and manipulate a (very) limited set of .dds-files.

class dds.DDSFile
DDSFile(str path) → DDSFile

The constructor loads and verifies .dds headers.

getItemFormat() → str

Returns a format string describing one pixel. Compatible with the struct-module. Can return None if the format is not supported.

isVersion10() → bool

Returns True if the file has a DDS_HEADER_DXT10-header in it.

readSurface() → list

Reads the first surface into a list which in turn contains lists containing RGBA-objects.

f = DDSFile("myfile.dds")
data = f.readSurface()

#Process every pixel.
for row in data:
    for pixel in row:
        pixel.r = 0
        ...

#Change pixel (x=42, y=30) to red, full alpha.
data[42][30] = RGBA(255, 0, 0, 255)
#Set pixels (10, 15) alpha component to 0 (fully transparent).
data[10][15].a = 0

#Save the processed data into a new file.
f.save("myfile_out.dds", data)
save(str path, data, savealpha=False) → None
Parameters: