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

Re: Switching between images without Flicker (GDIP)

Posted: 11 Dec 2020, 11:55
by keylo
yes but the image is surrounded by a black square? any way to fix that?

Re: Switching between images without Flicker (GDIP)

Posted: 16 Dec 2020, 10:03
by noname
You can take a look here: https://www.autohotkey.com/boards/viewtopic.php?t=77668
No need for using gdip and bitbild if you just want changing images without flickering.