xbmcgui.ControlImage with image data instead of file?
#1
Is there any way to display an image that is not a file?

For example:-
python:
imageControl = xbmcgui.ControlImage(100, 250, 125, 75, aspectRatio=2)
imageControl.setImage(pathToFile)

But instead of passing a file path is it possible to pass a byte array or ideally a previously loaded PIL image object?
Reply
#2
Unless there is a change you have to save the pil image to the hhd first... If you do find a way please pm me I have been trying to do something similar for over a year now.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#3
Quote:Unless there is a change you have to save the pil image to the hhd first
Yep, that what I'm currently trying to do, but I'm having problems with the image file not being ready on the disk when I try to display it, so I either get a corrupt image or no image at all, I've tried using xbmcvfs.exists to try and check the file is ready but it return true regardless of weather or not the file has been completely written or not. It's driving me crazy Sad
Reply
#4
Hi,
Just a thought for your work around. Could you check the size and compare it to the length of your byte array? Would be a possible quickfix
More generally speaking why are you doing this two steps asynchronously in the first place?
And if you really have to do it async a more cleaner approach would be to let your file writer tell your ui when to load something.
Reply
#5
(2018-06-15, 19:13)Takezo36 Wrote: More generally speaking why are you doing this two steps asynchronously in the first place?

That`s the thing.... I'm not. My code is as follows:-

python:
# Open Image
img = Image.open(src)
# ....
# .... Code to preform operations on image
# ....
# Save the new image
img.save(dest, format="jpeg", quality=95)

# Update Image control with new image file
imgControl.setImage(dest, false)

I suspect the problem is that even though the save function returns the file still isn't synced to the actual disk when the setImage function is executed.
Reply
#6
when you set image is this for a custom gui?
Or how are you passing it back into kodi...

The easiest way for this to work correctly every time is to set the image you want to display to a window property.. then in the skin have it check that it is filled... then it should auto fill once the image is actually ready... if nothing else use a delay of 1 sec before seting the image.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#7
(2018-06-16, 23:34)smitchell6879 Wrote: when you set image is this for a custom gui?
Or how are you passing it back into kodi...

It's a custom gui using PyXBMCt. I've tried various delays after saving/before updating the image and it's still really hit and miss as to weather the image correctly updates.
Reply
#8
I had it working just fine using the script to edit the image then set the image path to a window property. Then in the xml file make a image control set the texture as the window property you made... Have it be visible only if that property is filled... Maybe it is s the PC your using making the edit take longer and write.... I have a i5 with 12 gb or ram so normally a 1 to 2 second delay and it displayed... Keep in mind image needs to have a different name so that the Kodi cache will display it.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#9
(2018-06-21, 02:43)smitchell6879 Wrote: Then in the xml file make a image control set the texture as the window property you made...

I'm using pure python so no xml file.
 
(2018-06-21, 02:43)smitchell6879 Wrote: Keep in mind image needs to have a different name so that the Kodi cache will display it.

Yep, tried generating random file names every time the image is saved, still nothing. The setImage function has a second parameter to control weather or not to cache the image but that seems to do nothing....  I've pretty much given up trying to get this working, it just a shame the setImage function only accepts files and not raw data Sad
Reply
#10
you could make a service addon that serves the images over http, urls should work fine with controlimage.
Reply
#11
So, I tried to do this very thing. You can see the branch in github here: https://github.com/robbieh/screensaver.e...httpserver

I wanted to serve up images to a screensaver. Adding in the server wasn't too hard, but I can't get it to work without the controlImage blinking every time it fetches a new image. That makes it unsuitable for my use. I even tried swapping out two controls so one could update while hidden, but that doesn't work well either. Maybe I've made a mistake, but after banging my keyboard against this for days I give up.

What did work well, at least on a Linux-based system, was to search for a ramfs partition and write the temporary image files there. I'll have that posted to github soon, hopefully today.
Reply

Logout Mark Read Team Forum Stats Members Help
xbmcgui.ControlImage with image data instead of file?0