setting a specific color to transparency on a picture box

Joined
Jun 29, 2006
Messages
6
Location
Seaford, LINY---Las Vegas, NV
Programming Experience
1-3
I'm working on my final project for school and me and my group decided to make a RPG maker. I have been put in charge of databasing and creating the character editor. I have been going nuts trying to figure out how to set the background color on my character sheet to transparent for display purposes and i finally figured it out.

basically im displaying two picture boxs:
the first shows the entire char sheet
the second pulls pictures parts of the first picture to display movement

here's the code maybe someone else will find it useful:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static X As Integer = 0
Static Y As Integer = 0
Dim iLeft As Integer = 24 * X
Dim iTop As Integer = 32 * Y
X += 1
If X = 3 Then
Y += 1
X = 0
End If
If Y = 4 Then Y = 0
Dim img2 As Bitmap = Bitmap.FromFile("C:\Documents and Settings\ITT Tech Student\My Documents\Visual Studio 2005\Projects\CharacterStats\CharacterStats\res_viewer.bmp")

img2.MakeTransparent()

PictureBox1.Image = img2

PictureBox2.CreateGraphics.Clear(PictureBox2.BackColor)

PictureBox2.CreateGraphics().DrawImage(PictureBox1.Image,
New Rectangle(0, 0, PictureBox2.Width, PictureBox2.Height), New Rectangle(iLeft, iTop, 24, 32), System.Drawing.GraphicsUnit.Pixel)
End Sub
 
RPG Maker? Wow! But why don't u use DX technology? It's way easier...
Anyway, i don't think u should use the PictureBox. Try with the Panel Control. PictureBoxes don't support transparency, as far as i can remember.
 
the PBoxes seem to support the transparency ok.
Were not just using vb, this is our final project for the two years weve been going to school, so were supposed to show what weve learned in all the different areas. The Character editor is being written in vb the map editor is being written in C# and the game engine is being done in DX.

Doing the whole game in VB would be way too much work and wouldnt look too well
 
Back
Top