Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Resize Image when resizing Form

Posted on 2009-05-18
4
Medium Priority
?
184 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

824 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