473,466 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Drawing on top of a static image

I am using VB.NET to draw a gauge; i.e. to repeatedly draw a needle
moving on top of a static image of the gauge background whenever the
value changes.

Each time the value changes, I can clear the current graphics to some
color, redraw the gauge background picture with Graphics.DrawImage and
then the needle on top of it with Graphics.DrawPolygon & FillPolygon,
but this seems very wateful as the background never changes.

If I set the control's BackImage as my image and then only draw the
needle though, the last few spots the needle was still show it there
so it looks like there are many needles. These all get cleaned up
periodically when OnPaint is called but only when called by the system
(when I trigger OnPaint no cleanup occurs).

What is the right way to do this?

Thanks,
Jo
Jul 3 '08 #1
3 2074
Can you draw the needle on a separate transparent control that overlaps the
background image?

--
David Streeter
Synchrotech Software
Sydney Australia
"JM****@gmail.com" wrote:
I am using VB.NET to draw a gauge; i.e. to repeatedly draw a needle
moving on top of a static image of the gauge background whenever the
value changes.

Each time the value changes, I can clear the current graphics to some
color, redraw the gauge background picture with Graphics.DrawImage and
then the needle on top of it with Graphics.DrawPolygon & FillPolygon,
but this seems very wateful as the background never changes.

If I set the control's BackImage as my image and then only draw the
needle though, the last few spots the needle was still show it there
so it looks like there are many needles. These all get cleaned up
periodically when OnPaint is called but only when called by the system
(when I trigger OnPaint no cleanup occurs).

What is the right way to do this?

Thanks,
Jo
Jul 4 '08 #2
I guess I could do that too. Thanks for the tip.

I did resolve my issue though by adding Me.Refresh() such that the old
drawings could get whisked away.

Jo
Jul 7 '08 #3
I can't believe I haven't noticed it before but the PictureBox control in
VS2008 has a ".BackgroundImage" property as well as an ".Image" property.

In fact, it's a property of the Control class!!!

Maybe this will do what you need?

--
David Streeter
Synchrotech Software
Sydney Australia
"JM****@gmail.com" wrote:
I am using VB.NET to draw a gauge; i.e. to repeatedly draw a needle
moving on top of a static image of the gauge background whenever the
value changes.

Each time the value changes, I can clear the current graphics to some
color, redraw the gauge background picture with Graphics.DrawImage and
then the needle on top of it with Graphics.DrawPolygon & FillPolygon,
but this seems very wateful as the background never changes.

If I set the control's BackImage as my image and then only draw the
needle though, the last few spots the needle was still show it there
so it looks like there are many needles. These all get cleaned up
periodically when OnPaint is called but only when called by the system
(when I trigger OnPaint no cleanup occurs).

What is the right way to do this?

Thanks,
Jo
Jul 15 '08 #4

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

Similar topics

2
by: James Coburn's Grey Helmet Hair | last post by:
When I try to compile my GTK# app, the compiler says: jbailo@linux:~/mono> mcs buttons.cs -r gtk-sharp.dll -r glib-sharp.dll -r -o buttons.exe error CS2001: Source file 'buttons.exe' could not...
4
by: funcSter | last post by:
Hey, got a prob which is driving me nuts! I'm trying to resize the resolution of an image as well as it's pyhsical byte size. I've got: byte bytImage = null; System.Drawing.Image imgImage =...
2
by: Espen | last post by:
Hi I have a C# application that should display a chart, the chart drawing is done by a COM object. I have tried to use dllimport with gdi32.dll and created compatibleDC and compatibleBitmap with...
1
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
1
by: André Nogueira | last post by:
Hi there. I'd like to allow the user to create some free-form drawing in my application, in the style of Microsoft Paint (the Brush tool) or Paint.Net. I've looked through Paint.Net's source code,...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
2
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
2
by: ouzsharp | last post by:
The follwing class works well when used in a C# console application: namespace ScreenShotDemo { /// <summary> /// Provides functions to capture the entire screen, or a particular...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.