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)

Post by EvilLurker » 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

keylo
Posts: 51
Joined: 21 Oct 2020, 21:03

Re: Switching between images without Flicker (GDIP)

Post by keylo » 11 Dec 2020, 11:55

yes but the image is surrounded by a black square? any way to fix that?

User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: Switching between images without Flicker (GDIP)

Post by noname » 16 Dec 2020, 10:03

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.

Post Reply

Return to “Tips and Tricks (v1)”