procedure TFormMain.SaveAsGIF1Click(Sender: TObject);
// Create an animated gif from the layers in a TImageEnVect (TimageEnView) accounting for zoom
var
  i: integer;
  iFilename: string;
  iIEBitmap: TIEBitmap;
  iIndex: integer;
  iImageEnMView: TImageEnMView;
  iWidth: integer;
  iHeight: integer;
  iFrames: integer;
begin
  iFilename := 'anim.gif';
  // Create TImageEnMView to save the multiframe file
  iImageEnMView := TImageEnMView.Create(nil);
  try
    for i := 0 to ImageEnVect1.LayersCount - 1 do
    begin
      // Get the zoomed image dimensions-Get the width of the area used to show current image.
      iWidth := ImageEnVect1.ExtentX;
      // Get the height of the area used to show the current image.
      iHeight := ImageEnVect1.ExtentY;
      // Create the TIEBitmap to hold the image from a layer
      iIEBitmap := TIEBitmap.Create(iWidth, iHeight, ie24RGB);
      try
        // Copy the layers IEBitmap to iIEBitmap
        // This is a cropped and zoomed image which should be similar to the zoomed image on the screen
        ImageEnVect1.Layers[i].Bitmap.RenderToCanvasWithAlpha(iIEBitmap.Canvas, 0, 0, iWidth, iHeight, 0, 0, iWidth, iHeight,
          255, rfNone);
        // AppendImage appends a new image at last position in the list and returns the new image position
        iIndex := iImageEnMView.AppendImage;
        // Set the TIEBitmap to the iImageEnMView frame
        iImageEnMView.SetIEBitmap(iIndex, iIEBitmap);
        // Set the Gif's image index
        iImageEnMView.MIO.Params[i].GIF_ImageIndex := iIndex;
        // Free the Bitmap
        iImageEnMView.ReleaseBitmap(i);
      finally
        iIEBitmap.Free;
      end;
    end;
  // Save the animated multiframe GIF file.
  iImageEnMView.MIO.SaveToFileGIF(iFilename);
  finally;
    iImageEnMView.Free;
  end;
    iFrames := IEGetFileFramesCount(iFilename);
  MessageBox(0, PWideChar(IntToStr(iFrames) +
    ' frames were added to the GIF file and the file was saved as ' + iFilename + '.'), '',
    MB_ICONINFORMATION or MB_OK);
end;
William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html