Jump to content


Photo

is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ?


  • Please log in to reply
14 replies to this topic

#1 s3n0

  • Senior Member
  • 108 posts

+10
Neutral

Posted 28 May 2018 - 11:50

Hello everyone.

 

Is there a way to upload PNG images via .startDecode method, but including a transparent color parameter ("#XXrrggbb") ? I can not do that. If I upload a PNG image directly in the XML skin variable, over pixmap="path", everything is OK and the transparency in the PNG image works. However, if I upload an image through the familiar enigma2 algorithm (rendering function while running the program), then transparent pixels are ignored. I also tried to change backgroundColor (in parameter settings via .setPara) in my function, but it was unsuccessful.

 

Thanks.

 

 

The referenced image rendering algorithm (from my Screen class):

def imgRender(self, path):
    self.imgfile = path
    if exists(self.imgfile):
        self.sc = AVSwitch().getFramebufferScale()
        self.img = ePicLoad()
        if self.img:
            self.img.setPara((  sizemaxH, sizemaxV, self.sc[0], self.sc[1], False, 1, '#FF000000'  )) # max-X, max-Y, scale-X, scale-Y, aspect_ratio=1.000000, cache=0, resize=1, bg=#FF000000
            if self.img.startDecode(self.imgfile, 0, 0, False) == 0:
                ptr = self.img.getData()
                if ptr is not None:
                    self["layer_pic"].instance.setPixmap(ptr)   # original entry:    .instance.setPixmap(ptr.__deref__())
                    self["layer_pic"].show()
            del self.img

Edited by s3n0, 28 May 2018 - 11:54.


Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #2 MiLo

  • PLi® Core member
  • 13,781 posts

+289
Excellent

Posted 28 May 2018 - 18:52

The background renderer converts everything to 24-bit RGB (or 8-bit), so transparency gets lost. It was mostly built for large-file JPG viewing.

To get transparency, you'd have to either adapt that code to support 32-bit, or use the regular decoder in a thread. I don't know if the latter would actually be possible, since it's a GUI call.
Real musicians never die - they just decompose

Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #3 ims

  • PLi® Core member
  • 9,576 posts

+157
Excellent

Posted 28 May 2018 - 19:08

may be, info from skin is lost here?


Kdo nic nedělá, nic nezkazí!

Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #4 s3n0

  • Senior Member
  • 108 posts

+10
Neutral

Posted 1 June 2018 - 00:58

Thank you both. I do not know if the language source C language just represents a reduction from 32bit to 24bit because it does not look like that. However, I do not know C language very well.

I just need to change the images at a time when the skin from the Screen is already loaded. At that time, I can only hide / view widget or ePixmap, but not change it. Only a refresh of the whole view would be possible (hopefully), but I did not do so yet :).



Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #5 dhwz

  • Senior Member
  • 182 posts

+17
Neutral

Posted 3 June 2018 - 17:33

As far as I know DreamOS is right now the only E2 derivate which supports real 32bit alpha transparency support (as Dream reworked the whole graphics engine), also via Python startDecode. Any other image loses transparency when loading images (via Python), you can only set a specific background color but no transparency.

Edited by dhwz, 3 June 2018 - 17:35.


Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #6 s3n0

  • Senior Member
  • 108 posts

+10
Neutral

Posted 9 June 2018 - 11:49

OK, thank you for your explanation.

Although this is another subject, I have a second question:

How could it speed up loading an image from a file ? On slower set top boxes (such as Amiko Alien 2), it takes a long time to load the image from the file. But even on faster set top boxes it's actually slow. Is there even faster code for faster image loading ? And then also for his faster rendering.


Thanks.



Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #7 MiLo

  • PLi® Core member
  • 13,781 posts

+289
Excellent

Posted 11 June 2018 - 19:07

Fastest way to display an image on screen is to make it into a single-frame movie. Then you can use the hardware to decode and render it, blazingly fast.

Render speed mostly depends on the image size and algorithm. PNG will render faster if you use less bits per pixel. Well-dithered 8-bit PNG can look excellent on screen.

JPEG usually renders faster than PNG, because it's lossy. Compressing it more will also make it render faster.
Real musicians never die - they just decompose

Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #8 mrvica

  • Senior Member
  • 559 posts

+28
Good

Posted 11 June 2018 - 19:56

https://forums.openp...-for-boot-logo/

you can display the .mvi file with

showiframe file.mvi



Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #9 s3n0

  • Senior Member
  • 108 posts

+10
Neutral

Posted 12 June 2018 - 11:48

Yes, but I use PNG or JPG images downloaded online from the Internet. Every day another picture. So I would have to convert JPG/PNG > MVI every day. Sometimes even more ... for example, within 1 minute even 3 new pictures.

Is it possible to convert image files to 1-frame video even through some modules in Enigma2 (Python code) ? Or do I need some special tools for it ? How long will it take to convert images to MVI ? I need to render or change a picture on TV sometimes quite often. That's why I would need a faster code.

 

:unsure:

 

Thanks.



Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #10 dhwz

  • Senior Member
  • 182 posts

+17
Neutral

Posted 12 June 2018 - 15:53

How large are your images (resolution)? Because jpegs are usually loaded very fast as it is a hardware decoding, sounds strange if you say it is slow.
Converting it to mvi makes no sense that will take more time than loading it the usual way.

Edited by dhwz, 12 June 2018 - 15:55.


Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #11 s3n0

  • Senior Member
  • 108 posts

+10
Neutral

Posted 13 June 2018 - 14:34

FullHD resolution 1920x1080.

 

The problem is I need to see a specific image immediately. Plugin is dependent on real-time clock. A specific picture must appear at the exact time.

Uploading an image from an internal flash drive takes approximately:

Vu+ Solo SE V2 (1.3GHz) - 1 second
Amiko Alien 2 (450MHz) - 4 seconds

It's an extremely long time. I spend time and it's bad. I want it to work on slower linux boxes with enigma.

Would it be possible to predict the images in the variable as binary and pre-decoded data ? And keep them always in RAM memory and if necessary just call the rendering of this data from the variable ? Of course the pictures are multiple - about 5 to 20 pictures. This would obviously take up a lot of memory capacity. Hm...



Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #12 mirakels

  • Forum Moderator
    PLi® Core member
  • 7,502 posts

+62
Good

Posted 13 June 2018 - 19:03

if i remember correctly the enigma picture viewer decodes the next picture in the directory while viewing one. so only the first one may be slow. That is, depending on how long you look at the picture..
Geen wonder... Had slechts een dm7000, maar wel ook een rotor. eigenlijk al een tijdje ook een dm600 en dm7025. Maar nu kijkend met een et9000 en vuduo

Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #13 s3n0

  • Senior Member
  • 108 posts

+10
Neutral

Posted 14 June 2018 - 11:32

I use code as it is used in Python Enigma source codes. But my code does not consist of two parts (functions), but only one part - see the code above.

When a picture is uploaded using an add-on procedure, the upload takes place as the background process. For my code, the upload is performed as a foreground process (time loop). So I'd probably start using the original code. That's not important.

I tried to leave the images loaded in variables - for example ptr1, ptr2, ptr3, ptr4, etc. ... without deleting them and keeping them in memory. It works fine. But the problem is again when loading all the images when you first run the code :).



Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #14 MiLo

  • PLi® Core member
  • 13,781 posts

+289
Excellent

Posted 14 June 2018 - 19:00

It would help a lot if you'd just tell what you're writing, all these vague descriptions without actually telling what you want to do aren't helping...

If you load a picture, it will remain decoded in RAM as long as you keep the (python) object alive. So if you want to display it at a certain time, you'll have to download and decode it first in RAM, then you can quickly render it once needed (should take less than 1/20 second to render an image)

So to display it at 1:30:00, download it at 1:29:50 or so, and then wait until the time is right...

Edited by MiLo, 14 June 2018 - 19:01.

Real musicians never die - they just decompose

Re: is there a way to upload PNG images via startDecode, but including a transparent color parameter ("#?rrggbb") ? #15 s3n0

  • Senior Member
  • 108 posts

+10
Neutral

Posted 14 June 2018 - 20:01

More times I wrote what I needed. The basis is QUICK upload and rendering of the image. In English words: instantly view the image.
Also, my code is very complex. It fulfills a number of functions, so its explanation or sharing has no meaning yet.
I know these are objects. Currently, I leave the variables (objects) in memory and, if necessary, just drag the object into the ptr variable and open the image.
I do not know how the ePicload works. I'm already tired of getting too many studying the Enigma code :-).

 

Part of my code (Screen class):

    def imgRender(self, img_path):
        global cacheImage
        self.img_path = img_path
        self.idxP = [  i for i, j in enumerate(cacheImage) if j[0] == self.img_path  ]
        if not self.idxP: # if img_path was not found in the cache, then...
            global sql
            sql.downloadImageFileToCache(self.img_path) # download and prepare the image (from URL or from local disk) into cacheImage
        self.idxP = [  i for i, j in enumerate(cacheImage) if j[0] == self.img_path  ]
        self.idxP = self.idxP[0] # converting <tuple> to <int> (index found by the cache)
        ptr = cacheImage[self.idxP][1]
        self["content_pic"].instance.setPixmap(ptr) # original entry:    .instance.setPixmap(ptr.__deref__())
        self["content_pic"].show()

Edited by s3n0, 14 June 2018 - 20:05.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users