could confirm).
You can't set constant Alpha value in a PARGB without adjusting RGB values accordingly, I suppose.
Code: Select all
#NoEnv
#Warn
#SingleInstance, Force
SetWorkingDir, %A_ScriptDir%
If ! FileExist("T1.png")
UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=13665, T1.png
If ! FileExist("T2.png")
UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=13666, T2.png
Gui, New, -MinimizeBox, Opacity
Gui, Color, White
Gui, Margin, 20, 20
Gui, Add, Picture,xm, T1.png
Gui, Add, Text, xm y+0, Background
Gui, Add, Picture, xp+32 BackgroundTrans, T2.png
Gui, Add, Picture,xm, T1.png
Gui, Add, Text, xm y+0, Background
hBM := LoadPicture("T1.png", "GDI+")
SetTransparency(hBM, 127)
Gui, Add, Picture,xp+32 BackgroundTrans, HBITMAP:%hBM%
Gui, Show
SetTransparency(hBitmap, opacity) {
static DIB_RGB_COLORS := 0
VarSetCapacity(BITMAP, byteCount := 4*4 + A_PtrSize*2, 0)
DllCall("GetObject", "Ptr", hBitmap, "Int", byteCount, "Ptr", &BITMAP)
width := NumGet(BITMAP, 4, "UInt"), height := NumGet(BITMAP, 8, "UInt")
bpp := NumGet(BITMAP, 18, "UShort")
if (bpp != 32)
throw "Bits per pixel: " . bpp . ", must be 32"
if pBits := NumGet(BITMAP, 4*4 + A_PtrSize) {
Loop % width * height
NumPut(opacity, pBits + (A_Index - 1)*4 + 3, "UChar")
}
else {
VarSetCapacity(BITMAPINFO, size := 4*10, 0)
NumPut(size, BITMAPINFO)
NumPut(width, BITMAPINFO, 4), NumPut(-height, BITMAPINFO, 8)
NumPut(1, BITMAPINFO, 12), NumPut(bpp, BITMAPINFO, 14)
VarSetCapacity(Bits, width * 4 * height, 0)
hDC := DllCall("CreateCompatibleDC", "Ptr", 0, "Ptr")
hObj := DllCall("SelectObject", "Ptr", hDC, "Ptr", hBitmap)
DllCall("GetDIBits", "Ptr", hDC, "Ptr", hBitmap, "UInt", 0, "UInt", height, "Ptr", &Bits, "Ptr", &BITMAPINFO, "UInt", DIB_RGB_COLORS)
Loop % width * height
NumPut(opacity, &Bits + (A_Index - 1)*4 + 3, "UChar")
DllCall("SetDIBits", "Ptr", hDC, "Ptr", hBitmap, "UInt", 0, "UInt", height, "Ptr", &Bits, "Ptr", &BITMAPINFO, "UInt", DIB_RGB_COLORS)
DllCall("SelectObject", "Ptr", hDC, "Ptr", hObj)
DllCall("DeleteDC", "Ptr", hDC)
}
}
will do this if you pass a colormatrix in options.
I will try to implement this as a built-in feature. (Edit: Done)