Solved

Setting Mask (Transparent) Colour in PictureBox

Posted on 2007-12-02
1
2,428 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
1 Comment
 
LVL 62

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now