Announcement

Collapse
No announcement yet.

Transparency Help?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transparency Help?

    Hello,

    I am working with some animated gifs. I made the background of the gif black, then imported via Graphics Composer.

    I am trying to make the black of the gif transparent:

    gfx_Set(1,0xB596); //Set the Screen to Gray
    gfx_Cls();
    UpdateButtons(FORCEUPDATE);
    gfx_Set(4,0x0000); //Set black as transparent
    gfx_Set(5,1); //Enable transparency
    // uSD_SetSector(0x0000, 0x3EF3);
    // uSD_Video(70, 70);
    // uSD_SetSector(0x0000, 0x3EF3);
    // uSD_Video(70, 70);
    uSD_SetSector(0x0000, 0x4387);
    uSD_Image(70, 70);

    My image comes in with the black background white, while the movie (when uncommented) still shows a black background......I thought that anywhere there was black in the bitmap or animation, the gray background would show through.......

    Am I doing something wrong?

    Thanks for the help.....
    _______________
    Best Regards,
    Howard

  • #2


    Howard,
    Can you attach the gif and the image with the black background?
    Atilla

    Comment


    • #3


      Sure, here they are......

      Thanks!


      Attached files
      _______________
      Best Regards,
      Howard

      Comment


      • #4


        Png file didn't go through first time? Here it is again.....


        Attached files
        _______________
        Best Regards,
        Howard

        Comment


        • #5


          Sorry ... our fault for lack of explanation and detail.
          The Object Colour is used as the replacement for the transparency colour so you'll need to set it as below.
          gfx_Set(2,0xB596); // Set object colour as the transparent colour replacement

          We'll add more detail in the documentation.
          Edit: The Background colour is not used as the transparent colour replacement but the Object colour is.
          Atilla

          Comment


          • #6


            It looks like the png file is doing the transparency, but not the GIF animation:

            My Code:
            gfx_Set(1,0xB596); //Set the Screen to Gray
            gfx_Cls();

            gfx_Set(4,0x0000); //Set black as transparent
            gfx_Set(2,0xB596); // Set object colour as the trans.colour replacement
            gfx_Set(5,1); //Enable transparency

            uSD_SetSector(0x0000, 0x3EF3);
            n:=0;
            repeat
            gfx_Set(6,5); //Set the interframe rate
            uSD_Video(70, 70); //Rotate the gears (See black background)
            until (n++ == 5);

            uSD_SetSector(0x0000, 0x4387);
            uSD_Image(70, 70); //PNG image has no black
            gfx_Set(5,0); //Disable transparency
            _______________
            Best Regards,
            Howard

            Comment


            • #7


              The Black background really isn't black in the gif. There's a nice GIF Animator program you can use to edit the complete animation or individual frames, the trial version can be downloaded from here:
              http://www.blumentals.net/download/egifan4p.exe

              I've edited the gif and set the transparency as the black (0x0000) that it should be and it works really fine. If you have time give it a go....
              Atilla

              Comment


              • #8
                OK, I'll take a look.....

                I'm having a semi related problem.....

                #platform "uOLED-32028-PMD3T"

                func main()
                if(uSD_Init() == 0) // initialise and test the uSD card
                print("PLEASE INSERT uSD CARD");
                while(1);
                endif
                uSD_SetSector(0x0000, 0x4856); //Load an image with black squares
                uSD_Image(0, 0); // display image at x=0, y=0
                txt_Set(3,1);

                txt_MoveCursor(0,0);
                print ("Box is black");
                pause(2000); //Box is black

                gfx_Set(5,0); //Disable transparency
                txt_MoveCursor(0,0);
                print ("gfx_Set(5,0);\n");
                print ("Box is black");
                pause(2000);

                gfx_Set(1,0xFFFF); //Set BC = white
                txt_MoveCursor(0,0);
                print ("gfx_Set(1,0xFFFF);\n");
                print ("Box is white");
                pause(2000);

                gfx_Set(2,0xFFFF); //set object color=White
                txt_MoveCursor(0,0);
                print ("gfx_Set(2,0xFFFF);\n");
                print ("Box is white");
                pause(2000);

                gfx_Set(4,0xFFFF); //Set xparency=White
                txt_MoveCursor(0,0);
                print ("gfx_Set(4,0xFFFF);\n");
                print ("Box is white");
                pause(2000);

                gfx_Set(1,0xB5B5); //Set BC = Grey
                txt_MoveCursor(0,0);
                print ("gfx_Set(1,0xB5B5);\n");
                print ("Box is Grey ");
                pause(2000); //Box is
                endfunc

                Even with transparency disabled, the boxes are changing color. So, in my actual code I have the bottom 1/3 of the display set as buttons. I want to clear the upper 2/3 without disturbing the lower 1/3, so I set up the clip region. I then was going to set the BG color to grey, and clear the screen. However when I do that the text in my buttons turns grey as well....

                I'm pulling my hair out.......Must be because it is 1:00am.....
                _______________
                Best Regards,
                Howard

                Comment


                • #9


                  Ok, a few hours sleep is a good thing.....

                  If I want to clear a portion of the screen with a certain color, is it better to just, say, draw a filled square of the proper color to the region, than to try mucking around with clearing (cls) to the background color?

                  Is the behavior of the code in the last post as expected? If so I think I need a better understanding of what is going on......

                  Also, how did you edit the gif animation to get it to work? I downloaded the program in the link, and it appears that the background is black....If I use the eyedropper to get the black color it is RGB 00 00 00......

                  This may be moot, since I think for quality purposes I am going to make the background color of the gif the same as my application screen color, and possibly not mess around with transparency....

                  Thanks for any light you can shed Atilla......
                  _______________
                  Best Regards,
                  Howard

                  Comment


                  • #10


                    Hi all,

                    Reading this thread I understand why the transparent region of my images comes white at the screen.


                    About the message from atilla:
                    "Sorry ... our fault for lack of explanation and detail.
                    The Object Colour is used as the replacement for the transparency colour so you'll need to set it as below.
                    gfx_Set(2,0xB596); // Set object colour as the transparent colour replacement

                    We'll add more detail in the documentation.
                    Edit: The Background colour is not used as the transparent colour replacement but the Object colour is."

                    First of all, it is true that it would be more logical if the color used as replacement of the transparent one is the one from Background Color instead of the undocumented Object Color.

                    Anyway... Before to buy my screen, I read in the document that it handles transparency. But I could not imagine that "transparency" does not mean "transparency" for 4D system.

                    The behavior you are describing is not "transparency" handling, it is "replacement", or "color shift", or I don't know which other word could qualify it, but not transparency.
                    The transparency mean that for a transparent pixel of the picture being displayed, the screen pixel won't be modified. It means that if I draw my picture, the transparent region won't alter the screen and the screen pixels of that region will remain the same, some of them green, others yellow or anything else: just remaining the same color than before the image to be displayed. In the current implementation, all the screen pixels will be modified to the replacement color: it is not a transparency handling. Moreover, in that case there is no need to a such processing: I can create my image with the "transparency" region already set to black or any other color.

                    So please tell me I'm wrong and I don't understand how to use the true transparency handling of my OLED, or tell me that it will be corrected in the next firmware, because I really need the true transparency handling for my application, and as it is precised in the feature of the screen, it is supposed to handle it.

                    Thanks,
                    Regards,

                    Mathieu

                    Comment


                    • #11


                      kazh wrote:
                      The behavior you are describing is not "transparency" handling, it is "replacement", or "color shift", or I don't know which other word could qualify it, but not transparency.
                      The transparency mean that for a transparent pixel of the picture being displayed, the screen pixel won't be modified. It means that if I draw my picture, the transparent region won't alter the screen and the screen pixels of that region will remain the same, some of them green, others yellow or anything else: just remaining the same color than before the image to be displayed. In the current implementation, all the screen pixels will be modified to the replacement color: it is not a transparency handling.
                      True, that's no transparency. Would be useful though.

                      Comment

                      Working...
                      X