Tough graphics question?

bonedoc

Well-known member
Joined
May 4, 2006
Messages
112
Programming Experience
Beginner
I am trying to take a rectangle from the image of picturebox1 and draw it into another rectangle. To make it simple, I have 2 rectangles that are the same size and location as the mouse position, in the picturebox1.mousemove event. I use this:

VB.NET:
dim g as Picturebox1.CreateGraphics
dim ImageBoxR, ImageBoxS as rectangle
 
ImageBoxR = New Rectangle(e.x,e.y,100,100)
ImageBoxS = New Rectangle(e,x,e.y,100,100)
 
g.drawimage(picturebox1.image, ImageBoxR, ImageBoxS, GraphicsUnit.Pixel)
This works. It draws the image the rectangleR is over onto the rectangleS. The vertical measurements are right on, But the left to right demensions are shifted or smaller. Is it because the picturebox is taller than it is wider? Is it the GraphicsUnit.Pixel? I dont get why it is behaving this way.
 
Last edited by a moderator:
Ok, I found something interesting out. The Behavior happens when I load a new picture in the picturebox. However, if I SAVE the picture in the picturebox to a file, and then open it into the picturebox, it works perfect. It is like it is

1. Saving it as a different format.resolution
2. or, The GraphicsUnit.Pixel is jacking it around.

Any ideas?
 
Back
Top