Crashing Code
-
I used http://www.codeproject.com/cs/media/perpxalpha\_sharp.asp to create a non-rectangular window. Then I tried to add a Label Form, but that didn't work (didn't show up). Therefore I thought that this maybe wouldn't be possible when you have a this type of window and tried directly to draw strings in my loaded bitmap:
Graphics g = Graphics.FromImage(newBitmap); newBitmap.Dispose(); Font font = this.Font; Brush brush = new SolidBrush(Color.White); g.DrawString("Hallo wie geht es dir?",font,brush, 50,50); g.DrawImage(newBitmap,0,0); bitmap = newBitmap;
newBitmap contains the loaded png (with alpha mask) image. The assignment of bitmap seems to crash (System.ArgumentException) because I disposed newBitmap. But why? I however assigned newBitmap again with g.DrawImage... -
I used http://www.codeproject.com/cs/media/perpxalpha\_sharp.asp to create a non-rectangular window. Then I tried to add a Label Form, but that didn't work (didn't show up). Therefore I thought that this maybe wouldn't be possible when you have a this type of window and tried directly to draw strings in my loaded bitmap:
Graphics g = Graphics.FromImage(newBitmap); newBitmap.Dispose(); Font font = this.Font; Brush brush = new SolidBrush(Color.White); g.DrawString("Hallo wie geht es dir?",font,brush, 50,50); g.DrawImage(newBitmap,0,0); bitmap = newBitmap;
newBitmap contains the loaded png (with alpha mask) image. The assignment of bitmap seems to crash (System.ArgumentException) because I disposed newBitmap. But why? I however assigned newBitmap again with g.DrawImage...Draw image does not assign a bitmap, I'm suprised it isn't crashing on you at g.DrawImage line. Don't dispose the newBitmap until you're really done with it; or dispose it, then assign it again with
newBitmap = new Bitmap()
.
Tech, life, family, faith: Give me a visit. Judah Himango
-
Draw image does not assign a bitmap, I'm suprised it isn't crashing on you at g.DrawImage line. Don't dispose the newBitmap until you're really done with it; or dispose it, then assign it again with
newBitmap = new Bitmap()
.
Tech, life, family, faith: Give me a visit. Judah Himango