-
• #2
Hi! You've got the right idea with
frame
- actually changing the image height is a really neat idea to produce the data file!But I think you figured the issue out yourself.
frame
works by skipping forward that number of images - but it assumed they're one after the other - but as blocks of bytes. So if one image isn't exactly a byte long, there will be one or two unused bits between them.I think the behaviour of Espruino there is probably ok - it could get tricky for it if it has to start an image halfway through a byte - but we could definitely improve the tools.
My intention was to allow the Image Converter to take an animated gif, but that seemed a bit tricky and for what you're doing a bit long image works ok. Maybe we could make the converter have an extra option for
frames in image
and then it would automatically set the height and add the relevant padding.... and just FYI you could store the image as 2bpp 10x10 and it'd still be byte aligned, so that could be an option to use it as-is. With 2bpp you at least get the ability to have black+white+transparent, which may be handy for you.
-
• #3
Hi Gordon,
Thanks for your answers, yeah i figured we had to use vertical tilesheets to make the frame option work and when i tested it, it seemed to work fine initially. I was not aware of the byte alginment initially but yeah figured that might have been the issue after testing a bit.
I did try to change my image to a 2bpp (greyscale) 10x10 image but somehow it was still not working correctly for displaying all frames. imageMetrics does correctly report 126 frames with the 10x1260 image but somehow when i draw them some don't display and i was not sure what was causing that so i kept the 8 bit format for now as that seems to work fine. I don't know why the 2 bits per pixel 10x1260 would not work for displaying certain frames i did not really look into it as i knew the 8 bit ones are working fine. The reason it was working initially with the 1bpp 8x1008 image is that because of the width and height of the images (and a frame 8x8) the frames were also always byte aligned and as soon as i changed it to 10x10x1 they no longer were, i just kept it at 8bpp as then the size (width & height) of a single frame does not matter at all
modifying the tools would be nice, but its fairly easy to edit the height value manually but i'm not sure what you mean with the padding is this to make it work for images & bitdepth where the frames are not byte aligned ? to somehow make them bytealgined for every frame ? That would be nice if people want to use other bitdepths, but i'm guessing 8 bits per pixel will always work fine and now that there is some info about how one could use the frame option and that one can use vertical tilesheets to make frames work it should be fine for now (at least for me). Maybe it might be a nice feature to have for the tools in the long run.
edit: using optimal 2 bit with a color palette does work so i switched to that, then i can also try to make it adhere to the theme
-
• #4
i'm not sure what you mean with the padding is this to make it work for images & bitdepth where the frames are not byte aligned ?
Yes, that'd be the idea.
Glad you managed to get it sorted though! If you do use color palette then it won't adhere to the theme automatically though - but if it works paletted then there's a good chance it'll work without - maybe you just needed to store the image inverted?
-
• #5
If you do use color palette then it won't adhere to the theme automatically though
i edit the palette with the values from g.theme.fg and g.theme.bg now (if theming option in my game is enabled). this seems to work fine
but if it works paletted then there's a good chance it'll work without - maybe you just needed to store the image inverted?
Initially i had chosen in image convertor 2 bit grey scale and then it did not work correctly, but if i choose 2 bit optimal with a palette it did seem to work fine.
Hi,
I just received my bangle js2 today, i already got a game going but the original images are a bit small so i wanted to scale them.
initially I had an image consisting of 126 seperate images. this image was 8x1008 (so 1 tile = 8x8). I used the image converter to make a 1 bit image object out of it but i changed the width and and height both to 8 and then i could use the frame option to display a single tile from this bigger image and it displayed fine when drawing single frames or "tiles"
However i have now resized my image to 10x1260 so one tile is 10x10 but somehow this is now producing weird results when using drawBitmap with the frame: option, the images it draws seem distorted now
i could not find an example that used the frame option so i'm not sure if changing the height portion from 1008 or 1260 to 8 or 10 is the way to use this but i'm not sure how else i could produce frames of data
Basically i want to draw a smaller portion of a bigger image only and i thought frame could be used for that but it only seemed to work when i used a 8x8 tilesize not when using a 10x10 tilesize and i'm not sure where i went wrong or if i'm misusing the frame option.
Can someone show me an example on how to use the frame option from drawImage where width and height of a single "frame" is 10x10 in an image that is a multiple of that.
edit: is it possible this is a bug ?
I have included the image as attachment as well as the code i used so the original image was 10x1260 yet somehow imageMetrics is only returning 121 frames while it should report 126 frame if i change width and height to 10.
Or does frame only work for byte aligned sizes ? like 8, 16, 24, 32, etc for width & height ?
edit 2: it seems if i use 8bpp it produces correct results
1 Attachment