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.
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.
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
That works fine for me - I take it youve enabled the DoubleBuffer and AllPaintingInWmPaint styles for the form/control? Remember you dont have to do anything yourself to get double buffering to work, once youve set those two styles .NET does the rest.
As a side note, that code is nasty - it doesnt clean up any of the resources it uses.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.