A
Alphonse Giambrone
I am currently reading 'Programming The Web with Visual Basic .NET' and
have so far found it to be excellent. Downloaded all the code from Apress
and working in chapter 4, I get the error shown below.
I am running IIS5 on WinXP Pro.
Server Error in '/Chapter04' Application.
----------------------------------------------------------------------------
----
A generic error occurred in GDI+.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.
Source Error:
Line 76: .DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0)
Line 77:
Line 78: bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)
Line 79: m_iHeight = bmp.Height
Line 80: m_iWidth = bmp.Width
Source File: D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb Line: 78
Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +582
System.Drawing.Image.Save(String filename, ImageFormat format) +61
Chapter_04.ImageCreation.CreateImage(String Text, String& Path) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb:78
Chapter_04.ImageCreation.inimgGo_ServerClick(Object sender,
ImageClickEventArgs e) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb:40
System.Web.UI.HtmlControls.HtmlInputImage.OnServerClick(ImageClickEventArgs
e) +109
System.Web.UI.HtmlControls.HtmlInputImage.System.Web.UI.IPostBackEventHandle
r.RaisePostBackEvent(String eventArgument) +67
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573
--
Here is the full code for the routine:
Private Sub CreateImage(ByVal Text As String, _
ByRef Path As String)
Dim fnt As New Font("Verdana", 40)
Dim dummy As Bitmap = New Bitmap(1, 1)
Dim gfx As Graphics = Graphics.FromImage(dummy)
Dim size As SizeF = gfx.MeasureString(Text, fnt)
gfx.Dispose()
dummy = Nothing
Dim bmp As Bitmap = New Bitmap(CInt(size.Width), CInt(size.Height))
gfx = Graphics.FromImage(bmp)
With gfx
..CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality
..InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
..SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
..TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
..FillRectangle( _
New Drawing2D.LinearGradientBrush( _
New Point(0, CInt(size.Height) - 1), _
New Point(CInt(size.Width) - 1, 0), _
Color.Red, _
Color.Black), _
0, 0, CInt(size.Width), CInt(size.Height))
..DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0)
bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)
m_iHeight = bmp.Height
m_iWidth = bmp.Width
..Dispose()
End With
End Sub
Can anyone point me to a cause/fix??
Any help would be appreciated.
Alphonse Giambrone
Email: (e-mail address removed)
For email replace NOSPAM with agiam
have so far found it to be excellent. Downloaded all the code from Apress
and working in chapter 4, I get the error shown below.
I am running IIS5 on WinXP Pro.
Server Error in '/Chapter04' Application.
----------------------------------------------------------------------------
----
A generic error occurred in GDI+.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.
Source Error:
Line 76: .DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0)
Line 77:
Line 78: bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)
Line 79: m_iHeight = bmp.Height
Line 80: m_iWidth = bmp.Width
Source File: D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb Line: 78
Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +582
System.Drawing.Image.Save(String filename, ImageFormat format) +61
Chapter_04.ImageCreation.CreateImage(String Text, String& Path) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb:78
Chapter_04.ImageCreation.inimgGo_ServerClick(Object sender,
ImageClickEventArgs e) in
D:\Inetpub\wwwroot\Chapter04\ImageCreation.aspx.vb:40
System.Web.UI.HtmlControls.HtmlInputImage.OnServerClick(ImageClickEventArgs
e) +109
System.Web.UI.HtmlControls.HtmlInputImage.System.Web.UI.IPostBackEventHandle
r.RaisePostBackEvent(String eventArgument) +67
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573
--
Here is the full code for the routine:
Private Sub CreateImage(ByVal Text As String, _
ByRef Path As String)
Dim fnt As New Font("Verdana", 40)
Dim dummy As Bitmap = New Bitmap(1, 1)
Dim gfx As Graphics = Graphics.FromImage(dummy)
Dim size As SizeF = gfx.MeasureString(Text, fnt)
gfx.Dispose()
dummy = Nothing
Dim bmp As Bitmap = New Bitmap(CInt(size.Width), CInt(size.Height))
gfx = Graphics.FromImage(bmp)
With gfx
..CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality
..InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
..SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
..TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
..FillRectangle( _
New Drawing2D.LinearGradientBrush( _
New Point(0, CInt(size.Height) - 1), _
New Point(CInt(size.Width) - 1, 0), _
Color.Red, _
Color.Black), _
0, 0, CInt(size.Width), CInt(size.Height))
..DrawString(Text, fnt, New SolidBrush(Color.White), 0, 0)
bmp.Save(Path, System.Drawing.Imaging.ImageFormat.Gif)
m_iHeight = bmp.Height
m_iWidth = bmp.Width
..Dispose()
End With
End Sub
Can anyone point me to a cause/fix??
Any help would be appreciated.
Alphonse Giambrone
Email: (e-mail address removed)
For email replace NOSPAM with agiam