473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Painting on PictureBox

Hello.

I want to paint some geometric shapes on the graphic context from a picture
box. This picture box has dock style set to fill and is filling out the
whole form. The form is maximized. This is working very good and fast but
the problem is, that I want to have some kind of background image.

Doing so the performance is going down extremly. Even though I am using
double buffering, invalidating only the regions nessecary and using all the
other performance tricks I know...

So can someone tell me how it is possible in .NET to paint on a picture
(fullscreen) with GDI(+) and be fast enough that shapes being dragged around
are not running behind the mouse.

Thanks really a lot for any tips and tricks!
Greetings,
Tim.
Nov 16 '05 #1
4 3561
Shapes being dragged. I would recommend rendering a *drag box* or reversible
box using ControlPaint, and then only moving the graphic element when the user
is done. This eliminates your redraw while your control is *in motion*.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Tim Bücker" <ti************@web.de> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
Hello.

I want to paint some geometric shapes on the graphic context from a picture
box. This picture box has dock style set to fill and is filling out the
whole form. The form is maximized. This is working very good and fast but
the problem is, that I want to have some kind of background image.

Doing so the performance is going down extremly. Even though I am using
double buffering, invalidating only the regions nessecary and using all the
other performance tricks I know...

So can someone tell me how it is possible in .NET to paint on a picture
(fullscreen) with GDI(+) and be fast enough that shapes being dragged around
are not running behind the mouse.

Thanks really a lot for any tips and tricks!
Greetings,
Tim.

Nov 16 '05 #2
"Justin Rogers" <Ju****@games4dotnet.com> schrieb im Newsbeitrag
news:ec**************@TK2MSFTNGP12.phx.gbl...
Shapes being dragged. I would recommend rendering a *drag box* or reversible box using ControlPaint, and then only moving the graphic element when the user is done. This eliminates your redraw while your control is *in motion*.

First, thanks for answering!
But unfortunately I am already moving just rectangles and no complex shapes.

It seems (due to the lack of performance) as although I give invalidate a
rectangle, the whole background picture is redrawn...
That seems to be the problem somehow... But to be frank I have no idea.

Greetings and thanks again,
Tim.

"Tim Bücker" <ti************@web.de> wrote in message...
Hello.

I want to paint some geometric shapes on the graphic context from a picture box. This picture box has dock style set to fill and is filling out the
whole form. The form is maximized. This is working very good and fast but the problem is, that I want to have some kind of background image.

Doing so the performance is going down extremly. Even though I am using
double buffering, invalidating only the regions nessecary and using all the other performance tricks I know...

So can someone tell me how it is possible in .NET to paint on a picture
(fullscreen) with GDI(+) and be fast enough that shapes being dragged around are not running behind the mouse.

Thanks really a lot for any tips and tricks!
Greetings,
Tim.

Nov 16 '05 #3
DrawReversible* doesn't require that you invalidate and repaint the background,
instead
you delay the invalidate until the user has selected a location where they want
to move the
object. Only then do you invalidate the source location *repaint the
background* and
the target location *repaint the object in question.

What you have to realize is that you can repaint controls only a few times a
second, not
the hundreds of times that can be introduced by using real-time mouse-movements.
You
have to throttle the process of updating the screen to prevent poor performance.
Since
reversible lines don't require that you fill or repaint, you can draw a
reversible rectangle in
one spot, then simply redraw it again in the same spot and it disappears. You
can do this
thousands of times per second until the user has completed their drag operation.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Tim Bücker" <ti************@web.de> wrote in message
news:uz**************@TK2MSFTNGP09.phx.gbl...
"Justin Rogers" <Ju****@games4dotnet.com> schrieb im Newsbeitrag
news:ec**************@TK2MSFTNGP12.phx.gbl...
Shapes being dragged. I would recommend rendering a *drag box* or

reversible
box using ControlPaint, and then only moving the graphic element when the

user
is done. This eliminates your redraw while your control is *in motion*.


First, thanks for answering!
But unfortunately I am already moving just rectangles and no complex shapes.

It seems (due to the lack of performance) as although I give invalidate a
rectangle, the whole background picture is redrawn...
That seems to be the problem somehow... But to be frank I have no idea.

Greetings and thanks again,
Tim.

"Tim Bücker" <ti************@web.de> wrote in message...
Hello.

I want to paint some geometric shapes on the graphic context from a picture box. This picture box has dock style set to fill and is filling out the
whole form. The form is maximized. This is working very good and fast but the problem is, that I want to have some kind of background image.

Doing so the performance is going down extremly. Even though I am using
double buffering, invalidating only the regions nessecary and using all the other performance tricks I know...

So can someone tell me how it is possible in .NET to paint on a picture
(fullscreen) with GDI(+) and be fast enough that shapes being dragged around are not running behind the mouse.

Thanks really a lot for any tips and tricks!
Greetings,
Tim.


Nov 16 '05 #4
"Justin Rogers" <Ju****@games4dotnet.com>
DrawReversible* doesn't require that you invalidate and repaint the background, instead
you delay the invalidate until the user has selected a location where they want to move the
object. Only then do you invalidate the source location *repaint the
background* and
the target location *repaint the object in question.


@Justin Rogers:

Thanks - Thanks - Thanks.
You´ve saved my day!

Just wrote a little test program - it is working greatly and with enormous
performance!!!
Greetings,
Tim.

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alien | last post by:
I have a hex editor-type class that extends UserControl and paints its data to a PictureBox. Basically the problem is that repainting it takes usually between 60 and 80ms, which may seem pretty...
0
by: Peter van der Veen | last post by:
Hi I've an picturebox and fill this with a brush with a color say color.skyblue On a screen with 265 colors (like terminal servers clients have) this is owfull. However, when i set the...
0
by: akh | last post by:
I want to use de Drag and Drop ´s event to move a picture box from a form and within a Picture Box. But I have behaviour if the MyPBox As PictureBox as the Globale varible or not Thanks for...
8
by: Stefan Richter | last post by:
I want to paint some bars, as soon as a button get klicked. My Paint Method has this signature: Private Sub PaintChart(ByVal sender As Object, ByVal e As PaintEventArgs, ByVal insolvent As...
3
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
4
by: Nikola Bucic | last post by:
I have a problem with picturebox. I'm drawing on it with picturebox.DrawString, picturebox.DrawRectangle, etc. and it's working fine. But when I open another window over it I lost that. Triggering...
1
by: jimwawar | last post by:
I am working in C# and have a windows form containing a picturebox. The picture box is loaded with a bitmap by the user. The bitmaps are larger then the window and require scrolling. There is an...
4
by: munibe | last post by:
Hi, i have a problem about picturebox control. if you may help me, i will be so happy. i have a picturebox named pic_map, and i added a button named customer_button, my wish is to add a new small...
4
by: Marina Levit | last post by:
I am trying to do some processing on a background thread while keeping the UI painting. However, this is a generic server side call routine - and it needs to block until the server side call...
5
by: AWW | last post by:
XP VB 2005 running an example from help that creates a picturebox in code - the picturebox is not created. If I comment out the "Dim Box as New PictureBox" and create it in Design mode - the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.