Benutzer mit den meisten Antworten
paint/graphics on windows forms

Frage
-
Dear programmers,
I made an application that displays a background bitmap on a windows form. When I click on any position of the bitmap a circle appears.
This is the main code:
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim bild As New Bitmap("w:\test.bmp")
Dim feld As New Rectangle(0, 0, 800, 600)
e.Graphics.DrawImage(bild, feld, feld, GraphicsUnit.Pixel)
e.Graphics.DrawEllipse(Pens.Aqua, New Rectangle(x, y, 20, 20))
invalidate() is used to update the graphics on the form
However, I find it annoying that the bitmap flashes whenever the position of the circle is updated.
Obviously the bitmap is loaded every time I click the mouse.
Is there a way to avoid this flashing?
Thanks for your answers!
Yours,
Wolfgang Weirich- Verschoben Mathias Schiffer Montag, 30. März 2009 21:51 Die englischsprachigen Foren sind zu erreichen unter http://social.msdn.microsoft.com/Forums/en-us/categories
Antworten
-
Hallo Wolfgang,
Effizienter wird es, wenn Du einen BufferedGraphicsContext für die Bitmap verwendest:
http://msdn.microsoft.com/de-de/library/system.drawing.bufferedgraphics.aspx
Eine Alternative ist, die Bitmap der BackgroundImage Eigenschaft zuzuweisen
und nur die Ellipse im OnPaint zu zeichnen.
Gruß Elmar- Als Antwort markiert Mathias Schiffer Dienstag, 31. März 2009 10:58
Alle Antworten
-
Man spricht deutsh. Das englischsprachige Visual Basic-Forum findest Du hier:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads -
Hallo Wolfgang,
Effizienter wird es, wenn Du einen BufferedGraphicsContext für die Bitmap verwendest:
http://msdn.microsoft.com/de-de/library/system.drawing.bufferedgraphics.aspx
Eine Alternative ist, die Bitmap der BackgroundImage Eigenschaft zuzuweisen
und nur die Ellipse im OnPaint zu zeichnen.
Gruß Elmar- Als Antwort markiert Mathias Schiffer Dienstag, 31. März 2009 10:58
-
Hallo Wolfgang,
Vesruch mal den bitmap background der Form mitForm.Picture=LoadPicture(Pfad des bitmaps) laden und nacher den Zirkel zeichnen.
Mfg,
Robert
- Als Antwort vorgeschlagen Robert BreitenhoferModerator Dienstag, 26. Mai 2009 15:17