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
Solved

Setting Mask (Transparent) Colour in PictureBox

Posted on 2007-12-02
1
2,460 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …

856 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