how to transparent a picturebox control in C# and show everything behind of it

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mahboobeh
    New Member
    • Sep 2010
    • 7

    #1

    how to transparent a picturebox control in C# and show everything behind of it

    hi
    i have tow picturebox and i want to show the first with a low transparency on top of the another one. its mean i want to transparent above picturebox and show every thing that behind of it like the other picturebox .how can i do this?
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I did some digging around and my suspicions are confirmed, you can't really do this with a PictureBox.

    That said, it's pretty easy to just use a panel, set the background to transparent, then use GDI+ to draw your image yourself by overriding the OnPaint method.

    Look into this and let me know it works out, or if you need some help.

    Comment

    • mahboobeh
      New Member
      • Sep 2010
      • 7

      #3
      hi graytexmo
      tnx for you reply.
      ill put a sample here,i tried alphablend(an api) and a glassy control in this sample.
      it work with glassy control but it have very low speed in compile for big pictures,
      i tried yor suggestion but its great if you can give me a sample.
      i hope you got what i want.
      Regards.

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        I think I might be unclear on what you're looking for.

        Do you want:

        A) Transparency, the portion of of the control that is not taken up by the picture is completely see-through, such that you can see anything behind it.

        B) Opacity, the entire control, image included, is rendered such that you can see through the image to what is behind, but the image on top is still viewable.

        Your page title threw me off, I thought you meant transparency but on rereading everything in light of your latest post I'm thinking you actually meant opacity. Two different things, sorry for misunderstandin g you.

        I know you can control the opacity of the form itself, but I'm not sure about individual control. An alpha blend for a large picture can indeed be a fairly expensive operation if you do it every render cycle, but you might be able to do the blend on the image, render the result, and only update on a change.

        Also, are you needing the control itself to be semi-opaque, or are you just wanting to lay two pictures over top of each other?

        Comment

        • GaryTexmo
          Recognized Expert Top Contributor
          • Jul 2009
          • 1501

          #5
          Have you tried this?

          Comment

          • mahboobeh
            New Member
            • Sep 2010
            • 7

            #6
            tnx GaryTexmo
            i used wpf usercontorl.and it worked for me.
            i wnat something like image in wpf.it has an opacity in its propertis.

            Comment

            Working...