Retrieve image from sqlite3 and display in Kivy image widget - ValueError

后端 未结 2 525
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-25 19:26

REQUIREMENT

I\'m trying to retrieve an image from Database and set this image to kivy image widget, this operation throws a ValueError, unsure of the ca

2条回答
  •  长发绾君心
    2021-01-25 19:51

    Ikolim's answer is good but to be more specific, If you want to display a binary image directly into kivy you can simply work with io module (import io) and kivy image module (kivy.uix.image)

    Check this code:

    from kivy.uix.image import Image, CoreImage
    import io
    
    
    binary_data= #binary img extracted from sqlite
    
    data = io.BytesIO(binary_data)
    img=CoreImage(data, ext="png").texture
    
    new_img= Image()
    new_img.texture= img
    

提交回复
热议问题