
01.08.2012, 17:11
|
Прохожий
|
|
Регистрация: 01.08.2012
Адрес: UA
Сообщения: 11
Версия Delphi: 2007, XE2
Репутация: 10
|
|
Нашёл вот такой код
Код:
uses GDIPAPI, GDIPOBJ,GDIPUTIL;
procedure TForm11.Button1Click(Sender: TObject);
var
in_img, out_img: TGPImage;
g: TGPGraphics;
out_width, out_height: Integer;
sclx:extended; fname:string;
encoderClsid: TGUID;
begin
fname:='D:\test.png';
out_width := 450;
in_img := TGPImage.Create(fname);
sclx:=450/in_img.GetWidth;
if sclx <> 1 then
begin
out_height := round(in_img.GetHeight*sclx);
out_img := TGPBitmap.Create(out_width, out_height);
g := TGPGraphics.Create(out_img);
g.DrawImage(in_img, MakeRect(0, 0, out_width, out_height), 0, 0, in_img.GetWidth, in_img.GetHeight, UnitPixel);
g.Destroy;
in_img.Free; //иначе надо сохранять не в (fname) а (NOTfname)
GetEncoderClsid('image/png', encoderClsid);
out_img.Save(fname, encoderClsid);
end;
end;
http://kachkarvv.org.ua/faq/src-delp...pg-gdi-rsz.php
тестирую
|