Post reply

Name
Email
Subject
Message icon                                  
Attach:
(Clear Attachment)
(more attachments)
Restrictions: 6 per post, maximum total size 4096KB, maximum individual size 2048KB
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
Enter or copy Vampyre Imaging Library as an verification (we ge a lot of registration spam):

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: salvok5
« on: 22 December 2012, 15:50:26 »

On delphi XE3 the "ImagingFmx.pas" by 4 error.
Posted by: Galfar
« on: 22 December 2012, 04:07:28 »

Have you checked ImagingFmx.pas unit?
It has a functions like:
Code: Pascal
  1. { Converts image from TBaseImage instance to FMX bitmap. Bitmap must be already instantiated.}
  2. procedure ConvertImageToFmxBitmap(Image: TBaseImage; Bitmap: TBitmap);
that can directly convert from Imaging image to FMX bitmap (for FMX1 in XE2 only though).

Resaving image as GIF and loading it to FMX bitmap is a bad idea, you lose the alpha channel.
And it seems to me that you will only have the last frame in FMX image after this code is run.

Try something like this first:
Code: Pascal
  1. FImage.LoadMultiFromFile('E:\espulso.gif');
  2. FmxImage.BeginUpdate;
  3. try
  4.   ImagingFmx.ConvertImageToFmxBitmap(FImage, FmxImage.Bitmap);
  5. finally
  6.   FmxImage.EndUpdate;
  7. end;
  8.  
 
Posted by: salvok5
« on: 20 December 2012, 17:25:05 »

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.

Code: Pascal
  1. procedure TForm5.Button1Click(Sender: TObject);
  2. var
  3.   I,y,x: LongInt;
  4.   T: Int64;
  5.   io:Tmemorystream;
  6.   Dest, Src: PByte;
  7.   Alpha: Byte;
  8. begin
  9.     try
  10.       FImage := TMultiImage.Create;
  11.       FImage2 := TMultiImage.Create;
  12.  
  13.       // Load all subimages in file
  14.       T := ImagingUtility.GetTimeMicroseconds;
  15.       FImage.LoadMultiFromFile('E:\espulso.gif');
  16.       FImage2.LoadMultiFromFile('E:\espulso.gif');
  17.  
  18.       for I := 0 to FImage.ImageCount - 1 do
  19.       begin
  20.         FImage.ActiveImage := I;
  21.         if not (FImage.Format in TImagingCanvas.GetSupportedFormats) then
  22.           FImage.Format := ifA8R8G8B8;
  23.         for Y := 0 to Height - 1 do
  24.         begin
  25.           Src := FImage.Scanline[y];
  26.           Dest := FImage2.ScanLine[y];
  27.           for X := 0 to Width - 1 do
  28.           begin
  29.             Alpha := Src[X * 4 + 3];
  30.             Dest[X * 4 + 0] := Src[x * 4 + 0] * Alpha div 255;
  31.             Dest[X * 4 + 1] := Src[x * 4 + 1] * Alpha div 255;
  32.             Dest[X * 4 + 2] := Src[x * 4 + 2] * Alpha div 255;
  33.             Dest[X * 4 + 3] := Alpha;
  34.           end;
  35.         end;
  36.         io:=Tmemorystream.Create;
  37.         FImage2.SaveToStream('gif',io);
  38.         image1.Bitmap.LoadFromStream(io);
  39.         ............
  40.         break;
  41.  
  42.       end;
  43.       // Activate first image and update UI
  44.       FImage.ActiveImage := 0;
  45.     except
  46.       raise;
  47.     end;
  48.  
  49. end;