I want to move the PictureBox BackgroundImage to get the sprites functionality, so I inherited PictureBox and overrided OnPaintBackground:
public class PictureBox1 : PictureBox
{
int bgX = 0, bgY = 0;
public void SetImagePos(int X, int Y) {
bgX = X;
bgY = Y;
Invalidate();
Update();
}
protected override void OnPaintBackground(PaintEventArgs e) {
//base.OnPaintBackground(e);
e.Graphics.DrawImage(BackgroundImage, -bgX, -bgY, BackgroundImage.Width, BackgroundImage.Height);
}
}
This, however, discards the transparency. the commented //base.OnPaintBackground(e);
brings the transparency back, but also with the original image on the background. I also tried e.Graphics.Clear(Color.Transparent)
, but the background color is still velvet black instead. What am I missing?
I want a simple solution, performance is not an issue.