Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.445 Beiträge
Delphi 12 Athens
|
AW: Seitenverhältnis von PNG-Grafiken ändern
13. Mär 2012, 20:35
Delphi-Quellcode:
var
hdr: TChunkIHDR;
origin: TPoint;
png1: TPngImage;
png2: TPngImage;
frame: TRect;
size: Integer;
begin
png1 := TPngImage.Create;
try
png1.LoadFromFile('c:\Temp\bild_original.png');
size := Max(png1.Width, png1.Height);
origin := Point((size - png1.Width) div 2, (size - png1.Height) div 2);
frame := TRect.Create(origin, png1.Width, png1.Height);
hdr := png1.Header;
png2 := TPngImage.CreateBlank(hdr.ColorType, hdr.BitDepth, size, size);
try
png2.Canvas.Brush.Color := clWhite;
png2.Canvas.FillRect(TRect.Create(0, 0, size, size));
png2.Canvas.Brush.Style := bsClear;
png1.Draw(png2.Canvas, frame);
png2.SaveToFile('c:\Temp\bild_neu.png');
finally
png2.Free;
end;
finally
png1.Free;
end;
end;
|
|
Zitat
|