Warning
This module is not yet ready and some changes should be expected.
Helper utilities for .dds-file processing.
See also
Creates a 4CC string from an int.
Creates a 4CC int from a string.
This class can load and manipulate a (very) limited set of .dds-files.
The constructor loads and verifies .dds headers.
Returns a format string describing one pixel. Compatible with the struct-module. Can return None if the format is not supported.
Returns True if the file has a DDS_HEADER_DXT10-header in it.
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)
Parameters: |
|
---|
Saves data into a file in RGBA8 format. DDS_HEADER_DXT10-header is not written.
Returns textures dimensions.
Attributes
The DDS_HEADER-header structure.
The DDS_PIXELFORMAT-header structure.
The DDS_HEADER_DXT10-header structure. This can be None if the file does not have this header.
f = DDSFile("image.dds")
print("Width of the image: %i" % f.HEADER.dwWidth)
A very simple color class. Values can be intergers or floats.
Creates a new instance.
Indexing support.
rgba = RGBA(...)
assert(rgba[0] == rgba.r)
assert(rgba[1] == rgba.g)
#etc.
Attributes
The red component.
The green component.
The blue component.
The alpha component.