Bases: pyffi.object_models.xml.FileFormat
This class implements the DDS format.
Bases: pyffi.object_models.Data
A class to contain the actual dds data.
Quickly checks if stream contains DDS data, and reads the header.
Parameters: | stream (file) – The stream to inspect. |
---|
Quickly checks if stream contains DDS data, and gets the version, by looking at the first 8 bytes.
Parameters: | stream (file) – The stream to inspect. |
---|
Read a dds file.
Parameters: |
|
---|
Write a dds file.
Parameters: |
|
---|
Bases: pyffi.object_models.xml.enum.EnumBase
An unsigned 32-bit integer, describing the compression type.
Bases: pyffi.object_models.xml.basic.BasicBase
Basic type which implements the header of a DDS file.
Return a hash value for this value.
Returns: | An immutable object that can be used as a hash. |
---|
Return number of bytes the header string occupies in a file.
Returns: | Number of bytes. |
---|
Read header string from stream and check it.
Parameters: | stream (file) – The stream to read from. |
---|
Write the header string to stream.
Parameters: | stream (file) – The stream to write to. |
---|
alias of UndecodedData
alias of Byte
alias of Char
alias of Float
alias of Int
alias of Short
alias of UByte
alias of UInt
alias of UShort
Converts version string into an integer.
Parameters: | version_str (str) – The version string. |
---|---|
Returns: | A version integer. |
>>> hex(DdsFormat.version_number('DX10'))
'0xa000000'
>>> # check and read dds file
>>> stream = open('tests/dds/test.dds', 'rb')
>>> data = DdsFormat.Data()
>>> data.inspect(stream)
>>> data.header.pixel_format.size
32
>>> data.header.height
20
>>> data.read(stream)
>>> len(data.pixeldata.get_value())
888
>>> for stream, data in DdsFormat.walkData('tests/dds'):
... print(stream.name)
tests/dds/test.dds
>>> data = DdsFormat.Data()
>>> from tempfile import TemporaryFile
>>> stream = TemporaryFile()
>>> data.write(stream)
>>> for vnum in sorted(DdsFormat.versions.values()):
... print('0x%08X' % vnum)
0x09000000
0x0A000000