Guest mutant Posted May 10, 2003 Posted May 10, 2003 Is it possible to have like 2 layers of graphics in GDI+? I have some image that stays in the background and i dont wish to have to draw it every time paint is fired because i can see the picture get flicker. Quote
*Gurus* divil Posted May 10, 2003 *Gurus* Posted May 10, 2003 If you use double-buffering when you draw your control it shouldn't flicker. There isn't a "two layer" thing as you described. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Guest mutant Posted May 11, 2003 Posted May 11, 2003 Thats weird, i can get the double buffering to work with shapes, but it doesnt with images :( . Could show me an example for images or point me to some source where I could maybe find a tutorial or some explanation? Couldnt find any. Quote
*Gurus* divil Posted May 11, 2003 *Gurus* Posted May 11, 2003 I've never had a problem using double-buffering when drawing images. Can you post a sample that illustrates the problem? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Guest mutant Posted May 12, 2003 Posted May 12, 2003 I found a sample on internet. Dim bmp As New Bitmap(30, 30) Dim g As Graphics = Graphics.FromImage(bmp) g.DrawImage(New Bitmap("image.jpg"), 0, 0) Dim x As Integer For x = 0 To 5 e.Graphics.DrawImage(bmp, x * 30, 0) Next Is this correct? Quote
*Gurus* divil Posted May 12, 2003 *Gurus* Posted May 12, 2003 That works fine for me - I take it you've enabled the DoubleBuffer and AllPaintingInWmPaint styles for the form/control? Remember you don't have to do anything yourself to get double buffering to work, once you've set those two styles .NET does the rest. As a side note, that code is nasty - it doesn't clean up any of the resources it uses. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Guest mutant Posted May 12, 2003 Posted May 12, 2003 Thats funny, no of the articales said that I only need to setstyle to double buffer and .NET will do the rest, they told me to draw images like i showed before. Oh well, at least now its working all right :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.