Bitmap.MakeTransparent problem

J

James Dean

I am drawing to an offscreen bitmap various shapes and so on. I have
created a bitmap for this purpose. But the bitmap has a black background
so i used the make transparent method to clear the background. But i use
scroll bars if the image is too big for the client area. When i scroll
down the screen cannot redraw itself correctly. If i dont use the
transparent method and the background is black it does not do this. I
saw in the bitmap.drawbackground method that it does not recognize
transparent bitmaps.......how do i solve this problem to redraw the
screen correctly when scrolling through a transparent bitmap....here is
the method for scrolling event.

private void HandleScroll(Object sender, ScrollEventArgs se)
{
/* Create a graphics object and draw a portion
_canvasGraphics = pictureBox1.CreateGraphics();


_canvasGraphics.DrawImage(_canvasImage,
new Rectangle(0, 0, pictureBox1.Right - vScrollBar1.Width,
pictureBox1.Bottom - hScrollBar1.Height),
new Rectangle(hScrollBar1.Value, vScrollBar1.Value,
pictureBox1.Right - vScrollBar1.Width,
pictureBox1.Bottom - hScrollBar1.Height),
GraphicsUnit.Pixel);


pictureBox1.Update();


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top