Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - generation of PNG in asp.net failed

 
Thread Tools Search this Thread
Old 05-19-2004, 08:51 AM   #1
Default generation of PNG in asp.net failed


<%@ Page Language = "VB" ContentType="image/Png" %>
<%@ Import Namespace = "System.Drawing"%>
<%@ Import Namespace = "System.Drawing.Imaging"%>
<%@ Import Namespace = "System.Drawing.Drawing2D"%>

<%
Response.Clear()
Dim height As integer = 100
Dim width As integer = 200

Dim bmp As New Bitmap(width, height, PixelFormat.Format24bppRgb)
Dim g As Graphics = Graphics.FromImage(bmp)

g.SmoothingMode = SmoothingMode.AntiAlias
g.Clear(Color.White)
g.FillRectangle(New SolidBrush(Color.LightGray), 1, 1, 150, 50)
g.DrawString("Zone", New Font("Verdana", 10), SystemBrushes.WindowText, New
PointF(10, 15))

bmp.Save(Response.OutputStream, ImageFormat.Png)
g.Dispose()
bmp.Dispose()
Response.End()

%>

Error Msg
Exception Details: System.Runtime.InteropServices.ExternalException: A
generic error occurred in GDI+.

I wonder if i could generate png in asp.net by using "Dim bmp As New
Bitmap(width, height, PixelFormat.Format24bppRgb)" that?

If not so, what i should use?

Thank you.

Regards,
Angus




angus
  Reply With Quote
Old 05-19-2004, 09:14 AM   #2
Patrice
 
Posts: n/a
Default Re: generation of PNG in asp.net failed
What if you "g.dispose" before saving ?

Patrice


"angus" <> a écrit dans le message de
news:...
> <%@ Page Language = "VB" ContentType="image/Png" %>
> <%@ Import Namespace = "System.Drawing"%>
> <%@ Import Namespace = "System.Drawing.Imaging"%>
> <%@ Import Namespace = "System.Drawing.Drawing2D"%>
>
> <%
> Response.Clear()
> Dim height As integer = 100
> Dim width As integer = 200
>
> Dim bmp As New Bitmap(width, height, PixelFormat.Format24bppRgb)
> Dim g As Graphics = Graphics.FromImage(bmp)
>
> g.SmoothingMode = SmoothingMode.AntiAlias
> g.Clear(Color.White)
> g.FillRectangle(New SolidBrush(Color.LightGray), 1, 1, 150, 50)
> g.DrawString("Zone", New Font("Verdana", 10), SystemBrushes.WindowText,

New
> PointF(10, 15))
>
> bmp.Save(Response.OutputStream, ImageFormat.Png)
> g.Dispose()
> bmp.Dispose()
> Response.End()
>
> %>
>
> Error Msg
> Exception Details: System.Runtime.InteropServices.ExternalException: A
> generic error occurred in GDI+.
>
> I wonder if i could generate png in asp.net by using "Dim bmp As New
> Bitmap(width, height, PixelFormat.Format24bppRgb)" that?
>
> If not so, what i should use?
>
> Thank you.
>
> Regards,
> Angus
>
>





Patrice
  Reply With Quote
Old 05-19-2004, 10:26 AM   #3
angus
 
Posts: n/a
Default Re: generation of PNG in asp.net failed
the same error happened also.

by the way, if i changed

> > bmp.Save(Response.OutputStream, ImageFormat.Png)


to

bmp.Save(Response.OutputStream, ImageFormat.Jpeg)
as well as change the contenttype to "contenttype='image/jpeg'

every thing works fine.


"Patrice" <> wrote in message
news:...
> What if you "g.dispose" before saving ?
>
> Patrice
>
>
> "angus" <> a écrit dans le message de
> news:...
> > <%@ Page Language = "VB" ContentType="image/Png" %>
> > <%@ Import Namespace = "System.Drawing"%>
> > <%@ Import Namespace = "System.Drawing.Imaging"%>
> > <%@ Import Namespace = "System.Drawing.Drawing2D"%>
> >
> > <%
> > Response.Clear()
> > Dim height As integer = 100
> > Dim width As integer = 200
> >
> > Dim bmp As New Bitmap(width, height, PixelFormat.Format24bppRgb)
> > Dim g As Graphics = Graphics.FromImage(bmp)
> >
> > g.SmoothingMode = SmoothingMode.AntiAlias
> > g.Clear(Color.White)
> > g.FillRectangle(New SolidBrush(Color.LightGray), 1, 1, 150, 50)
> > g.DrawString("Zone", New Font("Verdana", 10), SystemBrushes.WindowText,

> New
> > PointF(10, 15))
> >
> > bmp.Save(Response.OutputStream, ImageFormat.Png)
> > g.Dispose()
> > bmp.Dispose()
> > Response.End()
> >
> > %>
> >
> > Error Msg
> > Exception Details: System.Runtime.InteropServices.ExternalException: A
> > generic error occurred in GDI+.
> >
> > I wonder if i could generate png in asp.net by using "Dim bmp As New
> > Bitmap(width, height, PixelFormat.Format24bppRgb)" that?
> >
> > If not so, what i should use?
> >
> > Thank you.
> >
> > Regards,
> > Angus
> >
> >

>
>





angus
  Reply With Quote
Old 05-19-2004, 11:02 AM   #4
Patrice
 
Posts: n/a
Default Re: generation of PNG in asp.net failed
I made a search about this weird issue and found that according to
http://www.c-sharpcorner.com/Code/20...orkWithPNG.asp the PNG file
format requires a seekable stream...


"angus" <> a écrit dans le message de
news:...
> the same error happened also.
>
> by the way, if i changed
>
> > > bmp.Save(Response.OutputStream, ImageFormat.Png)

>
> to
>
> bmp.Save(Response.OutputStream, ImageFormat.Jpeg)
> as well as change the contenttype to "contenttype='image/jpeg'
>
> every thing works fine.
>
>
> "Patrice" <> wrote in message
> news:...
> > What if you "g.dispose" before saving ?
> >
> > Patrice
> >
> >
> > "angus" <> a écrit dans le message de
> > news:...
> > > <%@ Page Language = "VB" ContentType="image/Png" %>
> > > <%@ Import Namespace = "System.Drawing"%>
> > > <%@ Import Namespace = "System.Drawing.Imaging"%>
> > > <%@ Import Namespace = "System.Drawing.Drawing2D"%>
> > >
> > > <%
> > > Response.Clear()
> > > Dim height As integer = 100
> > > Dim width As integer = 200
> > >
> > > Dim bmp As New Bitmap(width, height, PixelFormat.Format24bppRgb)
> > > Dim g As Graphics = Graphics.FromImage(bmp)
> > >
> > > g.SmoothingMode = SmoothingMode.AntiAlias
> > > g.Clear(Color.White)
> > > g.FillRectangle(New SolidBrush(Color.LightGray), 1, 1, 150, 50)
> > > g.DrawString("Zone", New Font("Verdana", 10),

SystemBrushes.WindowText,
> > New
> > > PointF(10, 15))
> > >
> > > bmp.Save(Response.OutputStream, ImageFormat.Png)
> > > g.Dispose()
> > > bmp.Dispose()
> > > Response.End()
> > >
> > > %>
> > >
> > > Error Msg
> > > Exception Details: System.Runtime.InteropServices.ExternalException: A
> > > generic error occurred in GDI+.
> > >
> > > I wonder if i could generate png in asp.net by using "Dim bmp As New
> > > Bitmap(width, height, PixelFormat.Format24bppRgb)" that?
> > >
> > > If not so, what i should use?
> > >
> > > Thank you.
> > >
> > > Regards,
> > > Angus
> > >
> > >

> >
> >

>
>





Patrice
  Reply With Quote
Old 05-19-2004, 12:34 PM   #5
Hans Kesting
 
Posts: n/a
Default Re: generation of PNG in asp.net failed
MemoryStream io = new MemoryStream();
bmp.Save(io, ImageFormat.Png);
Response.BinaryWrite( io.GetBuffer() );


"Patrice" <> wrote in message news:...
> I made a search about this weird issue and found that according to
> http://www.c-sharpcorner.com/Code/20...orkWithPNG.asp the PNG file
> format requires a seekable stream...
>
>
> "angus" <> a écrit dans le message de
> news:...
> > the same error happened also.
> >
> > by the way, if i changed
> >
> > > > bmp.Save(Response.OutputStream, ImageFormat.Png)

> >
> > to
> >
> > bmp.Save(Response.OutputStream, ImageFormat.Jpeg)
> > as well as change the contenttype to "contenttype='image/jpeg'
> >
> > every thing works fine.
> >
> >
> > "Patrice" <> wrote in message
> > news:...
> > > What if you "g.dispose" before saving ?
> > >
> > > Patrice
> > >
> > >
> > > "angus" <> a écrit dans le message de
> > > news:...
> > > > <%@ Page Language = "VB" ContentType="image/Png" %>
> > > > <%@ Import Namespace = "System.Drawing"%>
> > > > <%@ Import Namespace = "System.Drawing.Imaging"%>
> > > > <%@ Import Namespace = "System.Drawing.Drawing2D"%>
> > > >
> > > > <%
> > > > Response.Clear()
> > > > Dim height As integer = 100
> > > > Dim width As integer = 200
> > > >
> > > > Dim bmp As New Bitmap(width, height, PixelFormat.Format24bppRgb)
> > > > Dim g As Graphics = Graphics.FromImage(bmp)
> > > >
> > > > g.SmoothingMode = SmoothingMode.AntiAlias
> > > > g.Clear(Color.White)
> > > > g.FillRectangle(New SolidBrush(Color.LightGray), 1, 1, 150, 50)
> > > > g.DrawString("Zone", New Font("Verdana", 10),

> SystemBrushes.WindowText,
> > > New
> > > > PointF(10, 15))
> > > >
> > > > bmp.Save(Response.OutputStream, ImageFormat.Png)
> > > > g.Dispose()
> > > > bmp.Dispose()
> > > > Response.End()
> > > >
> > > > %>
> > > >
> > > > Error Msg
> > > > Exception Details: System.Runtime.InteropServices.ExternalException: A
> > > > generic error occurred in GDI+.
> > > >
> > > > I wonder if i could generate png in asp.net by using "Dim bmp As New
> > > > Bitmap(width, height, PixelFormat.Format24bppRgb)" that?
> > > >
> > > > If not so, what i should use?
> > > >
> > > > Thank you.
> > > >
> > > > Regards,
> > > > Angus
> > > >
> > > >
> > >
> > >

> >
> >

>
>





Hans Kesting
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
viewstate MAC failed in asp.net 2.0 while postback the page azraffarveen Software 0 05-12-2009 03:24 PM
ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method) msandlana Software 0 04-25-2008 06:37 AM
ASP.NET 2.0 application does not run in WIN2k3 johnfraj Software 0 04-19-2007 08:27 AM
As growth slows, Hollywood faces a DVD standoff. Allan DVD Video 0 07-11-2005 02:10 PM
Second Generation Blu-ray Products To Be Rolled Out At Year's End. Allan DVD Video 0 03-16-2005 10:18 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46