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
| Procedure TGIFViewer.RenderFrame(Index: Integer);
Var
Src: TFastBitmap;
pTop, pLeft: Integer;
iDrawMode: TFastBitmapDrawMode;
TmpBmp : Graphics.TBitmap;
Begin
Src := FGIFLoader.Frames.Items[Index].Bitmap;
pLeft := FGIFLoader.Frames.Items[Index].Left;
pTop := FGIFLoader.Frames.Items[Index].Top;
FRenderCache.AddNewCache;
FRenderCache.Items[Index].Delay := FGIFLoader.Frames[Index].Delay;
If Index = 0 Then
Begin
If (FTransparent) Then
Begin
FVirtualView.Clear(clrTransparent);
iDrawMode := dmAlphaCheck;
End
Else
Begin
FVirtualView.Clear(FGIFLoader.BackgroundColor);
iDrawMode := dmSet;
End;
FVirtualView.PutImage(Src, 0, 0, Src.Width, Src.Height, pLeft, pTop, dmSet);
FRestoreBitmap := FVirtualView.Clone;
End
Else
Begin
With FGIFLoader.Frames.Items[Index] Do
Begin
Case DrawMode Of
dmNone:
Begin
FVirtualView.PutImage(Src, 0, 0, Src.Width, Src.Height, pLeft, pTop, iDrawMode);
End;
dmKeep:
Begin
FVirtualView.PutImage(Src, 0, 0, Src.Width, Src.Height, pLeft, pTop, iDrawMode);
If Assigned(FRestoreBitmap) Then FreeAndNil(FRestoreBitmap);
FRestoreBitmap := FVirtualView.Clone;
End;
dmErase:
Begin
If (FGIFLoader.Frames.Items[Index].IsTransparent And FTransparent) Then FVirtualView.Clear(clrTransparent)
Else
FVirtualView.Clear(FGIFLoader.BackgroundColor);
FVirtualView.PutImage(Src, 0, 0, Src.Width, Src.Height, pLeft, pTop, iDrawMode);
End;
dmRestore:
Begin
FVirtualView.PutImage(FRestoreBitmap, 0, 0, FRestoreBitmap.Width, FRestoreBitmap.Height, 0, 0, dmSet);
FVirtualView.PutImage(Src, 0, 0, Src.Width, Src.Height, pLeft, pTop, iDrawMode);
End;
Else
FVirtualView.PutImage(Src, 0, 0, Src.Width, Src.Height, pLeft, pTop, dmSet);
End;
End;
End;
// Note : Sous MacOS on ne peux pas assigner FRenderCache.Items[Index].Bitmap directement avec
// FVirtualView.GetBitmap; On est obligé de créer le bitmap de destination et utiliser Assign.
// Dans le cas contraire seulment la première image sera affichée.
TmpBmp := Graphics.TBitmap.Create;
TmpBmp := FVirtualView.GetBitmap;
FRenderCache.Items[Index].Bitmap.Assign(TmpBmp);
FreeAndNil(TmpBmp);
If FGIFLoader.FFrames[Index].Delay <> 0 Then FAnimateTimer.Interval := FGIFLoader.FFrames[Index].Delay * FAnimateSpeed;
End; |