I have a picture in memory a format (output from pyplot) and I want to directly show it on the Android through Kivy, but I don't want to create a picture file. Is there any way to do this? On pyplot I am able to generate the file like object by writing it the object, but I don't know how to put it into Kivy.
Texture is a class that handles OpenGL textures. Depending on the hardware, some OpenGL capabilities might not be available (BGRA support, NPOT support, etc.) You cannot instantiate this class yourself. You must use the function Texture.create() to create a new texture: texture = Texture.
A Widget is the base building block of GUI interfaces in Kivy. It provides a Canvas that can be used to draw on screen. It receives events and reacts to them. For a in-depth explanation about the Widget class, look at the module documentation.
Similar to the first answer but doesn't require img_pygame:
from kivy.core.image import Image as CoreImage
from kivy.uix.image import Image
import io
import qrcode # specific to my usecase, interchangeable with Pil.Image
# OR
from PIL import Image as PilImage
msg = "text"
image = Image(source="")
imgIO = io.BytesIO()
qr = qrcode.make(msg) # returns PilImage object
qr.save(imgIO, ext='png') # equivalent to Pil.Image.save()
imgIO.seek(0)
imgData = io.BytesIO(imgIO.read())
image.texture = CoreImage(imgData, ext='png').texture
image.reload()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With