In case that you need to change PNG file size (width, height), you can use below function.
procedure copy_to_resized_png( tar, src:string; w, h: Integer);
var
bmp: TBitmap;
png, output: TPngImage;
begin
png := TPngImage.Create;
png.LoadFromFile( src);
bmp := TBitmap.Create;
bmp.Width := w;
bmp.Height := h;
bmp.Canvas.StretchDraw( RECT( 0, 0, w, h), png);
output := TPngImage.Create;
output.Assign( bmp);
output.SaveToFile( tar);
output.Free;
bmp.Free;
png.Free;
end;
var
bmp: TBitmap;
png, output: TPngImage;
begin
png := TPngImage.Create;
png.LoadFromFile( src);
bmp := TBitmap.Create;
bmp.Width := w;
bmp.Height := h;
bmp.Canvas.StretchDraw( RECT( 0, 0, w, h), png);
output := TPngImage.Create;
output.Assign( bmp);
output.SaveToFile( tar);
output.Free;
bmp.Free;
png.Free;
end;
In order to implement above function, I used TPngImage.
Another posts included in "Delphi"
| Delphi API to get the current working directory (0) | 2009/09/03 |
| Delphi API to get windows temporary directory (0) | 2009/09/03 |
| How to print external document ? (0) | 2009/09/09 |
| Get the length of arrays and a string (0) | 2009/08/22 |
| Delphi Pointer Types (0) | 2009/08/22 |
| How to read/wrtie INI file in Delphi ? (0) | 2009/08/21 |
| How to get file created time, modified time, and last accessed time ? (0) | 2009/08/19 |
| Delphi string conversion functions - AnsiToUTF-8, UTF8Encode, ... (0) | 2009/07/20 |

Prev

Rss Feed