Page 1 of 1

Icon serialize

Posted: Fri Mar 27, 2009 7:53 pm
by atz6975
Hi,
could someone tell me how to create the serialized string of a plugin icon?
I would like to add one for my new plugin.
Thank you.

Re: Icon serialize

Posted: Sat Mar 28, 2009 3:23 pm
by jinxdone
Make a 16x16 24bpp png file of the icon, then you can to convert it into base64 form, or you could also leave it as a file and just put the file name in your plugin icon property.

The base64 functions are available in a default python installation, you could make a little script that converts a given file into base64. Or you can use an online converter like this one; just input the image in the file box and hit convert.
http://www.motobit.com/util/base64-decoder-encoder.asp

Finally insert the base64 encoded icon file in the icon property, look for examples in the other plugins that have icons in them.

Hope this helped! :)

-jinxdone

Re: Icon serialize

Posted: Sat Mar 28, 2009 7:13 pm
by Pako
Try this script from Bitmonster:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="884">
    <Macro Name="Convert PNG to Python" Expanded="True">
        <Action Name="Convert PNG to Python">
            EventGhost.PythonScript(u'import base64\nimport wx\n\ndef Main():\n    dialog = wx.FileDialog(None, wildcard="PNG files (*.png)|*.png")\n    dialog.ShowModal()\n    filePath = dialog.GetPath()\n    dialog.Destroy()\n    if not filePath:\n        return\n    \n    fd = open(filePath, "rb")\n    data = base64.b64encode(fd.read())\n    fd.close()\n\n    s = "    icon = (\\n"\n    while len(data) > 68:\n        s += \'        "\' + data[:68] + \'"\\n\'\n        data = data[68:]\n    s += \'        "\' + data + \'"\\n\'\n    s += "    )\\n"\n            \n    eg.result = s\n\n\neg.CallWait(Main)\n\n')
        </Action>
        <Action>
            System.SetClipboard(u'{eg.result}')
        </Action>
    </Macro>
</EventGhost>
Found here:http://www.eventghost.org/forum/viewtopic.php?f=1&t=245
Pako

Re: Icon serialize

Posted: Sat Mar 28, 2009 10:21 pm
by atz6975
Will try, thanks.

Re: Icon serialize

Posted: Tue Apr 14, 2009 2:10 pm
by atz6975
It doesnt like my png...Any specs for png format? I tried 16x16x24 but no luck.

Re: Icon serialize

Posted: Tue Apr 14, 2009 3:00 pm
by jinxdone
You could open one of the existing .png icons that come with EG with your image editing program, for example \EventGhost\plugins\TechnoTrendIr\icon.png. I hope you can pick the correct properties for the image that way. I didn't have any problems creating icons though using GIMP.

Does the image show up in EG if you save the icon as icon.png file in the same directory as the plugin? If that is working ok then the image file itself should be fine.

Re: Icon serialize

Posted: Tue Apr 14, 2009 4:12 pm
by Bitmonster
It must have an alpha channel, so it needs to have 32bits depth.

Re: Icon serialize

Posted: Wed Apr 15, 2009 7:08 am
by jinxdone
Yep.. Sorry! That one was my mistake. The image has to be with alpha channel as well.

Thanks for correcting me Bitmonster.