procedure TForm1.Button1Click(Sender: TObject);
var
bmp: TBItmap;
jpg: TJpegImage;
scale: Double;
begin
if opendialog1.execute then begin
jpg:= TJpegImage.Create;
try
jpg.Loadfromfile( opendialog1.filename );
if jpg.Height > jpg.Width then
scale := 50 / jpg.Height
else
scale := 50 / jpg.Width;
bmp:= Tbitmap.Create;
try
{Create thumbnail bitmap, keep pictures aspect ratio}
bmp.Width := Round( jpg.Width * scale );
bmp.Height:= Round( jpg.Height * scale );
bmp.Canvas.StretchDraw( bmp.Canvas.Cliprect, jpg );
{Draw thumbnail as control}
Self.Canvas.Draw( 100, 10, bmp );
{Convert back to JPEG and save to file}
jpg.Assign( bmp );
jpg.SaveToFile(ChangeFileext( opendialog1.filename, '_thumb.JPG' ));
finally
bmp.free;
end;
finally
jpg.free;
end;
end;
|
Copyright ©
"Мастера DELPHI" E-mail:
delphi@mastak.com
http://www.delphimaster.ru |
Источник получения информации: http://www.delphimaster.ru
|