D2007 kullanıyorum.Kaliteli bir resim resize etmek için GR32 componenti http://www.g32.org/graphics32/ kullanmak istiyorum.
Kod: Tümünü seç
uses Jpeg, GR32, GR32_Image,GR32_Transforms,GR32_Filters;
procedure SaveImage(inBmp: TBitmap32; filename: string);
var jpeg: TJPEGImage;
bmp: TBitmap;
begin
jpeg := TJPEGImage.Create;
bmp := TBitmap.Create;
try
bmp.Assign(inBmp);
jpeg.CompressionQuality := 100;
jpeg.Assign(bmp);
jpeg.SaveToFile(filename);
finally
jpeg.Free;
bmp.Free;
end;
end;
procedure resizePicture(infile: string; outfile: string; width, height: integer;
aspectratio: boolean);
var srcpic, destpic:TBitmap32;
destrect, srcrect:TRect;
begin
srcpic:=TBitmap32.Create;
destpic:=TBitmap32.Create;
try
srcpic.LoadFromFile(infile);
if aspectratio=true then begin
if srcpic.Height > srcpic.Width then begin
width:=height * srcpic.width div srcpic.height;
end else begin
height:=width * srcpic.Height div srcpic.Width;
end;
end;
try
destpic.width:=width;
destpic.height:=height;
destrect:=Rect(0,0,destpic.width,destpic.height);
srcrect:=Rect(0,0,srcpic.width,srcpic.height);
srcpic.StretchFilter:=sfLanczos;
destpic.Draw(destrect,srcrect,srcpic);
finally
srcpic.free;
end;
//destpic.SaveToFile(outfile);
SaveImage(destpic, outfile);
finally
destpic.free;
end;
end;