Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved C#
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hkjghkj1
    wrote on last edited by
    #1

    [Message Deleted]

    L D 2 Replies Last reply
    0
    • H hkjghkj1

      [Message Deleted]

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      public static System.Drawing.Drawing2D.GraphicsPath Transparent(Image im)
      {
      int x;
      int y;
      Bitmap bmp = new Bitmap(im);
      System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
      Color mask = bmp.GetPixel(0, 0);

              for (x = 0; x <= bmp.Width - 1; x++)  
              {  
                  for (y = 0; y <= bmp.Height - 1; y++)  
                  {  
                      if (!bmp.GetPixel(x, y).Equals(mask))  
                      {  
                          gp.AddRectangle(new Rectangle(x, y, 1, 1));  
                      }  
                  }  
              }  
              bmp.Dispose();  
              return gp;  
      
          }  
      

      Then in your form load event handler

      System.Drawing.Drawing2D.GraphicsPath gp = Resources.Images.Transparent(pictureBox1.Image);
      pictureBox1.Region = new System.Drawing.Region(gp);

      I know nothing , I know nothing ...

      1 Reply Last reply
      0
      • H hkjghkj1

        [Message Deleted]

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        First, don't use PictureBoxs. Next, Color.Transparent is not really Transparent as you're expecting it to be. Transparent only tells the control to take on the background properties of the control that contains it. In other words, there is no true Transparency. Having said that, in your example, the control in the middle will NOT be visible in the transparent areas of the top control. It'll disappear behind the borders that makes up the top control window. A better option would be to drop a Panel control on the form, resized or docked as needed, then just draw each image yourself in the Paint event of Panel control. You'll have much greater control over the transparency.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups