Question about an unexpected behaviour.
Question about an unexpected behaviour.
Why the ‘image’ of an item (the setImage()) is always displayed with a size of 100×100?
If I run this script:
var i=LL.getEvent().getItem();
var im=LL.createImage(400,400);
var p=new Paint();
p.setColor(Color.RED);
im.draw().drawRect(50,50,350,350,p);
i.setImage(im);
What I expected is to display the image of the item with a red box in the middle.
But instead it shows part of the red box on the bottom left corner (concretely, the 100×100 top left part of the full image)
It happens the same with a smaller picture, in this case it is showed at the top left part.
Is this a bug? An unexpected behaviour? (A problem of my device/layout? )
It is easy to apply a scale before drawing, but I wanted to ask.
Also, is it always 100×100?
]]>
< ![CDATA[
I believe 100×100 is your final icon size, hence any larger image will be cropped. This is different for the icon: it is scaled to scale the icon size, but the final image is always displayed at a 1:1 ratio.
You can use the background to get a larger surface, but you need to take into account the item width to compute the scale matrix, or apply a matrix on the canvas for the image too. (in the clock sample there is the code for the canvas transformation matrix)
]]>
< ![CDATA[
I have a similar “problem”.
I was able to apply the Ren Shore scripts, even if I used the TrianguloY variation taken by its “material template” he posted here some months ago. I’m speaking about the hamburger menu morphin in an arrow:
https://plus.google.com/103259407078462677041/posts/GvymLfQGABU
Now, quite everything works prefectly, however I’m using a Tab S 8.4, screen resolution is 2560×1600, and I’m working on a 16×10 grid so every cell element has a 160×160 dimension.
In such situation, the resulting icon is always top left aligned, and changing dimensions in createImage method didn’t change anything for me (I was thinking to use 160×160).
My scope is simply to center the resulting “icon” instead to be at top left, and to eventually scale it.
Is it exactly the same problem?
]]>
< ![CDATA[
Francesco D’Agostino I think your case is different.
You can use the boxbackground, which will have exactly that size.
The icon is a smaller part of a item, and I need to use it.
Pierre Hébert my question was if that size is always 100 (without scale changes from the item settings) and if not how can I get it, because retrieving the current image and checking it’s size don’t work, it’s size is the one from the real image (in fact the image is fully saved, but it is only shown the 100×100 top left part in my case.
(Will I need to access the image view and get it’s size? )
]]>
< ![CDATA[
Hum, I am missing something here…
The size is not always 100, it depends on several factors: the default launcher icon size, usually something like 72, 96, 144px, the icon scale and whether reflection is enabled.
What do you mean by “retrieving the current image and checking it’s size don’t work”? This size is then used to draw an IconView (a kind of ImageView but without scaling). If you assign a larger bitmap to this IconView, it is displayed at 0x0 with a 1x scale, hence the remaining part of your 400×400 image is hidden. Does it explain the issue?
]]>
< ![CDATA[
Pierre Hébert yes, that explains it.
So, my question:
How can I know the size of the final visible part of the image? So that I can draw above it knowing exactly where to draw.
]]>
< ![CDATA[
This should be the width and height of the image returned by getImage.
]]>
< ![CDATA[
Pierre Hébert that’s what I said: it is not.
The returned image has the size of the original image, in my case 400×400
]]>
< ![CDATA[
Does it return the same size right after an app reload? Once it has been assigned a new image it will use it as is (no scale), and subsequent calls to getImage will return it unchanged, with the same new size, but the view will still keep its original size, not matter what the size of the bitmap is.
]]>
< ![CDATA[
Sorry if I’m a bit off-topic, however I was able to change the “hamburger menu” only drawing in a different ways the hamburger lines…
Instead of:
[30,39,70,39]
[30,50,70,50]
[30,61,70,61]
I used:
[60,15,0,15]
[60,30,0,30]
[60,45,0,60]
Now “hamburger” is perfect for me but I’ve sincerely missed the logic why worked in this way… For this reason I’m not able to draw a correct back arrow, have you some suggestion?
]]>
< ![CDATA[
Pierre Hébert aha! That was the problem 😛
Thanks
Francesco D’Agostino not really sure what your problem is. If you want, make a new post describing it (maybe also with a video if possible) and we will try to help you better than here
]]>
< ![CDATA[
TrianguloY Thank you, I’ve solved by myself 🙂
However my question was enough pertinent, considering I still feel quite a noob in LL.
Initially I tought I could visually modify what I was drawing by script (it’s an icon after all) changing some properties related to item like scale, internal scale, alignment, etc.
Those works if you choose as an icon a normal bitmap, but if you draw it by script, you have necessarily to change the coordinates inside the script.
This wasn’t clear for me until I didn’t tried.
However, I think it’s a normal acknowledgement process, try, fail and try until you don’t see by yourself what happen 🙂
Thanks again for your support!
]]>