Made a program to
Make a Border Or Do a Crop (Do a Crop and Not Do a Crap, Ha Ha.)
Set the Border size with a TSpinedit or Set the Crop decrease in size with that same TSpinedit
Clicking on the filename in the TFilelistbox loads the picture file.
Works for Bmp, png, jpg BUT NOT GiF saved back to GIF, unless I convert the gif to png.Problem: Using FPWriteGIF from
https://www.gocher.me/FPWriteGIF gives an Access Violation Error when Adding a Border or Cropping a Gif file.
Not sure why FPWriteGIF is making the Access Violation Error and how do I get rid of that error.
I played around with some FPWriteGIF code
by KodeZerg and successfully converted from bmp to gif in another sample code shown below without any Access Violation Error, but I was unable to get rid of that error in my own Border/Cropping program.
I wonder if anyone can help out?Not sure if Bgrabmp might work better in opening and saving to different picture formats?
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
fpImage, fpWriteGif;
type
TMyGifImage = class(TGifImage)
protected
class function GetWriterClass: TFPCustomImageWriterClass; override;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
class function TMyGifImage.GetWriterClass: TFPCustomImageWriterClass;
begin
Result := TFPWriterGIF;
end;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
bmp: TBitmap;
gif: TMyGifImage;
begin
bmp := TBitmap.Create;
try
bmp.LoadfromFile('test.bmp');
gif := TMyGifImage.Create;
try
gif.Assign(bmp);
gif.SaveToFile('test.gif');
finally
gif.Free;
end;
finally
bmp.Free;
end;
end;
initialization
TPicture.RegisterFileFormat('.gif', 'gif', TMyGifImage);
end.