TheGuardians / TagTool

GNU General Public License v3.0
64 stars 30 forks source link

Bitmap Decoding #21

Open Gravemind2401 opened 4 years ago

Gravemind2401 commented 4 years ago

I noticed some of the bitmap decoding for this is using super old Adjutant code (even including my comment at the top) and it has some todo comments to do some refactoring. I have since rewritten all of the decode functions and added more in my System.Drawing.Dds repo. If it may be of any use to you, check the DdsConvert.cs file for better structured decode methods (I believe the old ones are endian-swapped compared to these).

Beatthezombie commented 4 years ago

We also did some major refactors to this a few months ago. The main problem we had was that most bitmaps are tiled and have packed mipmap tails. The Xbox 360 xdk documentation was quite helpful. Indeed I had to endianswapp all the decoding functions, but most of the conversion code X360 -> PC doesn't require decode anymore. I suggest looking at the Bitmaps folder (BitmapConverter and XboxGraphics) and Direct3D/Xbox360 folder. We tested all bitmaps from Halo3/ODST and as far as I know, we can convert all of them flawlessly (except a few edge cases where mipmaps are not available). Halo Reach should use the exact same system but we haven't tested it thoroughly.

I added a CTX1-> DXN internal converter, feel free to use that in Adjutant. I also suggest to look at the dev branch of TagTool to get the latest information, the master branch is rarely updated because most features are still in dev. If you are ever interested in contributing to TagTool we are always looking for more contributors.

Gravemind2401 commented 4 years ago

I've had a look through the dev repo and it looks like all the areas I know about have already been covered pretty thoroughly, nice work! Other than that, one area I may be able to contribute is a UI, see the releases in my Reclaimer repo (see below) for an example of UI I could do. I've added you to my most recent repos which are a lot more up to date and far better structured than the old Adjutant code, you can have a look and see if anything there is useful to you. Regarding the bitmaps, as far as I can tell it looks like you only use the decode to convert from Xbox specific to DXGI then everything is saved as DDS. The DDS code I mentioned before may be useful if you want to support saving as PNG/TIFF as it has a number of methods to decompress BC1 to BC7 formats and a couple others.