.dds BC5 compression python image library support help

190 views
Skip to first unread message

Benjam901

unread,
May 20, 2015, 2:44:45 PM5/20/15
to python_in...@googlegroups.com
Hello all,

I am having a few troubles trying to load up a whole bunch of .dds files into python to check their size before downscale.

I am batch downsizing them to test memory, normally using DXT5 compression wouldn't be a huge issue because various python image libraries can load them like Pyglet (which I am trying to use)

However the issue I am having is that we are using the newer BC5 compression and it is rather new (so new in fact Maya won't load the images) and neither will the image library pyglet. This would indicate to me that there is little support for the image formats yet.

I have tried to install PyFFI to test but it requires python 3.0 and devIL does not seem to have any solid documentation on how to use it.

Has anyone worked with this image compression before and if so which library did you use to load the images?

Cheers,

Ben

damon shelton

unread,
May 20, 2015, 2:47:23 PM5/20/15
to python_in...@googlegroups.com
can you provide a test dds with that compression. might be able to parse the data yourself form the binary directly


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3a4148c0-3458-42c7-9023-608d87830b9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benjam901

unread,
May 20, 2015, 3:01:38 PM5/20/15
to python_in...@googlegroups.com
Yeah of course, see attached. I was thinking decoding it manually also, some help on it would be much appreciated! 

The image attached is encoded in the correct image format BC5(DX10)


On Wednesday, 20 May 2015 11:47:23 UTC-7, damonshelton wrote:
can you provide a test dds with that compression. might be able to parse the data yourself form the binary directly

On Wed, May 20, 2015 at 11:44 AM, Benjam901 <benandr...@gmail.com> wrote:
Hello all,

I am having a few troubles trying to load up a whole bunch of .dds files into python to check their size before downscale.

I am batch downsizing them to test memory, normally using DXT5 compression wouldn't be a huge issue because various python image libraries can load them like Pyglet (which I am trying to use)

However the issue I am having is that we are using the newer BC5 compression and it is rather new (so new in fact Maya won't load the images) and neither will the image library pyglet. This would indicate to me that there is little support for the image formats yet.

I have tried to install PyFFI to test but it requires python 3.0 and devIL does not seem to have any solid documentation on how to use it.

Has anyone worked with this image compression before and if so which library did you use to load the images?

Cheers,

Ben

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
asphalt_cracks.DDS

Benjam901

unread,
May 20, 2015, 3:18:18 PM5/20/15
to python_in...@googlegroups.com
Scratch that, the converter popped out a DXT5. Fixing that now

Benjam901

unread,
May 20, 2015, 3:24:16 PM5/20/15
to python_in...@googlegroups.com
OK so here is an image I just converted that has BC5u compression and cannot be read by my image library. Thank you for the help! :)
asphalt_cracks_n.DDS

Benjam901

unread,
May 20, 2015, 8:32:32 PM5/20/15
to python_in...@googlegroups.com
Hey guys,

I got there in the end. 

ddsFile = open(filePath, 'rb')
ddsFile.read(4) # Read the magic
ddsFile.read(8) # Skip 8 bytes in
height = struct.unpack('i', ddsFile.read(4))[0]
width = struct.unpack('i', ddsFile.read(4))[0]

Could anyone explain to me why we have to skip 4 bytes in and then 8 bytes also. I understand there are various magic numbers in headers but thats about it, being able to understand what is going on properly for future reference would be brilliant!!

Anthony Tan

unread,
May 20, 2015, 8:58:29 PM5/20/15
to python_in...@googlegroups.com
By skipping 12 bytes in, what you're doing is seeking straight to the header where the file format spec states the height and width reside - essentially, the file format spec says say so.
 
The specific bits you're implementing:
- A DDS file begins with a DWORD sized magic number (you want to look for the magic 0x20534444) and then a header block.
- Within the header block itself, there are two DWORDs you're then skipping past which are the elements dwSize (always set to 124), and dwFlags (describes what elements exist)
 
 
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages