Scaling

E

EricW

hi,

For my program I have two forms.
each has a picturebox on it.

The second form is to allow the user to determine where he wants to place a
small drawing in an existing drawing.
When he is finished, the location of that drawing needs to go to the main
form where it will place it on the drawing.

I know this sounds strange, but I need it to do it this way.

How can I place the small drawing of which I got it's position on the 2nd
form, in to the picturebox on the 1st form exactly where the user wants it?
The two forms are different in size and also the pictureboxes are.

could someone pls help?

rg,
Eric
 
A

Andrew Backer

Get the graphics object for the picturebox, and then you can call

g.DrawImage( image, destination rectangle, source rectangle, GraphicsUnit.Pixel)

This will draw the image onto the graphics object, at the desired location
(destination rectangle), using the data in the area defined by SourceRectangle.
It will do the scaling for you. If you want the entire image, just use
Image.Bounds (i think), or make a new rectangle like this : New Rectangle(new
Point(0,0), image.Bounds.Size ) and use that.

To make the scaling more attractive, you can use these settings. I think
the last one (InterpolationMode) is the only really required one, but perhaps
the graphics object you get back has the others set to low values.

gt.SmoothingMode = SmoothingMode.HighQuality;
gt.CompositingQuality = CompositingQuality.HighQuality;
gt.InterpolationMode = InterpolationMode.HighQualityBicubic;


//Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top