Page 1 of 1

Transparent images in VB

Posted: Tue Apr 29, 2008 1:10 pm
by mr_penguin
I'm trying to get an image to fade from solid to transparent. I'm using photoshop to make the image but when I use it in VB it makes the transparent part white. I've tried using different formats and using an alpha layer.

Also I'm trying to make a TrackBar control the opacity of the form but I can't seem to get it to work right. This is what I've done:

Code: Select all

Private Sub TrackBar1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Form1.Opacity = Me.TrackBar1.Value
End Sub
Doing that just makes the opacity 0 or 100, I've set the maximum value to 100 and the min to 0 but that still didn't work.

Posted: Tue Apr 29, 2008 1:17 pm
by Patrickssj6
Opacity goes from 0 to 1 in floating point numbers e.g. 0.1 makes it 10% transparent.

Posted: Tue Apr 29, 2008 3:14 pm
by mr_penguin
so I should leave the code the same but change it to:

Form1.Opacity = Me.TrackBar1.Value / 100

Edit: thats works

Posted: Wed Apr 30, 2008 10:38 am
by Patrickssj6
How about you try it... :wink:

Posted: Wed Apr 30, 2008 2:47 pm
by Dagger13
or you can just make the trackbar 0 to 1
for the other thing i found one on a vb site i forgot witch one but maybe you can google it then if you find one with a search box then search w/e on that site


i seen the code before a long time ago tho but i know it was like one line to change the alpha to 0(or anything) and it had "matrix" in it

Posted: Wed Apr 30, 2008 5:22 pm
by Jdogg
I had this probme before
Here it is.

Code: Select all

Dim opac as integer
opac = TrackBar1.Value * 0.01
Me.Opacity = opac

Posted: Thu May 01, 2008 12:33 pm
by mr_penguin
Well now that the least needed fix is solved, how can I get transparent images to work?