Delphi 图像比例缩放问题 高手来啊
编译器是Delphi2010程序错误很多啊哪个帮忙改下unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,...
编译器是Delphi 2010程序错误很多啊哪个帮忙改下unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); end;var Form1: TForm1;implementation{$R *.dfm}uses Wincode;procedure TForm1.Button1Click(Sender: TObject);var WicImg: TWICImage; Factory: IWICImagingFactory; Scaler: IWICBitmapScaler; {图像比例变换接口}begin WicImg := TWICImage.Create; WicImg.LoadFromFile('c:\temp\test.jpg'); Factory.CreateBitmapScaler(Scaler); Scaler.Initialize(WicImg.Handle, WicImg.Width div 2, WicImg.Height div 3, WICBitmapInterpolationModeFant); WicImg.Handle := IWICBitmap(Scaler); Canvas.Draw(0, 0, WicImg); Scaler := nil; Factory := nil; WicImg.Free;end;end.
展开
展开全部
function Imgcompression(fileAdd: string;Width,Height,Quality: Integer):Boolean;
var
jpg: TJpegImage;
bmp: TBitmap;
begin
try
Result:= False;
if FileAdd = '' then Exit;
bmp := TBitmap.Create;
jpg := TJpegImage.Create;
try
jpg.LoadFromFile(FileAdd);
bmp.Height:= Height;
bmp.Width:= Width;
bmp.Canvas.StretchDraw(bmp.Canvas.ClipRect, jpg);
jpg.Assign(bmp);
jpg.CompressionQuality := Quality;
jpg.Compress;
jpg.SaveToFile(fileAdd);
Result:= True;
except
Result:= False;
end;
finally
jpg.Free;
bmp.Free;
end;
end;
var
jpg: TJpegImage;
bmp: TBitmap;
begin
try
Result:= False;
if FileAdd = '' then Exit;
bmp := TBitmap.Create;
jpg := TJpegImage.Create;
try
jpg.LoadFromFile(FileAdd);
bmp.Height:= Height;
bmp.Width:= Width;
bmp.Canvas.StretchDraw(bmp.Canvas.ClipRect, jpg);
jpg.Assign(bmp);
jpg.CompressionQuality := Quality;
jpg.Compress;
jpg.SaveToFile(fileAdd);
Result:= True;
except
Result:= False;
end;
finally
jpg.Free;
bmp.Free;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询