I'm trying to convert a frame of animated gif file to "FMX TImage".
The problem with this code is that there is no transparency in the alpha channel does not work.
Sorry for my bad inghlese.
The problem with this code is that there is no transparency in the alpha channel does not work.
Sorry for my bad inghlese.
Code (pascal) Select
procedure TForm5.Button1Click(Sender: TObject);
var
I,y,x: LongInt;
T: Int64;
io:Tmemorystream;
Dest, Src: PByte;
Alpha: Byte;
begin
try
FImage := TMultiImage.Create;
FImage2 := TMultiImage.Create;
// Load all subimages in file
T := ImagingUtility.GetTimeMicroseconds;
FImage.LoadMultiFromFile('E:\espulso.gif');
FImage2.LoadMultiFromFile('E:\espulso.gif');
for I := 0 to FImage.ImageCount - 1 do
begin
FImage.ActiveImage := I;
if not (FImage.Format in TImagingCanvas.GetSupportedFormats) then
FImage.Format := ifA8R8G8B8;
for Y := 0 to Height - 1 do
begin
Src := FImage.Scanline[y];
Dest := FImage2.ScanLine[y];
for X := 0 to Width - 1 do
begin
Alpha := Src[X * 4 + 3];
Dest[X * 4 + 0] := Src[x * 4 + 0] * Alpha div 255;
Dest[X * 4 + 1] := Src[x * 4 + 1] * Alpha div 255;
Dest[X * 4 + 2] := Src[x * 4 + 2] * Alpha div 255;
Dest[X * 4 + 3] := Alpha;
end;
end;
io:=Tmemorystream.Create;
FImage2.SaveToStream('gif',io);
image1.Bitmap.LoadFromStream(io);
............
break;
end;
// Activate first image and update UI
FImage.ActiveImage := 0;
except
raise;
end;
end;