Can anyone help to tweek the fpwritegif unit? Get Access Violation ErrorI tried using the fpwritegif.pas unit provided to try to make a 3 frame animation test but I get 2 errors when compiling and a Access Violation Error when running the exe.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, BGRAAnimatedGif,
BGRAGraphicControl, FPWriteGIF, BGRABitmap, BGRABitmapTypes;
type
{ TForm1 }
TForm1 = class(TForm)
BGRAGraphicControl1: TBGRAGraphicControl;
bnConvert: TButton;
procedure bnConvertClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.bnConvertClick(Sender: TObject);
var
img: TBGRABitmap;
gif: TBGRAAnimatedGif;
i, delayms: integer;
ms: TMemoryStream;
gifw: TFPWriterGIF;
begin
delayms := 100;
gif := TBGRAAnimatedGif.Create;
gif.SetSize(709, 709);
gif.LoopCount := 0; //endless loop
ms := TMemoryStream.Create;
gifw := TFPWriterGIF.Create;
for i := 0 to 2 do
begin
img := TBGRABitmap.Create(Format('frame%d.png', [i]));
//save as gif with fpwritergif
img.SaveToStream(ms, gifw);
ms.Position := 0;
img.Free;
img := TBGRABitmap.Create(ms);
//add frame
gif.AddFullFrame(img, delayms);
img.Free;
ms.Clear;
end;
gifw.Free;
ms.Free;
gif.OptimizeFrames;
gif.SaveToFile('sample-ani-2.gif'); //save to file
gif.Free; //clean
end;
end.
QArr and CT are not initialsed are the 2 errors
QArr is a QuadArray and CT is a Color Table
They are both declared in the var section but I am struggling to find how to initialize them.
Tried doing
QArr := nil; but as QArr is TRGBQuadArray256 I get another message saying got Pointer expecting.
Tried doing
QArr[brackets i].r := Nil ; then got i was not initialised
I put brackets word here as web page gets rid of brackets i
Going round in circles.
Thanks in advance.