GdipCreateBitmapFromDirectDrawSurface or other ways to handle DDS

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Aurelain
Posts: 34
Joined: 02 Sep 2014, 15:37

GdipCreateBitmapFromDirectDrawSurface or other ways to handle DDS

Post by Aurelain » 26 Jun 2019, 17:32

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?

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: GdipCreateBitmapFromDirectDrawSurface or other ways to handle DDS

Post by swagfag » 24 Sep 2021, 18:35

https://www.google.com/search?q=autohotkey+GdipCreateBitmapFromDirectDrawSurface
image.png
image.png (2.57 KiB) Viewed 231 times
no, u can be the first one to do so

DllCall DirectDrawCreateEx to get an IDirectDraw7
ComCall IDirectDraw7::CreateSurface to get an IDirectDrawSurface7
ComCall IDirectDrawSurface7::Lock to get a pointer to its bytes
memcpy some raw bytes u have laying around into it, RtlMoveMemory or somesuch
ComCall IDirectDrawSurface7::Unlock
pass the previously obtained IDirectDrawSurface7 ptr to GDI+ or whatever

Post Reply

Return to “Ask for Help (v1)”