{ Converts image from TBaseImage instance to FMX bitmap. Bitmap must be already instantiated.}
procedure ConvertImageToFmxBitmap(Image: TBaseImage; Bitmap: TBitmap);
FImage.LoadMultiFromFile('E:\espulso.gif');
FmxImage.BeginUpdate;
try
ImagingFmx.ConvertImageToFmxBitmap(FImage, FmxImage.Bitmap);
finally
FmxImage.EndUpdate;
end;
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;
Page created in 0.014 seconds with 20 queries.