Adding PNG icons to Addons

Hi

Some time ago Campbell released this video - http://www.youtube.com/watch?v=mRiTfLpRlRU , and later wrote:

You can use OpenGL to draw pretty much anything, graphics - images etc.
Though this isn’t the main goal of py-buttons to draw graphics, its possible.

and it was in response to my question about adding icons to addons. So - anyone maybe knows if it really is possible? I am aware that icons are stored in a single png in Blender, that you can modify when building, but the question is about adding them to addons.

you can use the built-in icons with python like layout.label(…, icon=‘ZOOMIN’) or other UI elements that support icons.

If you wanted to draw them over the 3d view (draw handler), you would have to include the icon png, load it as blender image datablock or into bgl buffer and draw parts of it. See the Pie menus addon, it does this kind of stuff.

There’s unfortunately no function to retrieve the icon pixels as a buffer, or some way to get access to the icon texture sprite bound by C code to an opengl texture in python :frowning:
(should be like bpy.types.UILayout.icon_data(…))