d2lmirrors / anolis

Anolis is the underlying project for the XPize and Vize resource switchers for Windows XP and Vista respectivly. The codebase allows for the easy swapping around of resources within Win32 executables and other files. (just adding some missing data)
GNU General Public License v2.0
1 stars 0 forks source link

Image centering is buggy #24

Open Dobby233Liu opened 1 year ago

Dobby233Liu commented 1 year ago

creation date = 2009-03-03T17:35:31.393-08:00

The "center image" in Anolis Resourcer doesn't calculate coordinates properly: when changing the zoom level the image is transformed relative to (0,0) rather than the center of the image itself. Also when centered and if the image is large enough it becomes impossible to see it all.

Dobby233Liu commented 1 year ago

creation date = 2009-03-04T13:31:23.263-08:00

If you are interested in a quick fix, replace stuff in ZoomPictureBox.GetRectangle() with

retVal.X = (rect.Width - _image.Width) / Convert.ToInt32(2 * _zoom);
retVal.Y = (rect.Height - _image.Height) / Convert.ToInt32(2 * _zoom);

Note that you still relate to the form width/height, not the active draw area, which is smaller. And you should also add a minimum allowed size for the form, like 640x320.

Dobby233Liu commented 1 year ago

creation date = 2009-03-05T05:04:03.12-08:00

I thought of using that simple technique, but I'd like to stay "mathematically pure" and stick with the Transforms so I can also implement rotation and other nifty things you can do with Transform matrices.