I have inherited from a picturebox and modified it to allow a selection rectangle to be drawn. Everything works well, except I would like for it to work in all sizeModes. center is simple, normal is simple. but I cant' seem to get "Zoom" to work. I have used reflector to strip the out the code that is responsible for the zoom rectangle in the picturebox. Its simple, it just devides the client width by the image width and the client height by the image high and gets the smaller value and scales by that.

When I try to do this with my rectangle I don't get the correct size,

I'm not the best at math, especially geometry. but this seems like it should be more simple.

The image is centered in the control, and scaled to fit. I draw a rectangle on the control representing a crop region. the rectangle then needs to be translated to the acutall image coordinates. I found a codeproject site that translates points. but It seems to be off, and I can't seem to get the size of the rectangle right.

Any help would be appreciated.

Nevermind. I was over thinking it. Trick was to divide the ratio by the size of the rectangle. Now i have a more complicated problem of keeping the selection rectangle from running off the image.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.