GetIconTagList() not working on MorphOS?
  • Order of the Butterfly
    Order of the Butterfly
    ChrisH
    Posts: 167 from 2009/11/26
    If I use GetIconTagList() on any icon, then on AROS & OS4 it returns a nice object for me, but on MorphOS it always seems to fail (return NULL). I've tried changing various parameters, without luck.

    Has anyone successfully used GetIconTagList()?
    Author of the PortablE programming language.
    It is pitch black. You are likely to be eaten by a grue...
  • »09.01.13 - 15:38
    Profile Visit Website
  • MorphOS Developer
    Piru
    Posts: 588 from 2003/2/24
    From: finland, the l...
    icon.library provided by ambient is merely a simple wrapper to accommodate for most needs of an application.

    You can check the implementation here:
    http://morphosambient.cvs.sourceforge.net/viewvc/morphosambient/ambient/iconlib/private.c?revision=1.13&view=markup

    As you can see it's rather basic, just calling GetDiskObject for the name pretty much.
  • »09.01.13 - 16:20
    Profile
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    You can use following tags to get icon image with GetIconTagList():

    ICONGETA_PNGBitMap 256
    ICONGETA_PNGBitMap_Width 257
    ICONGETA_PNGBitMap_Height 258

    They are semi official (i.e. not found from the SDK) but since Ambient is open source they are public tags.

    struct BitMap *bm;
    ULONG w, h;

    APTR diskobj = GetIconTags("foobargame", ICONGETA_PNGBitMap, &bm,
    ICONGETA_PNGBitMap_Width, &w, ICONGETA_PNGBitMap_Height, &h, TAG_DONE);

    Icon bitmap is valid until you destroy returned disk object. If retrieved icon is not a PNG icon then bitmap pointer is NULL and you can use old style planar bitmap from returned disk object.

    Internally GetIconTagList() is calling GetDiskObject() and it should return something (if icon exists, that is)...
    1 + 1 = 3 with very large values of 1
  • »09.01.13 - 18:11
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    ChrisH
    Posts: 167 from 2009/11/26
    @itix Quote:

    you can use old style planar bitmap from returned disk object

    Would I have to somehow use the "do_Gadget" member to access this "old style bitmap"?
    Author of the PortablE programming language.
    It is pitch black. You are likely to be eaten by a grue...
  • »13.01.13 - 10:07
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    Yes you would have to. It is probably easier just provide some placeholder than start parsing GadgetRender data. Certainly I wouldnt.
    1 + 1 = 3 with very large values of 1
  • »13.01.13 - 10:16
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    ChrisH
    Posts: 167 from 2009/11/26
    @Itix (and Piru!)
    Thanks for your hints. I've got PNG icons loading nicely (after handling the alpha mask).

    I've also kind of got non-PNG (old style planar) icons loading, but anything above about 3 bitplanes looks horrible, presumably due to the lack of a proper palette. Any idea where that would be specified in the icon?

    (I guess an alternative to reading the planar data would be to attach the gadget to a window, which should cause the gadget to render itself, then we can copy the result into a bitmap... but this means that a small window will temporarily open each time an icon is read. Not ideal.)
    Author of the PortablE programming language.
    It is pitch black. You are likely to be eaten by a grue...
  • »14.01.13 - 20:23
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    ChrisH
    Posts: 167 from 2009/11/26
    I wrote: Quote:

    I guess an alternative to reading the planar data would be to attach the gadget to a window, which should cause the gadget to render itself, then we can copy the result into a bitmap...

    I tried this idea, and it actually worked on AmigaOS... but just crashes the whole machine on MorphOS, so I guess I'm trying to use some stuff which was never fully implemented on MorphOS?

    So it seems I need to go back to my earlier method... and somehow extract the icon's palette (but I have no idea where it is stored).
    Author of the PortablE programming language.
    It is pitch black. You are likely to be eaten by a grue...
  • »15.01.13 - 10:12
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    ChrisH
    Posts: 167 from 2009/11/26
    I wrote:Quote:

    I've also kind of got non-PNG (old style planar) icons loading, but anything above about 3 bitplanes looks horrible, presumably due to the lack of a proper palette. Any idea where that would be specified in the icon?

    I should add that this is for high-colour icons from OS4.

    I just tested my code on OS4, and somehow it (usually) gives the right result on OS4. So perhaps this is something else which simply isn't implemented on MorphOS? Although somehow Ambient still manages to display high-colour icons from OS4!
    Author of the PortablE programming language.
    It is pitch black. You are likely to be eaten by a grue...
  • »15.01.13 - 10:48
    Profile Visit Website