Anyway (and this applies to all scripting code) if you don’t know if of a classes is loaded or not just use it. If it makes a “X is not defined” error then you need to bind it.
It doesn’t work in no way, and i understood where the problem is:
when i use the “draw” method, it returns a canvas and then i draw on it the bitmap. But it is still a canvas not an image object, and setBoxBackground accept only image…
Some other idea? Pierre Hébert what do you think about it?
< ![CDATA[
item.setBoxBackground(image,”nsf”[,true|false]);
]]>
< ![CDATA[
Lol, i inverted string and bitmap xD really thanks!
]]>
< ![CDATA[
OK, it doesn’t work. I guess it needs an image not a bitmap, right?
]]>
< ![CDATA[
Yes
]]>
< ![CDATA[
LL.createImage(width,height).draw().drawBitmap(bitmap,0,0,null)
]]>
< ![CDATA[
How can I convert a bitmap to an image object?
I create the bitmap using the createBitmap method, but before it was an image object (pickImage method).
]]>
< ![CDATA[
Loool, thou hast anticipated me! Impressive! Thanks again 🙂
]]>
< ![CDATA[
Still have problems, please don’t kill me 🙁
It’s better if I share directly the code here…
—————————–
//Class—————
LL.bindClass(“android.graphics.Bitmap”);
//header_var—————
var header=LL.getCurrentDesktop().getItemByName(“main”).getContainer().getItemByName(“pan_header”).getContainer().getItemByName(“header”);
var h_width=header.getWidth();
var h_height=header.getHeight();
//Image_creation—————
var img=LL.pickImage(0).getBitmap();
var img_width=img.getWidth();
var img_height=img.getHeight();
var scaled_width=img_width/(img_height/h_height);
Android.makeNewToast(scaled_width,true).show();
var img_scaled=Bitmap.createScaledBitmap(img,scaled_width,h_height,true);
var cut=(scaled_width/2)-(h_width/2);
var tmp_img=Bitmap.createBitmap(img_scaled,cut,0,h_width,h_height);
var h_img=LL.createImage(h_width,h_height).draw().drawBitmap(tmp_img,0,0,null)
img.recycle();
img_scaled.recycle();
tmp_img.recycle();
//header_set_box—————
var edit=header.getProperties().edit();
var h_box=edit.getBox(“i.box”);
header.setBoxBackground(h_img,”nsf”,true);
edit.commit();
h_img.recycle();
]]>
< ![CDATA[
In this case you have to do it in two steps : First create the image, then draw on it. Otherwise you can’t keep reference to the image.
]]>
< ![CDATA[
i have to include some other classes or draw method is included in LL api?
]]>
< ![CDATA[
It should be included I think.
Anyway (and this applies to all scripting code) if you don’t know if of a classes is loaded or not just use it. If it makes a “X is not defined” error then you need to bind it.
]]>
< ![CDATA[
It doesn’t work in no way, and i understood where the problem is:
when i use the “draw” method, it returns a canvas and then i draw on it the bitmap. But it is still a canvas not an image object, and setBoxBackground accept only image…
Some other idea? Pierre Hébert what do you think about it?
]]>
< ![CDATA[
Repeat: “In this case you have to do it in two steps : First create the image, then draw on it. Otherwise you can’t keep reference to the image.”
var img = LL.createImage(…
img.draw().drawBitmap(…
…setBoxBackground(img,…
]]>
< ![CDATA[
Lukas Morawietz I already did that, and it didn’t work.
Always appears the same alert: “Cannot find call method setBoxBackground(b.a.b.ej,string,boolean)”.
I already said why (in my opinion) it doesn’t work in my previous comment
]]>
< ![CDATA[
Code above works for me.
]]>
< ![CDATA[
Please post your current code. (or update above and tell)
]]>
< ![CDATA[
Lukas Morawietz you was right, it works perfectly.
I made a mistake:
var IMG_tmp=LL.createImage(…);
Var IMG=IMG_tmp.draw().drawBitmap(…);
Item.setBoxBackground(IMG…);
In this way I set as box background the canvas xD
SORRY for the misunderstanding and really really thanks for your help and patience… 🙂
How can I repay the lost time?
]]>