Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-02

lazarus resources

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Everton Vieira

I`ve make a very easy lazarus resource file, is annexed: -------------- next part --------------
A non-text attachment was scrubbed...
Name: unEdit_Add_Rem.lrs
Type: application/octet-stream
Size: 21633 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120207/b076dbaa/attachment-0001.obj> -------------- next part --------------
, with two png files insides, and i`m using like this:

btnAdd.Glyph.LoadFromLazarusResource('edit_add');
initialization
  {$I unEdit_Add_Rem.lrs}

Generates this error:

Exception Class: EInvalidGraphic
With the Message: TGlyphBitmap: Unsupported Resourcetype: PNG Resource Name: edit_add

Stack Trace:
00 - 0046C8E0 TGRAPHIC__LOADFROMLAZARUSRESOURCE, line 263 of ./include/graphic.inc. 01 - 00430940 TFMFILTRAR__BTNADDCLICK, line 246 of unFiltrar.pas. 02 - 004F0754 TCONTROL__CLICK, line 2288 of ./include/control.inc. 03 - 00531C21 TCUSTOMSPEEDBUTTON__CLICK, line 117 of ./include/speedbutton.inc. 04 - 005332E5 TCUSTOMSPEEDBUTTON__WMLBUTTONUP, line 799 of ./include/speedbutton.inc. 05 - 0040B8BA , line 9423 of .
06 - 004EE948 TCONTROL__PERFORM, line 1083 of ./include/control.inc. 07 - 004E4C62 TWINCONTROL__ISCONTROLMOUSEMSG, line 4606 of ./include/wincontrol.inc. 08 - 004E5EE9 TWINCONTROL__WNDPROC, line 5206 of ./include/wincontrol.inc. 09 - 00419F4E TCUSTOMFORM__WNDPROC, line 1362 of ./include/customform.inc. 10 - 00561867 DELIVERMESSAGE, line 110 of lclmessageglue.pas. 11 - 0050CFEE WINDOWPROC, line 2441 of win32callback.inc. 12 - 0059913F CUSTOMFORMWNDPROC, line 357 of win32wsforms.pp. 13 - 77D28709 , line 0 of .
14 - 77D287EB , line 0 of .
15 - 77D289A5 , line 0 of .
16 - 77D289E8 , line 0 of .

I tough TSpeedButton could read png images.

Any suggestions?

Reply by email

Felipe Monteiro de Carvalho
to Everton Vieira

Each class can only read 1 format.

btnAdd.Glyph is a TBitmap and therefore reads only bitmaps. But you can first read to a PNG and then use Assign to convert to a bitmap.

Try doing it like this:

var
  MyPNG: TPortableNetworkGraphic;
begin
  MyPNG := TPortableNetworkGraphic;
  MyPNG.LoadFromLazarusResource('edit_add');
  btnAdd.Glyph.Assign(MyPNG);
  MyPNG.Free;
Felipe Monteiro de Carvalho

Reply by email

Everton Vieira
to Felipe Monteiro de Carvalho

Thanks!

Felipe Monteiro de Carvalho wrote 23 lines
Each class can only read 1 format. btnAdd.Glyph is a TBitmap and therefore reads only bitmaps. But you can first read to a PNG and then use Assign to convert to a bitmap. Try doing it like this: var MyPNG: TPortableNetworkGraphic; begin MyPNG := TPortableNetworkGraphic; MyPNG.LoadFromLazarusResource('edit_add'); btnAdd.Glyph.Assign(MyPNG); MyPNG.Free; -- Felipe Monteiro de Carvalho -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email