Solved

Setting Mask (Transparent) Colour in PictureBox

Posted on 2007-12-02
1
2,475 Views
Last Modified: 2012-06-21
In VB6, one could set the Mask colour of a PictureBox (or was it an ImageBox?) to make a specific colour transparent (normally this was set to the picture's background colour). I can't seem to find this property in VB 2005's PictureBox control. Any ideas?
0
Comment
Question by:SETP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 20392041
Hi SETP;

In VB .Net 2005 the transparent color is now part of the Bitmap image itself and not the PictureBox object. The sample code below shows hot to load a gif image into a picture box with a transparent color of red = 7, green = 15 and blue = 0 or you could use a Color.ColorName as also shown.

Fernando
        Dim bMap As Bitmap = CType(Bitmap.FromFile("C:\Temp\image001.gif"), Bitmap)
        bMap.MakeTransparent(Color.FromArgb(7, 14, 0))
        PictureBox1.Image = bMap
 
Or
 
        Dim bMap As Bitmap = CType(Bitmap.FromFile("C:\Temp\image001.gif"), Bitmap)
        bMap.MakeTransparent(Color.Yellow)
        PictureBox1.Image = bMap

Open in new window

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question