-
• #2
It depends on what exactly the image was encoded as... If it's a base64 image of raw bits then you can just shove it in an object with width, height and buffer fields like http://www.espruino.com/Image+Converter does (http://www.espruino.com/Graphics#images-bitmaps)
However if it's a windows bitmap file (which is what
asURL
does) then you can convert it to a binary form withatob(...)
and then feed that into the bitmap loader module which will give you an image which you can draw with graphics as well: http://www.espruino.com/BMPLoaderIf a normal PC application is encoding an image to a URL it may well end up encoding it as a PNG of JPEG image - and I'm afraid there aren't any decoders for those in Espruino though.
-
• #3
Ah, perfect. I just need to read your docs better. I was stuck on http://www.espruino.com/Reference#Graphics looking through all the functions and didn't see the link to http://www.espruino.com/Graphics which would have lead me to http://www.espruino.com/BMPLoader
-
• #4
Great! If you think of any search keywords that might have helped you find those pages better, please can you let me know?
If you click the
This page is auto-generated from GitHub
link at the bottom of the screen you should go to the page's source on GitHub where it's got a* KEYWORDS: ...
list. If there's anything missing it's trivial for me to add, and it might help someone else out in the future. -
• #5
I have played with the idea of having an easy way to debug graphics locally and made the following module https://gist.github.com/opichals/8f74cc494a3e2d7cf122c6013e8935cf
It wraps the
Graphics.createArrayBuffer
by callingrequire('./webGraphics').add(Graphics)
and exposes http://localhost:8000 endpoint with canvas renderer for Espruino. -
• #6
Nice! There's
g.dump()
which gets picked up and displayed in the Web IDE: https://youtu.be/YQtLmu8-aHw?t=271
But that doesn't update in real-time like yours. Actually with a little bit of abstraction around button handling you could make it so you could remotely view and also control a device. It'd be a really neat way of quickly making a web interface for a device.
-
• #8
I think @opichals is actually running it on an ESP32, however the code should work if you add an ESP8266 to the Pixl, maybe something like http://www.espruino.com/arduino-esp8266
-
• #9
It should be capable of working on boards but I have actually only ran it on my OSX laptop.
I guess the bandwidth and the lack of WS binary support might be a little problematic memory-wise as it is getting 8kB (screen buffer for 128x64 1bpp) over to the browser on every
flip()
call. -
• #11
@dave_irvine I run the whole application on my local machine. I mock any HW stuff and so the application graphics rendering is done as usual but uses some fake data to render.
Hi Gordon,
Is there an inverse equivalent of https://www.espruino.com/Reference#l_Graphics_asURL ? I.e if I've got a base64 encoded image, can I convert it to something I can pass to Graphics to display on the screen?