Recent

Author Topic: Graphics32 Fit Image  (Read 259 times)

Pe3s

  • Sr. Member
  • ****
  • Posts: 311
Graphics32 Fit Image
« on: August 31, 2022, 08:51:47 pm »
Hello, how can I check if an image is in Portrait or Landscape format and adjust it to display?
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button2Click(Sender: TObject);
  2. var
  3.   Fit: Single;
  4. begin
  5.     Fit := ImgView32_1.Height / ImgView32_1.Bitmap.Height;
  6.   ImgView32_1.Scale := Fit;
  7. end;
  8.  
Width code
Code: Pascal  [Select][+][-]
  1. Fit := ImgView32_1.Width / ImgView32_1.Bitmap.Width;
  2.  

How to connect together?

paweld

  • Hero Member
  • *****
  • Posts: 524
Re: Graphics32 Fit Image
« Reply #1 on: August 31, 2022, 09:06:51 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button2Click(Sender: TObject);
  2. var
  3.   Fit: Single;
  4. begin  
  5.   if ImgView32_1.Bitmap.Height > ImgView32_1.Bitmap.Width then
  6.     ShowMessage('Portrait')
  7.   else
  8.     ShowMessage('Landscape');  
  9.   Fit := ImgView32_1.Height / ImgView32_1.Bitmap.Height;
  10.   if Fit > ImgView32_1.Width / ImgView32_1.Bitmap.Width then    
  11.     Fit := ImgView32_1.Width / ImgView32_1.Bitmap.Width;
  12. end;
You can also set ScaleMode to smOptimal or smStretch and then the size will be automatically adjusted: https://graphics32.github.io/Docs/Units/GR32_Image/Classes/TCustomImage32/Properties/ScaleMode.htm
« Last Edit: August 31, 2022, 09:09:50 pm by paweld »
Best regards
paweld

Pe3s

  • Sr. Member
  • ****
  • Posts: 311
Re: Graphics32 Fit Image
« Reply #2 on: August 31, 2022, 09:37:55 pm »
Thank you, you cannot zoom with those options

 

TinyPortal © 2005-2018