Is there any way to duplicate(make a copy) of a ‘Image’?
Is there any way to duplicate(make a copy) of a ‘Image’? For example if you want to take the background picture of an item, modify it and set it to another one, if you just use seticon(geticon()) the image is shared so the original one is also modified.
I tried duplicating the bitmap, the canvas…but I couldn’t find the right combination.
This is also a suggestion to a Image Image.copy(Image src) or similar
Another question: Bitmap class is available, or at least their functions. However static functions can’t be launched from Bitmap.copy(…), it throws a ‘Bitmap not defined’ error. However calling them from another bitmap works, even thought that bitmap is not used.
Is there something I’m missing? Is there any reason for this?
]]>
< ![CDATA[
In theory it should be possible to duplicate an image this way (not tested):
var img_orig =;
var bmp_orig = img_orig.getBitmap();
var img_copy = LL.createImage(bmp_orig.getWidth(), bmp_orig.getHeight());
img_copy.draw().drawBitmap(bmp_orig, 0, 0, null);
Whell, in fact the Bitmap class is not directly available. Bitmap objects returned are available, but the prototype isn’t. I will update this in the next release.
]]>
< ![CDATA[
Pierre Hébert welcome back from holiday (i guess). While your at bitmap… API-doc mentions PorterDuff but something missing there too. At least, I could not get it to work. And I have some plans with my colored app-drawer script.
]]>
< ![CDATA[
Jappie Toutenhoofd vacations ? Well, sort of… Never really in vacations nor fully at work !
Anyway porter duff operations are critical to achieve some good stuff. I will have a look at this too.
]]>
< ![CDATA[
Sorry for the delay, I was testing and has issues with another part of the code.
The code works great, and it’s easy to put it in a function.
Thanks.
(I know it’s not really necessary…but will you add it as Image.copy() perhaps? Just asking)
]]>
< ![CDATA[
If Bitmap.copy works, is Image.copy needed too ? I am wondering whether this could have deeper implications and / or different use cases.
]]>
< ![CDATA[
A different use will be to copy nine patches, however we can’t edit them now so…
It’s true that it’s not strictly necessary, but will allow easier scripts when copying icons or backgrounds with modifications
Just asking
]]>