Create an HBitmap with transparency
Posted: 12 May 2020, 10:47
Hello, I'm trying to create a simple HBitmap (to be used in a Picture control) that only has a background with transparency. The idea is to use it to overlay some controls I have that are going to be disabled.
I tried the following code:
But I read that Gdip_CreateHBITMAPFromBitmap ignores the alpha channel.
So I found about DIB section, but the problem is that when I create it I can't specify what background I want, and I don't know how to change the pixels on it because Gdip_GetPixel works only with pBitmap and DIB sections are hBitmap.
So to make it short:
I need a simple hBitmap that only holds a semi-transparent color and it will go on top of other controls.
Gdip_CreateHBITMAPFromBitmap doesn't support transparency and the methods I found on this forum are only for images from files.
Any ideas? I want to avoid using another gui, changing the transparency of the entire gui and/or using an image from a file.
I tried the following code:
Code: Select all
pBitmap := Gdip_CreateBitmap(400, 400)
hBackground := Gdip_CreateHBITMAPFromBitmap(pBitmap, 0xff000000)
hOverlay := Gdip_CreateHBITMAPFromBitmap(pBitmap, 0x00F000FF)
gui, add, picture, x0 y0 Altsubmit, HBITMAP:%hBackground%
gui, add, picture, x0 y0 Altsubmit BackgroundTrans, HBITMAP:%hOverlay%
gui, show
return
So I found about DIB section, but the problem is that when I create it I can't specify what background I want, and I don't know how to change the pixels on it because Gdip_GetPixel works only with pBitmap and DIB sections are hBitmap.
So to make it short:
I need a simple hBitmap that only holds a semi-transparent color and it will go on top of other controls.
Gdip_CreateHBITMAPFromBitmap doesn't support transparency and the methods I found on this forum are only for images from files.
Any ideas? I want to avoid using another gui, changing the transparency of the entire gui and/or using an image from a file.