Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://lazplanet.blogspot.com
- // Adnan Shameem
- // Imagefile = The jpg file that you want to resize
- // W, H = Image destination width and height
- // DestFile = Destination file where the resized image should be saved
- function TForm1.ResizeAndSave(ImageFile: String; W: Integer; H: Integer;
- DestFile: String):Boolean;
- var
- bmp: TBitmap;
- jpg: TJPEGImage;
- begin
- try
- try
- jpg:=TJPEGImage.Create;
- bmp:=TBitmap.Create;
- jpg.LoadFromFile(ImageFile);
- bmp.Width:=w;
- bmp.Height:=h;
- bmp.Canvas.StretchDraw(Rect(0,0,w,h), jpg);
- jpg.Assign(bmp);
- jpg.SaveToFile(DestFile);
- Result:=true;
- except
- Result:=False;
- end;
- finally
- FreeAndNil(bmp);
- FreeAndNil(jpg);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement