Switching between images without Flicker (GDIP)

Put simple Tips and Tricks that are not entire Tutorials in this forum
EvilLurker
Posts: 8
Joined: 26 Mar 2018, 00:25

Switching between images without Flicker (GDIP)

14 Apr 2018, 12:37

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

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest