On 28/04/2017 at 08:41, xxxxxxxx wrote:
Originally posted by xxxxxxxx
at what point does our documentation give the impression you could use GetIcon() to change the icon of for example Null objects? We'd need to clarify this, as you can't.
Even if it's bad and I really discourage to use it in production since it can literally kill the UI and user don't really like that !
But you can do it
#Func by niklas
def set_icon(pluginid, bmp, overwrite_alpha=True) :
icon = c4d.gui.GetIcon(pluginid)
if not icon:
return c4d.gui.RegisterIcon(pluginid, bmp)
ref = icon['bmp']
w, h = icon['w'], icon['h']
temp = c4d.bitmaps.BaseBitmap()
if temp.Init(w, h, bmp.GetBt()) != c4d.IMAGERESULT_OK:
bmp.ScaleIt(temp, 256, True, True)
a1 = a2 = None
a1 = ref.GetInternalChannel()
a2 = temp.GetInternalChannel()
for x in xrange(w) :
rx = x + icon['x']
for y in xrange(h) :
ry = y + icon['y']
ref[rx, ry] = temp[x, y]
alpha = temp.GetAlphaPixel(a2, x, y)
alpha = 255
ref.SetAlphaPixel(a1, rx, ry, alpha)
def main() :
fn = c4d.storage.LoadDialog()
if not fn: return
bmp = c4d.bitmaps.BaseBitmap()
res = bmp.InitWith(fn)
if res != c4d.IMAGERESULT_OK:
But again avoid this !!!
But it can be a lazy method for modifing your icon of your plugin.
For more detail have a look at my tutorial here https://vimeo.com/190940660 (it's in french)
Another thing take a look at this plugin which can be a kind of what you want.