Jump to content
  • Advertisement
Sign in to follow this  

Need help with GDI+ animation flickering issue

This topic is 4723 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm animating a series of images with GDI+. I get flickering and I"m not sure how to fix it. I've tried a variety of things but desparetly need a better idea. Is there an easy way to double buffer in GDI+? I can draw with no flicker using Image i(tmp); Graphics g2(hdcScreen); g2.DrawImage&i,0,0,rctVisFrame.left,rctVisFrame.top ,FrameWidth ,FrameHeight,UnitPixel ); g2.ReleaseHDC(hdcScreen); However, the image smears because of a lack of updates. I then tried using RECT visRect = {0,0,FrameWidth ,FrameHeight}; RedrawWindow(hWnd_window,&visRect,NULL,RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); This preventing smearing but resulted in flickering. I then tried doing a screen capture, drawing ontop of that, and then presenting that to the screen. It doesn't flick but it does smear if the animation remains in a single location.

Share this post


Link to post
Share on other sites
Advertisement
I think what I really need is a way to Redraw the window offscreen, then draw ontop of that, and then present that to the screen. Anyone know how to redraw the window offscreen?

Share this post


Link to post
Share on other sites
I've used this method before:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngdi/html/msdn_flicker.asp

Not sure about speed though...

Share this post


Link to post
Share on other sites
double buffering :

1 ) create a compatible dc ( memDC )
2 ) create a bitmap compatible with the current dc
3 ) select the bitmap in the previously created dc ( memDC )
4 ) draw onto that dc ( memDC )
5 ) when finished drawing just bitblt memDC on the actual dc of the control.

ah yes, you'll want to do that in the control's OnPaint() method.
whenever you need to redraw things ( data model changes ) just call a RedrawWindow()

Share this post


Link to post
Share on other sites
ok, I'll try both methods over the next few days and see how it goes. Part of the problem is that I don't have access to the window's OnPaint function. I'm drawing in a window that is not my program window. It is a different window so I must do everything with the HDC of that window (as far as I can tell).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!