I am trying to load an image onto a usercontrol Graphics Surface. I have no problem doing this. However, the result is never as expected. The image should scale to reach the border with the longest axis and be in the center of the remaining axis. I can not find any information that describes this relationship well to enable full understanding of what is actually happening.
Using something like :
private void ZoomControl_Paint(object sender, PaintEventArgs e)
{
var g = e.Graphics;
g.Transform = new Matrix();
Zoom = 0.5;
float X = dx;
float Y = dy;
g.TranslateTransform(X, Y);
g.ScaleTransform(zoom, zoom);
g.DrawImage(objBitmap, 0,0);
}
I have tried many combinations but all this is doing is proofing I don't know how a transformation works and its persistence nature.
I can scale correctly using Image methods and paint normaly on the control for the perfect solution but this does not yield a good starting point for Zooming and Panning to follow. Expected Result
This approach provides the best animation in the Drag and Zoom phases and the inspiration of this attempt was sourced here https://github.com/AliAlAali/ZoomPanControl. Sadly this example doesn't use or start with a perfectly scaled and centered image.