Resize Image when resizing Form

Posted on 2009-05-18
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 :)
Question by:eNarc
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

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

Author Comment

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 :)

Expert Comment

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;
   Target.PixelFormat := pf24bit;
   if ((new_h>10)  and (new_w >10)) then
          Target.Height  :=  new_h;
          Target.Width   :=  new_w;
          Target.Canvas.StretchDraw(Rect(0, 0, Target.Width, Target.Height), FromBit);
   result := Target;
end ;

Open in new window


Accepted Solution

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.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month5 days, 19 hours left to enroll

627 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