## 3 replies

Last post Jun 28, 2005 06:50 AM by JasonFollas

None

0 Points

57 Posts

### Image Zooming

Hi all,

I have defined a bitmap object and have successfully draw marks on a vertical line using small range of coordinates (0-1000). However, this is what happems for long ranges:

I have a set of  coordinates that i would like to make a mark on a vertical line. However due to the long range of my coordinates, the mark doesnt seems to appear on the Line.

Coordinates
114171763,114172304
59615937,59616341
107664369,107664544

It seems impossible to show such long ranges of coordinates, therefore, i am thinking of  actually drawing the smaller version of the image and zooming it in to see the details, Is it possible? PLease advice.
An example of what i describe would be this (http://www.ncbi.nlm.nih.gov/mapview/maps.cgi?taxid=9606&chr=1)

Regards

Member

10 Points

169 Posts

### Re: Image Zooming

What you mentioned about drawing the smaller version is the exact approach that I would take.

You likely (or hopefully) won't have an image that is millions of pixels along one side, so you'll need to translate your coordinates into a new pixel space.  Sounds harder than it really is.

For instance, let's look at how to handle the (114171763, 114171763) coordinate.

You need to first determine a comfortable image size that your users will be viewing.  For this example, let's say that we're going to use a 500px by 500px image.

You next need to determine the coordinate space that your picture represents.  For this example, let's say that pixel (0,0) is coordinate (0,0), and pixel (500,500) is coordinate (15000000, 15000000).  I picked a maximum coordinate that is larger than my data, because otherwise, I would be plotting off of the image.

This means that every pixel on the drawing represents 30000 units of the coordinate space:

(15000000 - 0) / 500 = 30000 coordinates/pixel

([max coord represented] - [min coord represented]) / [image size in pixels]

So, when drawing coordinates to your image using this example, simply divide the coordinate by 30000 to get the pixel number within the small image.  If you use floating point types, then GDI+ will often do the anti-aliasing for you, giving you the feeling of drawing "in-between pixels"

For zooming functionality, you can either choose to grow your image (so instead of 500x500, maybe it's now 1000x1000) or have your image become a zoom window, much like internet mapping sites do.  In either case, repeat the exercise above of determining the coordinates-per-pixel in order to do your conversion of coordinate number to pixel number.

Note that when you pan a zoom window around, the (0,0) pixel of the image will no longer represent your coordinate (0,0).

Let me know if this is too confusing.

None

0 Points

57 Posts

### Re: Image Zooming

Hi Jason,

I understand what you are saying. However, it seems if u divide the coords by 30000, it became a decimal which cannot be use in the DrawLine method which accepts integer as its datatype.

I encountered the following error:
(C:\Inetpub\wwwroot\WebGraphicsFYPJ\WebForm1.aspx.vb(42): Overload resolution failed because no accessible 'DrawLine' can be called without a narrowing conversion:
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)': Argument matching parameter 'x1' narrows from 'Double' to 'Integer'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)': Argument matching parameter 'x2' narrows from 'Double' to 'Integer'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single)': Argument matching parameter 'x1' narrows from 'Double' to 'Single'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single)': Argument matching parameter 'x2' narrows from 'Double' to 'Single'.)

An example of the method: objGraphics.DrawLine(penDraw1, 1, Y1coord / 1000000, 1, Y2coord / 1000000)

Am i in the right path?

Member

10 Points

169 Posts