<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[StickC UiFlow displaying a  jpg image from variable]]></title><description><![CDATA[<p dir="auto">Hello<br />
  I have an idea to send a picture in .jpg format using MQTT to M5StickC from one device (PC / smartphone / etc) and display it on the StickCscreen.</p>
<p dir="auto">the process should look something like this:</p>
<p dir="auto">on sending device side</p>
<ol>
<li>aquire image</li>
<li>resize and convert to jpg</li>
<li>encode with base64 and publish via mqtt to server</li>
</ol>
<p dir="auto">on receive m5stickc side<br />
4. subscribe data from mqtt server<br />
5. decode image with base64 and save to variable<br />
6. display image from variable on screen</p>
<p dir="auto">I have a problem with 6 point</p>
<p dir="auto">I skip points 1-4 that I won't have a problem with and I will deal with them later.<br />
What I was able to get:<br />
decode the received text as jpg and save it to a variable and to a file. And read it from the file and display it. Very frequent saving to flash memory will burden it tremendously and will shorten its life, so I want to skip writing. Unfortunately, I can't find any function to skip saving to the file and display the image directly from the variable. I was looking for a solution to my problem and the only thing I found was an analogous library for arduino where there is an identical function as in the micropyton and the one I am looking for, but on my hardware the compilation of code in arduino takes forever, which greatly extends the coding / programming / debugging process. I found a function / class in the micropyton<br />
<strong>tft.pixel(x, y [,color])</strong><br />
but then I would have to send images as individual bitmap points and practically draw pixel by pixel but it would complicate my software for points 1-3 and extend the drawing time on the screen</p>
<p dir="auto">working main part of the code:</p>
<p dir="auto">text = '/9j/4AAQSkZJRgABAQAAAQABAAD ... ( ~ 3-5 kB encoded jpg file) ... '<br />
temp = binascii.a2b_base64(text) # decode base64 ascii stream to binary jpg stream<br />
f = open("res/temp.jpg", "wb")<br />
f.write(temp) # save stream to file<br />
f.close()<br />
image0 = M5Img(0, 0, "res/temp.jpg", False) # create image object and load saved stream as jpg file<br />
image0.show()</p>
]]></description><link>https://community.m5stack.com/topic/1505/stickc-uiflow-displaying-a-jpg-image-from-variable</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 08:58:13 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/1505.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Nov 2019 19:59:29 GMT</pubDate><ttl>60</ttl></channel></rss>