Solved

Setting Mask (Transparent) Colour in PictureBox

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

19 Experts available now in Live!

Get 1:1 Help Now