Dear colleagues,
I refer to your help with specific graphic problem. It is
necessary to create a viewfinder in graphic application.
It seems that the algorithm is simple: just draw lines
in specific position in according to value of some
controls, track bars, for example. Next read the track
bars value to find the coordinates of lines cross.
It works, but I can not get real cross because the
background image is being deface by lines images.
The drawing procedures looks like the next:
' Picture box picbView and two track bars (trckHoriz,
trckVer) are created on form.
#Region "Form level variables"
Dim hwnd As New IntPtr ' handler of picturebox's
window
Dim g As Graphics ' graphic object for drawing
lines
#End Region 'Form level variables
Sub InitiateFormData()
' call this procedure at Sub New, located at Windows Form
Designer generated code
' maximums of appropriate trackbars are equal to
picture box size
trckHoriz.Maximum = picbView.Width
trckVert.Maximum = picbView.Height
hwnd = picbView.Handle ' assigned
handler
g = Graphics.FromHwnd(hwnd) ' created
graphic object
' get path to image and load it as picture box's
background
Dim strImageFile As String =
Application.ExecutablePath.Substring(0, _
Application.ExecutablePath.LastIndexOf
("\") + 1) & "Viewfinder.jpg"
picbView.BackgroundImage = Image.FromFile
(strImageFile)
End Sub
Sub DrawViewfinder()
' draw viewfinder's lines
' TODO - how to prevent the drawing of multiple
lines ????
Dim p_en As New Pen(Color.Yellow)
g.DrawLine(p_en, 0, trckVert.Value,
picbView.Width, trckVert.Value) ' horizontal line
g.DrawLine(p_en, trckHoriz.Value, 0,
trckHoriz.Value, picbView.Height) ' vertical line
' and we get the images of all lines ever been
drawn :<<<
End Sub
Private Sub trckHoriz_Scroll(ByVal sender As Object,
ByVal e As System.EventArgs) Handles trckHoriz.Scroll
DrawViewfinder()
End Sub
Private Sub trckVert_Scroll(ByVal sender As Object,
ByVal e As System.EventArgs) Handles trckVert.Scroll
DrawViewfinder()
End Sub
I will be highly grateful for advices how to resolve this
problem.
Best regards
George Golubev, Russia 2 2201
Hi, http://www.vb-helper.com/howto_net_rubberband_line.html
Ken
--------------
"George" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl... Dear colleagues, I refer to your help with specific graphic problem. It is necessary to create a viewfinder in graphic application. It seems that the algorithm is simple: just draw lines in specific position in according to value of some
controls, track bars, for example. Next read the track bars value to find the coordinates of lines cross. It works, but I can not get real cross because the background image is being deface by lines images. The drawing procedures looks like the next:
' Picture box picbView and two track bars (trckHoriz, trckVer) are created on form.
#Region "Form level variables" Dim hwnd As New IntPtr ' handler of picturebox's window Dim g As Graphics ' graphic object for drawing lines #End Region 'Form level variables
Sub InitiateFormData() ' call this procedure at Sub New, located at Windows Form Designer generated code ' maximums of appropriate trackbars are equal to picture box size
trckHoriz.Maximum = picbView.Width trckVert.Maximum = picbView.Height
hwnd = picbView.Handle ' assigned handler g = Graphics.FromHwnd(hwnd) ' created graphic object
' get path to image and load it as picture box's background Dim strImageFile As String = Application.ExecutablePath.Substring(0, _ Application.ExecutablePath.LastIndexOf ("\") + 1) & "Viewfinder.jpg" picbView.BackgroundImage = Image.FromFile (strImageFile)
End Sub
Sub DrawViewfinder() ' draw viewfinder's lines
' TODO - how to prevent the drawing of multiple lines ????
Dim p_en As New Pen(Color.Yellow) g.DrawLine(p_en, 0, trckVert.Value, picbView.Width, trckVert.Value) ' horizontal line g.DrawLine(p_en, trckHoriz.Value, 0, trckHoriz.Value, picbView.Height) ' vertical line ' and we get the images of all lines ever been drawn :<<< End Sub
Private Sub trckHoriz_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles trckHoriz.Scroll DrawViewfinder() End Sub
Private Sub trckVert_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles trckVert.Scroll DrawViewfinder() End Sub
I will be highly grateful for advices how to resolve this problem. Best regards George Golubev, Russia
* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit: http://www.vb-helper.com/howto_net_rubberband_line.html
Notice that the 'ControlPaint' class provides some methods to draw
selection rectangles and/or focus rectangles too.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Remon Huijts |
last post by:
Hi there,
For a very specific service, I have created a PHP script that uses the GD
library functions to create a PNG image from a few lines of XML data
describing a simple diagram/drawing. It's...
|
by: KathyB |
last post by:
Hi, I'm using xml transformed to html via xsl. The problem is my HTML
source text auto wraps/breaks lines. This only matters when the line
involves a parameter I'm passing to a script...which then...
|
by: news.microsoft.com |
last post by:
Hello group,
My goal is to attach an image over another image.
Top image should be transparent so the back image is visible through the top
one.
Bellow is a test code in VB.NET. You need to...
|
by: techfuzz |
last post by:
I scoured this group and others looking for the best way to disable a
button after the first click to prevent multiple submissions, but
never did find anything that worked like they said it would. ...
|
by: Ken Varn |
last post by:
I have an ASP.NET page that draws over 32 dynamic images using an HttpModule
object through the <IMG> tag. Since IIS under Win2K Pro has a limit of 10
connections, some of the images do not get...
|
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...
|
by: Galen Somerville |
last post by:
My VB2005 app gets real time Heart sounds and an ECG from a USB device. I'm
looking for a way to speed up the drawing of the traces on the screen.
In the following code the routine GetSounds...
|
by: =?Utf-8?B?R2lkaQ==?= |
last post by:
Hi,
I've windows form, in this form i've a panel.
I want to draw lines inside the panel using the panel coordinates( meaing
that the left upper corner of the panel is 0,0), how can i do it?
...
|
by: YouPoP |
last post by:
I am doing an app (C# 2.0) where you can draw in a panel with your mouse in "real time". I actually have 2 problems;
1- it does not really is "real time", if your mouse move fast or very fast the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
| |