1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
unit uimagesize1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls,
GraphType, IntfGraphics, fpimage, fpreadpng,fpwritepng;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
Bmp: TBitmap;
I, J, W, H: Integer;
lzimg: TLazIntfImage;
Png: TPortableNetworkGraphic;
begin
W := 32767;
H := 16383;
Bmp := TBitmap.Create;
try
Bmp.PixelFormat := pf32bit;
Bmp.Width := W;
Bmp.Height := H;
Bmp.Canvas.Pen.Color := clYellow;
Bmp.Canvas.Brush.Color := clYellow;
BMP.Canvas.Lock;
Bmp.Canvas.Rectangle(100, 100, W-100, H-100);
bmp.Canvas.Unlock;
Bmp.Canvas.Changed;
{ Png := TPortableNetworkGraphic.Create Obligatoire pour la prise en charge de la transparence.
TTLazIntfImage.Savetofile('test.png'); ne sauvegarde pas la transparence
}
Png := TPortableNetworkGraphic.Create;
try
lzimg := TLazIntfImage.Create(0, 0, [riqfRGB, riqfAlpha]);
try
lzimg.SetSize(W, H);
lzimg.LoadFromBitmap(Bmp.Handle,bmp.MaskHandle,W,H);
Bmp.free;
Png.LoadFromIntfImage(lzimg);
finally
lzimg.Free;
end;
Png.SaveToFile('test.png');
finally
Png.Free;
end;
finally
Image1.Picture.LoadFromFile('test.png');
end;
end;
end. |