-
• #2
Hi, I guess http://www.espruino.com/Graphics would be a good start, there is some info at Images / Bitmaps chapter.
There is also an image converter http://www.espruino.com/Image+Converter to make converting images easier. -
• #3
As above - there are tools for converting images (the IDE has one built in if you try to upload an image to storage).
Since the https://www.espruino.com/ST7735 driver is paletted I'd suggest setting it up with a 4 bit ('mac') palette, and then you can convert all your images to that using the image converter.
Another option is to save the image as a paletted image string, then modify the ST7736 driver to blit the image right out using the image's own palette - that'd be pretty quick but is a lot more advanced.
-
• #4
thaks @AkosLukacs,
i'm able to display colorPaletted image, but don't understand how to use palette from object image.var img = { width : 128, height : 128, bpp : 8, buffer : require("heatshrink").decompress(atob("3143wABAaYATC4N4AAUyAC4aBG6xHRM7o4ZPg4HDAYIBDA4qAuAGz6QCCCCvFtPxPojrKAKCAJFYKBtAY77qBxYaOmR3sfMYACNBDtOB5SGJK4o3EAH4AGdZRqLPxYALbEp+sNRLxNBIQADB5QTFHAvxLUCqfD4TtJACqCECiB3+FJT9IA45sJBogACEgIVLDQr7hP1BuJAYppOAAoWQPP79OfZIHHSQoBCAAQoBD5IXG33xH4QDDAAYHHPdj9NAC6ADPwYXQH4RffAD79KBJIBQf5SQFQAz10PxzrQMAzvJQQwTMQA4A9J4T9ZPRD/MDJIDDIQPxIwQDHMSh+dAD6AHPwSACACLedDrnxfohiFaI7ZJAJQAEf56AkADr+dQBouDUxomH+J/4MxBWPOgwHJQAgRIFZqAKRSa5DPzT9eAAh5Df4iACACTgZPbIcDfpZ6QPAwuJbYLdCQQgxDGo4HDMjZ+eJBKCQPhB2CPgiAJFZ5/4fp4TGPQxwCAB42CQQQ1MF4aiDVQ4Aneqh+GPg6APMAYeBQAQ3OGIjjTPrHxIYj9PPgr1QQRiARB4T9wYR79HvB8cPwSAEf84AaORD9Kfb6CGHo6ALfdZ+UBwZ+lNQRvBQB5lVCyxAGPx58iQQzAHHREyf1y/PP1qACbII8NHoJ2jEga9JQhgXBAFhDHQBBXFAEvxfyK/CPtZsCeQJAMPtI8CP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w7KJf76zEAQJuFXp4RCeIYBIF4qSGRBIVCforJCIKIEEeiIDEBgo8CVZCEHBYxsHNA48GCZR+HZQx6Nf8hmDHBJCMdpYBEXpAACCJD9IfyLUGf56BMcob/VGwjpKQwzCQJRJ+Uf7I6DPwY4KIZZaFf4h6GPhQbDe4wLHP57OHMIR3RCYwbBBAT5JV4oLEPhYAJQhr/LA4L9UA4b/XPwiACHBx+GQCJ8EPxj9HBIhFRAIz/PWgoDEIAgoHGQoFEPg7/PQyrKFPir/aPQYADf6AABEQ6AEQg54GPxjbHIqTKFAgb5TAoZ7CQQgqJWIoaCMwwAVQRpYGPyJXHf7QBCfiKvELwaAQf5SAOf6h+FZwZ1MAZD7EfIoqGA4b9FNgYAZD4pPEA4x/EQhJLFAIr/YfSL9JAJB4Pf6xISA47/LfpanHWJYABftL/LP6JPHf7AwTfwbjMPiYBKPwbNEcgL/UKYj/LAAoRDGB5BBIYYDBfDaEKRBh+CQBj7ECIQBFf6w=")) }; function draw() { digitalPulse(LED2, true, 20); g.clear(); g.drawImage(img,0,0); g.flip(); } var g; function onInit() { A5.set(); // Backlight On var colorPalette = new Uint16Array([0, 0xFFF]); // 2 couleurs pour la palette // init spa var spi = new SPI(); spi.setup({mosi:B15 /* sda */, sck:B13 /* scl */}); g =require("ST7735").connect({ palette:colorPalette, spi:spi, dc:A7, cs:B10, rst:B1, // height : 160 // optional, default=128 }, draw ); }
-
• #5
Hello,
i'm graphic designer and a 4bit mac paletted image is not optimised for displaying grayscale image as this palette contain only 4 grayscale levels... sad...
i've tried to optimized with a generic 2bit-grayscale palette with photoshop([#000000,#676767,#b6b6b6,#ffffff]) from https://lospec.com/palette-list/2-bit-grayscale
if i use your tool the palette does not match and the tool rebuild the paletted image and loose 1 color pix even in flat mode.
how can i manage to encode the image as is?
regards
-
• #6
well i build a MAC16 palette in photoshop as your script does (the online tool)
now i can export the image "as is".Now on my screen, the color does not match.
what is suppose to be a gray #bbb is purple and the gray #444 is green...
no matter i change the palette reference by reorganize (in photoshop) the place of each color as in your coded palette...oh and i use your palette as the ref palette.
what's wrong?var img = { width : 128, height : 128, bpp : 4, buffer : require("heatshrink").decompress(atob("mUzAJIAJmUykMRiAAEiIHDiMiDZQjIGZwAMkURgI5BABEBgMTFC4AVmJ3EHYgJEU4MSFCqAUn8yOgiAKQIc/DIbFWIxp9BOgL1DAYUARAoJDkY7UPiICBPRQJEAgQCBgMCfUpSBkEAHYr/FAAMhQA0Tf8J8BAIMyfBsRiUSfoQJDgLBBf65+MO4hyCOgYACP4aAFiT/jPxZyBBgR/CBIgACl7/ikD5HPop/DQAYAEQB4ASfpyACP4MiA4KCGf4IBBAAIDDYZJ+Pdoj/LQAILFgCARf6JpCQJgNCP4QHEQIZ6LACcwMgRzEAAgLGkQEDBYkAkaAeNAiADiR8GBIR/FPwkBgSABAIZAXmJ+GAJCKEkMhPgocBAIJ+cn8hPgb/EAggADPwMSkb9GgCACib+cM4hsFPQqEDkMiP4QKCQAQVBiPzQDUyPwroDAAJ6CQA0jkSKFQAcRl7/DAIIAUfwoECA4gzEfYIABP4KADDIaACYBj/OfwJ8HQwZ6DkUikYACmaAECYSACiT9ZmT5GMoR+FPIMyAA0hf4aADCwL/ZfwJ+IBIR8CPAIAHkUSP4iACiMvBwT/JIBcwO4Z+DA4QuBPYJZKQAQZCDQbAMPxk/fwR7GfQR7BMgM/AAaAGP4QADH5r+RPwQBCFgIRE+YBEDgshPogDCkI/Yfw4FBPoJ6EAA7vETo0AiUvH60xLwh+EkR+HAAJcHQAQfFgLZBf6r+IgMTfIqANkciHQL/DDoS9UmcgPwoABgJWDPggAFEA0iEAIhEiS/WG4L+FgB+K/6AKmciEIKADiQNDB4aAOLorgCPx6AFmUykKACAAURkbAVbop+DAAL/OQAR/DkQfEgI/VmJ/FfoqACABaAGmSgFiQ/VfgheBgZ+HfYIBDf5UjkchUQg/Bf6bcBPwkAkR/Ff5iAEPwMikJ/EiJ+Tn64BLYbdCbwJeCQA5+KQAUiiIgBX4UvH6T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var g; function onInit() { A5.set(); // Backlight On var colorPalette = new Uint16Array([ 0x000000, 0x444444, 0x888888, 0xBBBBBB, 0x996633, 0x663300, 0x006600, 0x00aa00, 0x0099ff, 0x0000cc, 0x330099, 0xff0099, 0xdd0000, 0xff6600, 0xffff00, 0xffffff]); // 2 couleurs pour la palette // init spa var spi = new SPI(); spi.setup({mosi:B15 /* sda */, sck:B13 /* scl */}); g =require("ST7735").connect({ palette:colorPalette, spi:spi, dc:A7, cs:B10, rst:B1, // height : 160 // optional, default=128 }, draw ); }
-
• #7
it seems there is a rgb to bgr inversion...
-
• #8
well i do not understand wich format can be used to directly loadImage from storage as in exemple!
is it a bmp file in 1bit? or a what?
how to put img file in the storage area of the espruino?
am i wrong, it only works with a sd card module?i have to admit, i'm a beat confuse. sorry
g.drawImage(require("Storage").read("myimage.img"), 10, 10);
-
• #10
ok i've found the palette issue...
the display is RGB16bits not RGB24bits, so the MAC16 Palette look like this with 16bits values:var colorPalette = new Uint16Array([ 0x0, 0x4228, 0x8c51, 0xBDD7, 0x9b26, 0x6180, 0x320, 0x540, 0x04DF, 0x19, 0x3013, 0xf813, 0xd800, 0xfb20, 0xffE0, 0xffff]);
-
• #11
Great - glad you got it sorted!
You may also find that 'optimal 4 bit palette' will work well for you, but then the palette will change for each image.
For your use case, are you thinking that having a '4 bit greyscale' option would be better for you?
-
• #12
Hello @Gordon, sorry for late answer, have to test more to give feedback.
The optimal 4bits palette does not works.... the display seems to use only the 16MAC Palette even if i iniate with the palette generated by online converter tools.
I've tried with 2 differents (cheap) displays a 128x128 1.44", and a 1.8" 128x160 from ebay.
the palette does not works in 4 bits mode.
and as the screen is initialize with 4 bit palette, the 16bits pictures are wrong color... (even if i modify thecmd(0x36,0xC8)
, tocmd(0x36,0xC0);
(the RGB to BGR bit in the datasheet)
i don't find a way to initialize the display in 16bits.
if we remove the palette option, it produces an error.regards.
any help would help.
é.
-
• #13
Maybe you could try just setting up the display without images and trying out some colours to make sure it's working right. Looking at what you said above:
0000FF = yellow 00ff00 = blue ff0000 = black (no color) ffffff = white
My guess is the screen's colour format is 16 bit BGR565 (
BBBBBGGGGGGRRRRR
). However it could be that the byte order is wrong, which would explain a lot. In that case it'd be something likeGGGBBBBBRRRRRGGG
which would be super confusing.
Hello,
i 've got a small 128x128 ST7735 display, i'm able to drawString on it. happy of that.
i'll be curious to display picture on the small screen.
how to create an arrayBuffer with a bitmap picture?
is there a tool to create and compact the picture in base64 or anything else to store the picture in the espruino?
is there a way to display with a descent framerate? more than 1 picture every 2sec....
sorry for that basic question, for sure the espruino is not designed to play video, but let me hope of that...
regards
éric