7 Replies Latest reply: Sep 25, 2008 6:32 AM by 843851 RSS

    Transparency with *png in MHP with DVBAlphaComposite-what's the problem?

    843851
      Hello!
      I know this topic exists already, but it could not help me with my problem:
      I want an HIcon with an transparent picture in it but I am not able to get any transparency..To me that code seems to be right,
      but when testing it with the IRT RI, the Graphic is opaque..
      Does anybody see what i am missing?

      ...
      public void startXlet() throws XletStateChangeException {


      MediaTracker tracker = new MediaTracker(this);
      picture = Toolkit.getDefaultToolkit().getImage("AlphaGrafik.png");
      tracker.addImage(bild, 0);

      try{
      tracker.waitForAll();
      }
      catch(InterruptedException e) {
      picture = null;
      }

      cont = new HContainer(0, 0, 720 , 576);
      icon1 = new HStaticIcon(picture, 0, 0, 720, 576);
      cont.add(icon1);
      scene.add(cont);
      scene.setVisible(true);
      icon1.requestFocus();

      }

      public void alpha(Graphics g){
      DVBAlphaComposite compositeRule = DVBAlphaComposite.getInstance(DVBAlphaComposite.SRC_OVER, (float)0.5);
      DVBGraphics image = (DVBGraphics)g;
      try {
      image.setDVBComposite(compositeRule);
      }
      catch (org.dvb.ui.UnsupportedDrawingOperationException ex) {
      System.out.println("Exception: " + ex);
      }
      image.drawImage(picture,0,0,null);



      }

      Any help is very useful for me!
      Regards, Alex.
        • 1. Re: Transparency with *png in MHP with DVBAlphaComposite-what's the problem
          843851
          I have simular problem applying alpha composing to Graphic layers.
          If I draw graphic elements like circle or rectangular with some color or draw images with transparency (Alpha) then I can see only background IFame under top element. It seams when I draw something on graphic layer then middleware compose background video layer and DVB colors of element that I am drawing at the moment. Colors of elements that placed under the top element are ignored. I tried verious composing rules but It does not give any correct result. It seams middleware does not suppot alpha composing at this moment. Did you get some exception applying alpha composing?
          I use Alticast MHP middleware installed on my Humax STB
          • 2. Re: Transparency with *png in MHP with DVBAlphaComposite-what's the problem
            843851
            eltrimo:
            Did you try it that way:

                 public void paint(Graphics g) {
                      
                      try
                      {
                           ((DVBGraphics) g).setDVBComposite(DVBAlphaComposite.Src);
                      } catch (UnsupportedDrawingOperationException e)
                      {
                           e.printStackTrace();
                      }
            //draw whatever you like

            man-e-faces:
            who calls the method alpha(Graphics g)

            Both of you:
            Did you try creating a png with transperent color in photoshop,etc.? Maybe this helps.
            }
            • 3. Re: Transparency with *png in MHP with DVBAlphaComposite-what's the problem
              843851
              Hi Arachne!
              Yes, i tried it with Photoshop and solved the problem that way!
              I just added an Alpha Channel to my *.png-File and set its transparency to 50%.
              Now it works fine!

              eltrimo:
              You should try it that way too! It is a more easier solution!
              • 4. Re: Transparency with *png in MHP with DVBAlphaComposite-what's the problem
                843851
                Thanks for hint. But I have the same problem : top graphic element is composed only with background layer - IFram image.
                For example I created a couple of semi-transparent images red and blue.
                Then I overlap them on TV screen with this hierarchy redPicture -> bluePicture->IFrame
                and I am able to see only IFrame through redPicture but not edges of bluePicture under redPicture. It's a pity but it is not so impotant.
                I drew rectangulare areas with colors
                DVBColor(255, 0, 0, 128) and DVBColor(0, 0, 255, 128) instead of semi-transtarent pictures painted in Photoshop. I got the same result.
                Anyway, thanks for hint.
                • 5. Re: Transparency with *png in MHP with DVBAlphaComposite-what's the problem
                  843851
                  oops. The right line of code is of course:

                  try
                  {
                  ((DVBGraphics) g).setDVBComposite(DVBAlphaComposite.SrcOver); //SrcOVER !!!
                  } catch (UnsupportedDrawingOperationException e)
                  {
                  e.printStackTrace();
                  }

                  Try to put this at the beginning of your paint method.
                  You can also try to make the red and blue image seperate components, each with SrcOver activated in their paint Methods.
                  • 6. Re: Transparency with *png in MHP with DVBAlphaComposite-what's the problem
                    843851
                    I think that your code has an error with the colors, because MHP hasn't got 128 alpha channel, only 179. Could you try with DVBColor(255, 0, 0, 179) & DVBColor(0, 0, 255, 179)?
                    • 7. Re: Transparency with *png in MHP with DVBAlphaComposite-what's the problem
                      843851
                      I have a question about tranparency.
                      I wrote a program using a class that extends the java.awt.Component class, and in the paint() method i write the code:

                      public void paint(Graphics g) {
                      g.setColor(1,0,0,0.5f); // red color with 50% transparency
                      g.fillRect(0,0,50,50);
                      }

                      And the code works perfectly at Xletview emulator.
                      I want to know if this code works in a MHP based set top box.
                      With images i use photoshop to apply a alpha channel in .png archives and works very well in Xletview.