TBGRABitmap doesn't work for me on Ubuntu 10.04 with FPC 2.5.1 :
bgragtkbitmap.pas(41,17) Error: There is no method in an ancestor class to be overridden: "TBGRAGtkBitmap.Draw(TCanvas,LongInt,LongInt,Boolean="TRUE");"
bgragtkbitmap.pas(42,17) Error: There is no method in an ancestor class to be overridden: "TBGRAGtkBitmap.Draw(TCanvas,TRect,Boolean="TRUE");"
bgragtkbitmap.pas(48,1) Fatal: There were 2 errors compiling module, stopping
Hello, I wrote BGRABitmap. What is happening here is strange. I have tried it on both Linux and Windows.
Maybe you are using directly BGRAGtkBitmap instead of BGRABitmap. In the uses clause, you should put "bgrabitmap" and "bgrabitmaptypes", and then use the TBGRABitmap class.
Both procedures in th error messages seem well defined. In bgragktbitmap :
procedure Draw(ACanvas: TCanvas; x,y: integer; Opaque: boolean= True); override;
procedure Draw(ACanvas: TCanvas; Rect: TRect; Opaque: boolean= True); override;
And in bgradefaultbitmap :
procedure Draw(ACanvas: TCanvas; x,y: integer; Opaque: boolean= True); virtual;
procedure Draw(ACanvas: TCanvas; Rect: TRect; Opaque: boolean= True); virtual;
Does someone else have this problem on Linux ?
uses ..., Graphics, BGRABitmapTypes, BGRABitmap;
procedure MergeImages(FirstFileName, SecondFileName, CombinedFileName: string);
var
First: TBGRABitmap;
Second: TBGRABitmap;
begin
Second := TBGRABitmap.Create(SecondFileName);
First := TBGRABitmap.Create(FirstFileName);
First.Bitmap.Canvas.CopyRect(
Rect(0, 0, First.Width, First.Height),
Second.Bitmap.Canvas,
Rect(0, 0, Second.Width, Second.Height)
);
First.SaveToFile(CombinedFileName);
First.Destroy;
Second.Destroy;
end;
MergeImages('First.png', 'Second.png', 'Combined.png');
This is not the best way. You should write instead :
uses ..., Graphics, bgrabitmaptypes, bgrabitmap;
procedure MergeImages(FirstFileName, SecondFileName, CombinedFileName: string);
var
First: TBGRABitmap;
Second, SecondResample: TBGRABitmap;
begin
First := TBGRABitmap.Create(FirstFileName);
Second := TBGRABitmap.Create(SecondFileName);
SecondResample := Second.Resample(First.Width,First.Height) as TBGRABitmap; //fine resample
Second.Free;
First.PutImage(0,0, SecondResample, dmDrawWithTransparency); //fast putimage
SecondResample.Free;
First.SaveToFile(CombinedFileName);
First.Free;
end;
MergeImages('First.png', 'Second.png', 'Combined.png');