Solved

Resize Image when resizing Form

Posted on 2009-05-18
4
178 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

762 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