![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
exact code: try { Bitmap err_bmp = new Bitmap(200, 50, PixelFormat.Format16bppRgb555); err_bmp.SetResolution(72, 72); Graphics err_g = Graphics.FromImage(err_bmp); Font err_f = new Font("Arial", 8); SolidBrush err_b = new SolidBrush(Color.White); err_g.FillRectangle(err_b, 0, 0, err_bmp.Width, err_bmp.Height); err_b.Color = Color.Black; err_g.DrawString(some_text, err_f, err_b, new RectangleF(new PointF(0, 0), new SizeF(err_bmp.Width, err_bmp.Height))); Response.ContentType = "image/bmp"; err_bmp.Save(Response.OutputStream, ImageFormat.Bmp); ... } catch (Exception err) { err_g.DrawString(err.Message, err_f, err_b, new RectangleF(new PointF(0, 0), new SizeF(err_bmp.Width, err_bmp.Height))); err_bmp.Save("c:\\err.bmp"); } The last showed line inside try{} block (save to stream) raises "Generic error occurred in GDI+". But saving to a file (inside catch{} block) works well. I read the exception text inside the saved bmp. Any ideas? |
#3
| |||
| |||
|
|
exact code: try { Bitmap err_bmp = new Bitmap(200, 50, PixelFormat.Format16bppRgb555); err_bmp.SetResolution(72, 72); Graphics err_g = Graphics.FromImage(err_bmp); Font err_f = new Font("Arial", 8); SolidBrush err_b = new SolidBrush(Color.White); err_g.FillRectangle(err_b, 0, 0, err_bmp.Width, err_bmp.Height); err_b.Color = Color.Black; err_g.DrawString(some_text, err_f, err_b, new RectangleF(new PointF(0, 0), new SizeF(err_bmp.Width, err_bmp.Height))); Response.ContentType = "image/bmp"; err_bmp.Save(Response.OutputStream, ImageFormat.Bmp); ... } catch (Exception err) { err_g.DrawString(err.Message, err_f, err_b, new RectangleF(new PointF(0, 0), new SizeF(err_bmp.Width, err_bmp.Height))); err_bmp.Save("c:\\err.bmp"); } The last showed line inside try{} block (save to stream) raises "Generic error occurred in GDI+". But saving to a file (inside catch{} block) works well. I read the exception text inside the saved bmp. Any ideas? |
#4
| |||
| |||
|
|
Try disposing of your graphics object before saving to a stream. "TumurS" <spam_tumur (AT) magicnet (DOT) mn> wrote in message news:uwCsSdYjHHA.1624 (AT) TK2MSFTNGP06 (DOT) phx.gbl... exact code: try { Bitmap err_bmp = new Bitmap(200, 50, PixelFormat.Format16bppRgb555); err_bmp.SetResolution(72, 72); Graphics err_g = Graphics.FromImage(err_bmp); Font err_f = new Font("Arial", 8); SolidBrush err_b = new SolidBrush(Color.White); err_g.FillRectangle(err_b, 0, 0, err_bmp.Width, err_bmp.Height); err_b.Color = Color.Black; err_g.DrawString(some_text, err_f, err_b, new RectangleF(new PointF(0, 0), new SizeF(err_bmp.Width, err_bmp.Height))); Response.ContentType = "image/bmp"; err_bmp.Save(Response.OutputStream, ImageFormat.Bmp); ... } catch (Exception err) { err_g.DrawString(err.Message, err_f, err_b, new RectangleF(new PointF(0, 0), new SizeF(err_bmp.Width, err_bmp.Height))); err_bmp.Save("c:\\err.bmp"); } The last showed line inside try{} block (save to stream) raises "Generic error occurred in GDI+". But saving to a file (inside catch{} block) works well. I read the exception text inside the saved bmp. Any ideas? |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |