Solved

Resize Image when resizing Form

Posted on 2009-05-18
4
176 Views
Last Modified: 2012-05-07
Hi I'd like to be able to resize an image1 while still keeping its aspect, when I resize the form.

so when I expand the form the image also expands, when I shrink the form the image also shrinks :)
0
Comment
Question by:eNarc
  • 2
4 Comments
 
LVL 8

Expert Comment

by:BdLm
ID: 24418871
do you need to change the pixel size ?  There are many options for resize an image, from fast algo with low quality until excellent results using long calc time.

the cheap option is the stretch option in the image property
0
 
LVL 5

Author Comment

by:eNarc
ID: 24420104
mostly its just the image1.height and image1.width that need changing because if I was to change the image draw on resize it would amount so much memory that it would probly stall the computer.


like how we would keep that of a panel in line with the rest of the form, neeting an image to remain in aspect at the same time staying within the form as it moves :)
0
 
LVL 8

Expert Comment

by:BdLm
ID: 24420380
you my try that code, fast procedure,

how to use:  

         MynewBitMap := ResizeBMP(OldBMP, newh, neww);



function ResizeBMP(FromBit:  TBitmap; new_h, new_w  :  Integer) : TBitMap;
var    Target   :  TBitmap;
begin
 
 
   Target:=TBitmap.Create;
 
   Target.PixelFormat := pf24bit;
 
   if ((new_h>10)  and (new_w >10)) then
      begin
          Target.Height  :=  new_h;
 
          Target.Width   :=  new_w;
 
          Target.Canvas.StretchDraw(Rect(0, 0, Target.Width, Target.Height), FromBit);
 
      end;
 
   result := Target;
end ;

Open in new window

0
 
LVL 1

Accepted Solution

by:
sidneye earned 500 total points
ID: 24422364
On your Timage set Proportional=True, Stretch=True, Align=alClient.  You may need to move other components to a panel that you align to an edge but this is all you need.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to disable mouse scroll in a combo box field within a Delphi cxGrid 4 135
Internet Explorer View Settings Question 15 111
code issue 8 130
Delphi Form ownership 4 89
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question