Page 1 of 1

Switching between images without Flicker (GDIP)

Posted: 14 Apr 2018, 12:37
by EvilLurker
I've had such a hard time figuring this out, so this might come in handy to someone out there;
Switching between images displayed on screen, without the annoying white flicker:
You can play around with the margin, pic size and BitBlt sizes to fit your needs.

Code: Select all

#include gdip.ahk
pToken := Gdip_Startup()
hbm := CreateDIBSection(w := 697, h := 550), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gui, 1: Add, Picture, w%w% h%h% +BackgroundTrans hwndpic
Gui, -ToolWindow -Caption -Border
Gui, 1: Show, AutoSize, Example
ddc := GetDC(pic)
Gdip_DrawImage(G, pBitmap := Gdip_CreateBitmapFromFile("gmenu1.png")) 
BitBlt(ddc, -7, -15, w, h, hdc, 0, 0)
Gdip_DisposeImage(pBitmap)
Sleep, 1000
Gdip_DrawImage(G, pBitmap := Gdip_CreateBitmapFromFile("gmenu2.png")) 
BitBlt(ddc, -7, -15, w, h, hdc, 0, 0)
Gdip_DisposeImage(pBitmap)
Sleep, 1000
ExitApp