954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Can't enable Picturebox transparency

Hello there. I'm making a simple Pacman game because I'm practicing C# (I've never programmed in C# before), but I ran into a problem. Here is my code:

void addGhost(object sender, EventArgs ea) {
 	Random random = new Random();
 	int ghostNum = random.Next(5);
 	
	// Here I use and enum I've created before, this enum haves the ghosts names, so I can load the images from the *.resx file

 	Bitmap img = (Bitmap) res.GetObject( Enum.GetName(typeof(ghostName),ghostNum).ToLower());
 	//img.MakeTransparent(img.GetPixel(1,1)); // I'm loading my images from *.png's with transparency already enabled
 		
 	GhostClass aux = new GhostClass(); //Ghost class extends PictureBox
 	aux.Parent = this;
 	aux.Location = new Point(random.Next(512), random.Next(512)); // just random positions
 	aux.Size = new Size(23, 23);
 	aux.BorderStyle = BorderStyle.None;
 	aux.SizeMode = PictureBoxSizeMode.Normal;
 	aux.Image = img;
 	aux.BringToFront();
 		
 	ghostArray.Add(aux); // my ghost array
 }


As you can see, I have a resources file where I have all my loaded images (the map and ghosts, all of them loaded from *.png's), but once the images are shown in the frame, looks like the transparency works only in the grey background of the window application, but not between images.

I have a button to add ghost, so this method is the event function. I hope you can help me, I've searched through the web and I didn't find a specific solution for my problem

For the development I'm using SharpDevelop IDE

AurosGamma
Newbie Poster
11 posts since Jun 2011
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: