Renate Schaaf 64 Posted May 4, 2023 I'm not all that familiar with FMX. So I'm trying to have a TImage display a TBitmap so I see the "exact" original, and I also want the image to resize to the correct dimensions of the bitmap. This is what I have come up with, but it seems overly complicated: procedure DisplayInOriginalSize_AndSizeToFit(const bmp: TBitmap; im: TImage); var ScaleInv: single; begin im.WrapMode := TImageWrapMode.Original; ScaleInv := 1 / im.Scene.GetSceneScale; // ScaleInv:=1/Screen.Displays[0].Scale; im.SetBounds(im.Position.X, im.Position.Y, bmp.Width * ScaleInv, bmp.Height * ScaleInv); im.Bitmap.Assign(bmp); im.Bitmap.BitmapScale := 1; end; The commented line works too for me, but it wouldn't in a multiple-monitor-setting. There must be an easier way to set the exact pixel dimensions of a control. Thanks, Renate Share this post Link to post
programmerdelphi2k 237 Posted May 4, 2023 (edited) question: and if you place a TImage in a form (or another container), define this container to occupy the entire screen (or the desired size), and, in the TImage, activate the option to use the entire client area of this container. So the TImage properties (like WrapMode) can be set to fill this entire area, dont? there is TImageViewer too... Edited May 4, 2023 by programmerdelphi2k Share this post Link to post
Renate Schaaf 64 Posted May 4, 2023 5 minutes ago, programmerdelphi2k said: and if you place a TImage in a form (or another container), define this container to occupy the entire screen (or the desired size), and, in the TImage, activate the option to use the entire client area of this container. How does this relate to my question? Share this post Link to post
programmerdelphi2k 237 Posted May 4, 2023 (edited) 1 hour ago, Renate Schaaf said: How does this relate to my question? if dont, sorry! look my post... calculate font scale Edited May 4, 2023 by programmerdelphi2k Share this post Link to post
Patrick PREMARTIN 69 Posted May 4, 2023 As I understand you want your TImage has the same Width/Height than your Bitmap without interest in pixel depth ? In that case, try this : procedure DisplayInOriginalSize_AndSizeToFit(const bmp: TBitmap; im: TImage); begin im.Bitmap.Assign(bmp); im.With := im.Bitmap.Width; im.Height := im.Bitmap.Height; // or SetSize() im.Bitmap.BitmapScale := 1; end; Share this post Link to post
Renate Schaaf 64 Posted May 4, 2023 (edited) 6 hours ago, Patrick PREMARTIN said: im.With := im.Bitmap.Width; This will scale the image by the desktop-DPI. For example my desktop-display is set at 200%. The bitmap is displayed in original size because of im.Wrapmode = Orignal. But the Image will be twice as large as its bitmap, and the scrollbox it's in will have a scrollbar-range which is too big . I have corrected that by dividing the width by im.scene.scale, which works. I was just wondering, whether there isn't a simpler way. Edited May 4, 2023 by Renate Schaaf Share this post Link to post
Patrick PREMARTIN 69 Posted May 5, 2023 Perhaps you can put the TImage in a TScaledLayout or simply use its Scale property after having a TImage.Size=TBitmap.Size in pixels ? Share this post Link to post