Link to home
Start Free TrialLog in
Avatar of eNarc
eNarcFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Resize Image when resizing Form

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 :)
Avatar of BdLm
BdLm
Flag of Germany image

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
Avatar of eNarc

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of sidneye
sidneye

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial