How to Gdip_CreateBitmapFromFile without it keeping the file in use?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Stealthle
Posts: 32
Joined: 13 Mar 2017, 00:48

How to Gdip_CreateBitmapFromFile without it keeping the file in use?

Post by Stealthle » 01 Apr 2023, 03:59

I'm trying to load a bitmap to an editor I made with AHK but I can't save it after editing because it seems the file is still in use from Gdip_CreateBitmapFromFile and I can't use Gdip_DisposeImage yet because I can't save it yet.

I was copying the file first and then using Gdip_CreateBitmapFromFile on it instead but I feel like its too "unprofessional" and would like to keep it in memory.


Any help is greatly appreciated!

Stealthle
Posts: 32
Joined: 13 Mar 2017, 00:48

Re: How to Gdip_CreateBitmapFromFile without it keeping the file in use?

Post by Stealthle » 01 Apr 2023, 04:58

Well I found a work around to turn it into an Hbitmap and then back to a bitmap and now the original file isn't in use although i'm not quite sure why it works or if it will cause an issue I haven't seen yet.

Code: Select all

pBitmaptemp := Gdip_CreateBitmapFromFileSimplified(filespecial) 
hBitmaptemp:= Gdip_CreateargbHBITMAPFromBitmap(pBitmaptemp)
pBitmap:= Gdip_CreateargbBITMAPFromhBitmap(hBitmaptemp)
Gdip_DisposeImage(pBitmaptemp)
DeleteObject(hBitmaptemp)
[Mod edit: [code][/code] tags added.]

Post Reply

Return to “Ask for Help (v1)”