By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,950 Members | 1,112 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,950 IT Pros & Developers. It's quick & easy.

making image and picturebox transparent

P: n/a
in my app i must have several pictureboxes over the others. Some pictureboxes
just have a couple of lines or rectangles, and absolutly nothing more but the
image is an .BMP. So, my problem is that i need to see whats beind those
pictureboxes and at the same time showing, the lines and rectangles that
exist on the pictureboxes that are at the top. Because i just can't copy the
image to the other picturebox (because i'll have to be able to control that
image, later) i need to know how can i turn transparant the pictureboxes that
are at the top. I've tryed the following code but it didn't work because what
it does is to copy the background color of the main picturebox to the
picturebox at the top

dim Logo as new Bitmap(CompanyLogo.Image)
Logo.MakeTransparent(Logo.GetPixel(1,1))
CompanyLogo.Image=Logo;

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

The picturebox does not have a transparent color property. I
would use a form instead.

Dim frm As Form

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
PictureBox1.BackgroundImage = Image.FromFile("C:\bliss.bmp")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim bm As New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim g As Graphics = Graphics.FromImage(bm)
g.Clear(Color.White)
g.FillEllipse(Brushes.Red, 20, 20, 20, 20)
bm.MakeTransparent(Color.White)
g.Dispose()
frm = New Form
With frm
.FormBorderStyle = FormBorderStyle.None
.Size = PictureBox1.Size
.TopLevel = False
.Parent = PictureBox1
.BringToFront()
.TransparencyKey = SystemColors.Control
.BackgroundImage = bm
.Show()
End With
End Sub

Ken
-----------------
"Ricardo Furtado" <Ri************@discussions.microsoft.com> wrote in
message news:16**********************************@microsof t.com...
in my app i must have several pictureboxes over the others. Some
pictureboxes
just have a couple of lines or rectangles, and absolutly nothing more but
the
image is an .BMP. So, my problem is that i need to see whats beind those
pictureboxes and at the same time showing, the lines and rectangles that
exist on the pictureboxes that are at the top. Because i just can't copy
the
image to the other picturebox (because i'll have to be able to control
that
image, later) i need to know how can i turn transparant the pictureboxes
that
are at the top. I've tryed the following code but it didn't work because
what
it does is to copy the background color of the main picturebox to the
picturebox at the top

dim Logo as new Bitmap(CompanyLogo.Image)
Logo.MakeTransparent(Logo.GetPixel(1,1))
CompanyLogo.Image=Logo;

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.