I must be doing something wrong. Using the lazarus method (if as the wiki said I can use the precompiled RES and RC formats from Delphi I would love to see example code in Lazars loading a PNG res)
I first built the lrs file using the syntax
C:\code\Lazarus\Resource Test>c:\lazarus\tools\lazres.exe images.lrs logo.png
logo.png ResourceName='logo' Type='PNG'
The lrs file has this format
LazarusResources.Add('logo','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#1#144#0#0#0#254#8#2#0#0#0#155'T'#196
+#5#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#4'gAMA'#0#0#177#142
+'|'#251'Q'#147#0#0#0' cHRM'#0#0'z%'#0#0#128#131#0#0#249#255#0#0#128#233#0#0
+'u0'#0#0#234'`'#0#0':'#152#0#0#23'o'#146'_'#197'F'#0#3'V'#28'IDATx'#218'TS'
+#203'n'#28'E'#20#173'g?gz'#30'=c;'#227'ql'#136#29#147'Hq,!$X'#177'd'#143#196
+#142'5'#27#190#137#29'[$~ '#192#2#1#18'B d'#130'B'#28#219'!'#142#205'x'#30'='
+'='#253#174'''w'#28'6'#148'Z'#173'['#183'n'#157':u'#207')'#252#233#231'G'#171
Here is the simplest code I can test it with. Single form with a single image on it.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{$i images.lrs}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var png:TPortableNetworkGraphic;
begin
png:=TPortableNetworkGraphic.Create;
try
Png.LoadFromLazarusResource('logo');
Image1.Canvas.Draw(0,0,Png);
finally
Png.Free;
end;
end;
end.
Now when I try and run the app I get the images.lrs shwoing with this error
images.lrs(1,1) Fatal: Syntax error, "BEGIN" expected but "identifier LAZARUSRESOURCES" found
That was using {$i images.lrs}. If I use {$r images.lrs} I get
windres: C:/code/Lazarus/RESOUR~1/images.lrs:1: syntax error
after the compiler or windres tries to compile the lrs file
Any other ideas? Ideally I would like to use the existing Delphi compiled res file as is supposedly supported, but even getting the lrs method working would be good now.