Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to make glass effect image in .NET/WinXP

How to make glass effect image in .NET/WinXP

Scheduled Pinned Locked Moved Visual Basic
csharpcomtutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    re infecta
    wrote on last edited by
    #1

    Is it possible to make a simple white bar that is see-through and has a smooth alpha-blended shadow? This is my goal: http://www.osx-e.com/screenshots/06\_47\_50\_RealDock.jpg I have a PNG image that is transparent. I imported it in my VB.net project, I set the background and transparent key to the same value, but I only get very ugly shadows. They are not alpha-blended at all. Have you tried making a glass-like image in .NET?

    S H 2 Replies Last reply
    0
    • R re infecta

      Is it possible to make a simple white bar that is see-through and has a smooth alpha-blended shadow? This is my goal: http://www.osx-e.com/screenshots/06\_47\_50\_RealDock.jpg I have a PNG image that is transparent. I imported it in my VB.net project, I set the background and transparent key to the same value, but I only get very ugly shadows. They are not alpha-blended at all. Have you tried making a glass-like image in .NET?

      S Offline
      S Offline
      salysle
      wrote on last edited by
      #2

      I generally build transparent GIFs; I originally build the icon as an image file in Freehand and then export the file as a gif and reopen it in Fireworks. From there I set up the transparency and save the gif. I have tried other image formats including PNG when I needed the effect and they always look bad; I have never had the problem with transparent GIFs. Also, if the image has a drop shadow, that usually will not work unless it was drawn on a surface with the exact same back color and the target location in the web page.

      R 1 Reply Last reply
      0
      • S salysle

        I generally build transparent GIFs; I originally build the icon as an image file in Freehand and then export the file as a gif and reopen it in Fireworks. From there I set up the transparency and save the gif. I have tried other image formats including PNG when I needed the effect and they always look bad; I have never had the problem with transparent GIFs. Also, if the image has a drop shadow, that usually will not work unless it was drawn on a surface with the exact same back color and the target location in the web page.

        R Offline
        R Offline
        re infecta
        wrote on last edited by
        #3

        The biggest problem is the shadows. I want them to look smooth independent of what surface they are drawn on. I think the solution is PNG because it supports more than 1 transparency key. But I don't know how advantage transparent PNG images in VB? How to make their multi-color transparency key work?

        T 1 Reply Last reply
        0
        • R re infecta

          The biggest problem is the shadows. I want them to look smooth independent of what surface they are drawn on. I think the solution is PNG because it supports more than 1 transparency key. But I don't know how advantage transparent PNG images in VB? How to make their multi-color transparency key work?

          T Offline
          T Offline
          The ANZAC
          wrote on last edited by
          #4

          if you have adobe photoshop, i'm sure you can design in image in there or in something like axialis icon workshop, that will get the right effect. It's just a matter of learning how to get it right.

          Posted by The ANZAC

          1 Reply Last reply
          0
          • R re infecta

            Is it possible to make a simple white bar that is see-through and has a smooth alpha-blended shadow? This is my goal: http://www.osx-e.com/screenshots/06\_47\_50\_RealDock.jpg I have a PNG image that is transparent. I imported it in my VB.net project, I set the background and transparent key to the same value, but I only get very ugly shadows. They are not alpha-blended at all. Have you tried making a glass-like image in .NET?

            H Offline
            H Offline
            hannesHTG
            wrote on last edited by
            #5

            Put two Buttons on your form named btnBlendShapes and btnDrawImages respectively. Add a picturebox, named pic. Type this : Import this

            Imports System.Drawing.Imaging

            Then,

            Private Sub btnBlendShapes\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBlendShapes.Click
            
                'alpha numbers has to be between values 0 and 255. 
                'alpha 0 is fully transparent while alpha 255 is fully opaque
            
                'of course, change any of the alpha values below depending on which color you want to be more or
                'less transparent or opaque
            
                'the first apha value to be fully visible
                Dim alphaValue As Integer = 255
            
                'the second alpha value will have some transparency
                Dim alphaValue2 As Integer = 155
            
                'create 2 brushes. 1 brush with the first alpha value and the second brush using the 2nd alpha 
                'value
                Dim aBrush As SolidBrush = New SolidBrush(Color.FromArgb(alphaValue, Color.Fuchsia))
                Dim aBrush2 As SolidBrush = New SolidBrush(Color.FromArgb(alphaValue2, Color.Goldenrod))
            
                'draw 2 rectangles, 1 with the first brush and the other rectangle using the 2nd brush
                pic.CreateGraphics.FillRectangle(aBrush, 0, 0, 100, 100)
                pic.CreateGraphics.FillRectangle(aBrush2, 50, 50, 100, 100)
            
            End Sub
            
            Private Sub btnDrawImages\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDrawImages.Click
            
                'the 2 images to use for the alpha blend. you may have to change the image paths to where the
                'images are on your computer. 
                Dim imagePath As String = "AW-9TriplePan2.gif"
                Dim imagePath2 As String = "AW-9TriplePan2.gif"
            
                'create 2 new images with the above filenames
                Dim img As Image = Image.FromFile(imagePath)
                Dim img2 As Image = Image.FromFile(imagePath2)
            
                'create 2 new ojects to use the ImageAttrubute class and the ColorMatrix Class
                Dim i As ImageAttributes = New ImageAttributes
                Dim c As ColorMatrix = New ColorMatrix
            
                'draw both images onto the picturebox control. the first image will not have any changes made to
                'any of its attributes.
                pic.CreateGraphics.DrawImage(img, 0, 0, 200, 150)
            
                'with matrix33 you can adjust the images alpha value
                'values I think are to be between 0 and 1. Ex: .3, .25, or .5 ect....
                c.Matrix33 = 0.45
                i.SetColorMatrix(c)
            
                'this 2nd image will have its maxtrix3
            
            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups