Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / September 2005

Tip: Looking for answers? Try searching our database.

making image and picturebox transparent

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ricardo Furtado - 15 Sep 2005 08:51 GMT
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;
Ken Tucker [MVP] - 15 Sep 2005 12:10 GMT
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
-----------------
> in my app i must have several pictureboxes over the others. Some
> pictureboxes
[quoted text clipped - 16 lines]
> Logo.MakeTransparent(Logo.GetPixel(1,1))
> CompanyLogo.Image=Logo;

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.