# Weird draw location

**URL:** <https://forum.xojo.com/t/weird-draw-location/62967>\
**Category:** General\
**Created:** [April 25, 2021, 11:56pm UTC](https://forum.xojo.com/t/weird-draw-location/62967 "2021-04-25T23:56:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 25, 2021, 11:56pm UTC](https://forum.xojo.com/t/weird-draw-location/62967/1 "2021-04-25T23:56:54Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Michael\_Hußmann](https://forum.xojo.com/user_avatar/forum.xojo.com/michael_hu%C3%9Fmann/32/438_2.png) [@Michael\_Hußmann](https://forum.xojo.com/u/Michael_Hu%C3%9Fmann)\
**Post date:** [April 26, 2021, 1:16pm UTC](https://forum.xojo.com/t/weird-draw-location/62967/2 "2021-04-26T13:16:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 26, 2021, 1:41pm UTC](https://forum.xojo.com/t/weird-draw-location/62967/3 "2021-04-26T13:41:36Z")

</div>

![image](https://forum.xojo.com/uploads/default/original/2X/2/236e5ed1cd389dc87dd68b7dff2448d862ac4f4d.png)  
Image. Dart Picture will be draw inside the green rectangle.

![image](https://forum.xojo.com/uploads/default/original/2X/3/36cd58a7d13e41cb40a0c4cdeab9466f8dc68b1f.png)  
Dart 1

![image](https://forum.xojo.com/uploads/default/original/2X/c/cb68e41f89cffcc94e0c5140ced597ce3329183e.png)  
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…

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 27, 2021, 8:36am UTC](https://forum.xojo.com/t/weird-draw-location/62967/4 "2021-04-27T08:36:19Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [April 27, 2021, 8:58am UTC](https://forum.xojo.com/t/weird-draw-location/62967/5 "2021-04-27T08:58:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 27, 2021, 2:35pm UTC](https://forum.xojo.com/t/weird-draw-location/62967/6 "2021-04-27T14:35:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [April 27, 2021, 4:36pm UTC](https://forum.xojo.com/t/weird-draw-location/62967/7 "2021-04-27T16:36:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 28, 2021, 8:46pm UTC](https://forum.xojo.com/t/weird-draw-location/62967/8 "2021-04-28T20:46:57Z")

</div>

Here’s an example result:

![image](https://forum.xojo.com/uploads/default/original/2X/4/40ac554c136e8f8b194558f8fc405dd0196a4755.png)
