Weird draw location

This happens while I was refactoring my code and it goes well. Then I made my test using a Portrait image to be sure it works with the two orientations images: Portrait and Landscape.

The code below centers a landscape window. OK, why not. But, if I use a Portrait image, I also get the image centered.And this is normally not possible with a fixed X value and an image with a smaller width….

Same image, rotated and resized; one is 316 pixels width, the second is 920 pixels width.

Xojo 2021r1.1
Big Sur
MacBook Pro M1

Image.Graphics.DrawPicture Dart,52,Align_Y

I even use 0 instead of 52 and get the image centered.

I cleared Xojo Cache folder, quit Wojo and restart.

The only thing I do not do (yet) is to shutdown and reboot, then test again.

BTW: 52 is the correct value to center horizontally the Landscape image. I computed it manually (*). But the real code to be tested is one that compute by itself the value to center the image using the passed (I was suspicious, so I replaced Align_X with 52, then 0, and the image is still centered with the Portrait image !

Image is a fixed sized image. I computed the value to center horizontally the Dart image with a sheet of paper and pen.Old methods can be good methods.

Nota: I also have troubles with vertical alignments (Top, Center and Bottom). Center is correct, but the other two may vary.
Align_X and Align_Y are not Static nor Properties, only standard local variables; and this may be related…

Odd … but impossible to explain without any context. If one line of code appears to be correct the root of the issue is usually found somewhere else.

Image. Dart Picture will be draw inside the green rectangle.

Dart 1

Dart 2

Dart 1 is 900 pixels wide (20 pixels less than the green image width) and the height is unknow.
Dart 2 is 600 pixels wide (50 pixels less than the gree image height) and the width is unknow.

Dart 1 and Dart 2 comes from the user and their size is unknow, but resized to 900 pixels wide (if Landscape) and 600 pixels tall (if Portrait).

In my test I draw Dart 1 and Dart 2 inside the Green area of Image.

Is it clear now ?

They were smaller in LibreOffice…

I fired Xojo / M1, minutes ago, and the Landscape image is draw at X=0; the Portrait image is not…

Also, Realbasic.Rect draw the window a bit too to the right of the monitor…

i would test the coords with dots or draw rectangle
and giving the images also a border and without alpha.
test without hidpi. test with last xojo release.

The Dart Picture (loaded from disk) do not have alpha).

Resolution does not matter as I load/draw in a Picture and DrawPicture that Picture.

There is no new than:
Xojo 2021r1.1
Big Sur 11.3
MacBook Pro M1

Now, while I was downloading a 7GB archive, I’ve followed the process more carefully and discovered that in Dart = Resize(f) module, I created a Picture that fills the whole allowed space (to center the image), and there is no room afterward for centering !

Thank you for the advices. More to refactor.

1 Like

okay. good that you found a trail.

my typical mistake is that the draw output is scaled into a area and have nothing to do with the original image size. as example .DrawPicture pic,0,0,g.Width,g.Height,0,0,pic.Width,pic.Height

Here’s an example result: