473,327 Members | 1,896 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,327 software developers and data experts.

Scaling a collection of points(lines)?

Im kind of new to vb.net drawing routines. Im reading a collection of 2d
points from a
proprietary file. These points are simply for drawing lines, I can draw the
lines fine using Graphics.DrawLine, but I need to scale all the lines to fit
a rectangle of a given width and height.

What is the best method to do something like this? Its also important that
the drawing retain proportion within the given rectangle.

Thanks
Craig
Oct 20 '06 #1
1 1162
Have you tried percentages?

I placed a picture box on a form. Named it picturebox1

and used this code

Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
'Draw rectangle
Dim Rec As New Rectangle(0, 0, e.Graphics.ClipBounds.Width,
e.Graphics.ClipBounds.Height)
e.Graphics.DrawRectangle(Pens.Green, Rec)

'Draw 2 lines
Dim p1 As New PointF(Rec.Width * 0.01, Rec.Height * 0.1) '1% of width,
10% of height
Dim p2 As New PointF(Rec.Width * 0.8, Rec.Height * 0.9) '80% of width,
90% of height

'Wrote out the ponts.
Console.WriteLine(Rec.ToString & " " & p1.ToString)
Console.WriteLine(rec.ToString & " " & p2.ToString)

'Draw line to box
e.Graphics.DrawLine(Pens.Blue, p1, p2)

End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize
'Code used to redraw.
Me.PictureBox1.Invalidate()
End Sub

Does this help?
Good luck!

--
Thiele Enterprises - The Power Is In Your Hands Now!

--
"Craig Lucas" <cr********@tds.netwrote in message
news:dw*****************@newsreading01.news.tds.ne t...
Im kind of new to vb.net drawing routines. Im reading a collection of 2d
points from a
proprietary file. These points are simply for drawing lines, I can draw the
lines fine using Graphics.DrawLine, but I need to scale all the lines to fit
a rectangle of a given width and height.

What is the best method to do something like this? Its also important that
the drawing retain proportion within the given rectangle.

Thanks
Craig

Oct 20 '06 #2

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

Similar topics

1
by: rich | last post by:
I am trying to determine the best way to code a page with auto scaling left/right margins as well as an auto scaling footer. Here is a basic diagram of what I am hoping to achieve:...
2
by: Tomomichi Amano | last post by:
Hello How can I delete (clear) lines that were made useing Graphics.DrawLine() ? Thanks in advance! Have a nice day!
3
by: Larry Serflaten | last post by:
I am taking a 256 color bitmap from a file and scaling it up X 16 to a 32bppPARGB bitmap in memory. I copy that image to the screen. After scaling, the edges of all the lines and colors are...
54
by: MLH | last post by:
I use A97 and do not always insert line numbers while writing procedures. I find it necessary to go back and add them later to aid in debugging. Nearly 3 years ago, something was mentioned in...
11
by: lovecreatesbeauty | last post by:
For example, line L1 and line L2 are two lines in two-dimensional space, the start-points and end-points can be described with following the `point_t' type. The start-points and end-points are:...
5
by: David Longnecker | last post by:
I'm working to create a base framework for our organization for web and client-side applications. The framework interfaces with several of our systems and provides the business and data layer...
19
by: Pavan | last post by:
Hi, I want to know if there is any software for measuring lines of code of my c++ application. I found out a tool, sloccount, but it gives only physical lines of code. I found out one more...
4
by: sagar | last post by:
Hello Friends, I am working on a web application in which I have a map loaded on the page and I am required to dynamically draw points, lines, curves on the map to show a location, road etc. ...
158
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.