Hi Robert,

It's been a while, eh?

Well, here are submissions about handling of S3TC-DXTC (.dds) images. All 
changes are related, but they come in multiple commits.
If I could easily base my work on a specific revision for "Image.cpp" (few 
changes), the recent changes in "ReaderWriterDDS.cpp" are based on my previous 
submissions. To avoid the pain of searching old submissions in the mailing 
list, I re-organized everything here. This is why you'll find 3 (numbered) 
versions of the RW, to separate changes in multiple commits. Just focus on this 
submission and forget my previous ones about DDS! :)

Base revision is master b5fa42c203 / trunk r13348.

Attached are the modified source files, a simple test program (which creates 
test images, or read+rewrites images through DDS ReaderWriter), and DDS files 
used & produced during this test.

1. Image.cpp
Failure to perform a vertical flip on S3TC-DXTC now simply leaves the original 
image instead of corrupting it.
Image.cpp was sometimes performing a "normal" (= for uncompressed images) 
vertical flip on S3TC-DXTC images, producing weird results.
Actually, code was trying a "DXTC vertical flip" and relied on the result to 
call a "normal vertical flip". But when the "DXTC v-flip" encounters an error, 
this is is not necessarily because the image is not S3TC (ex: unhandled image 
dimensions)!
So now the code simply does "if dxtc, then flip_dxtc; else flip_normal;".
 
2. ReaderWriterDDS-1.cpp
Added some support of non-modulus-4 dimensions in S3TC-DXTC images (previous 
implementation seem just not to handle these properly).
- Added missing packing value on S3TC images. Images are coded with 4x4 blocs, 
whatever the image size. So there is an horizontal packing of 4 pixels (2 bytes 
in DXT1, 4 bytes in DXT2-5).
- Added crash guard against writing corrupted S3TC images.
Notes:
- What is missing is a support of "lines packing" in osg::Image (see code 
comments).
- S3TC-DXTC vertical flipping crashes (access violation) with some unusual 
dimensions (see code). I could not implement missing cases, so I added guards 
to avoid crashing.

3. ReaderWriterDDS-2.cpp
Added vertical flipping to the writer depending on the Image::getOrigin() value 
(= flip the image when Image::BOTTOM_LEFT). Most of the time this will not 
change DDS writing (= no v-flip), as it seems images are rarely "BOTTOM_LEFT". 
To skip this behaviour, the "ddsNoAutoFlipWrite" option was added.
I also moved a few lines of code about "dds_flip" option, and made options 
reading more like in other ReaderWriters.

4. ReaderWriterDDS-3.cpp
Added ".dds" file deletion on writing failure.


Cheers,

Sukender

Attachment: DDSTest.7z
Description: application/7z-compressed

Attachment: DDSTest source images and results.7z
Description: application/7z-compressed

Attachment: DDS - Improved handling of S3TC-DXTC.7z
Description: application/7z-compressed

_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to