My images are not fully displayed (height)

I cannot goes on because I do not understand what happens.

Here’s theimage as it is displayed “as is”:

As you can see, the Canvas is higher than the window(full screen) and the image is missing its bottom.

When I resize horizontally the window, here’s the results:

There is still a bit of missing image at the bottom, but fewer.

I added Self.UpdateNow after I resized my Offscreen image (who is displayed in Paint.Graphics.Draw Picture.
The OffscreenPict is complete (miss nothing in the debuger).

I cleared the cache (Settings).

Sequoia / current Xojo

Ideas ?

Write a tiny sample to show the problem, share the project zip here, the community will fix the code if necessary.

to display a picture stretched on canvas in the paint event i use out of mind
g.DrawPicture pic,0,0,g.Width,g.Height,0,0,pic.Width,pic.Height

I guess the math he will need is best fit-in centered into canvas, not stretch to canvas.

I assume you just need to scale proportionally and use the max.height for the final image as reference.

Proportional scaling can be achived f.e. using a method like:

Function Scale_Proportional(Pic as Picture, Width as integer, Height as Integer) As Picture
		  If pic=Nil Then Return Nil
		  
		  // calculate the scale factor
		  Dim factor As Double = Min( Height / Pic.Height, Width / Pic.Width )
		  
		  // Calculate new size
		  dim w as integer = Pic.Width * factor
		  dim h as integer = Pic.Height * factor
		  
		  // create new picture
		  Dim NewPic As New Picture( w, h )
		  
		  // draw picture in the new size
		  NewPic.Graphics.DrawPicture( Pic, 0, 0, w, h, 0, 0, Pic.Width, Pic.Height )
		  
		  // return scaled image
		  Return NewPic
End Function

Snippet taken from my Stable Diffusion Prompter: GitHub - Schneppi/Stable-Diffusion-Prompter: A UI driven Stable Diffusion Prompt Generator

at least it is full visible :slight_smile:

@Emile_Schwarz
have you set the anchors correct?
you could use a background color to see the control elements better.

Well… We are talking about art. Proportions matter very much.

2 Likes

in the first image it looks like that width and height is equal,
maybe copy/paste mistake if you create the image?

When I resize horizontally the window, here’s the results:

and then other if/then is used for dimension?