Page 1 of 1

GdipCreateBitmapFromDirectDrawSurface or other ways to handle DDS

Posted: 26 Jun 2019, 17:32
by Aurelain
I built a tool that extracts the assets from "Heroes of Might & Magic III - HD Edition":
https://github.com/Aurelain/H3Lens/blob/master/unpack/unpak.ahk

It works fine, but I'd like to optimize its handling of DDS textures and I need your advice. Here's the current workflow:

1. PAK file
--> RawRead -->
2. ZIP buffer
--> DllCall zlib -->
3. DDS buffer
--> RawWrite -->
4. DDS file
--> imagick cmd -->
5. BMP file
--> Gdip -->
6. BMP buffer
--> Gdip draw -->
7. GUI

What I would like to do is get rid of steps 4 and 5. For this, I thought of 4 different ways:
  1. Use gdiplus\GdipCreateBitmapFromDirectDrawSurface. This would be the absolute best option. However, I couldn't find a way to make it work, and the documentation is sparse. I don't even know if it's supposed to take DDS buffers as input...
  2. Use a third-party dll for bitmap conversion. Perhaps one of these would get the job done: mwgfx.dll, CORE_RL_MagickCore_.dll or something from nvidia perhaps.
  3. Use a browser (electron) in order to access its DDS renderer with compressedTexImage2D. I'm affraid this might get very bloaty.
  4. Write my own DDS parser. Not gonna happen.
TL;DR: Has anyone ever used GdipCreateBitmapFromDirectDrawSurface?