AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=319&pId=-1
Dynamic PNG images with ASP.NET and GDI+
page
by Chris Garrett
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 12063/ 16

Dynamic PNG images with ASP.NET and GDI+
Dynamic PNG images with ASP.NET and GDI+
by Chris Garrett

FAQ

Q: Why do I get "A generic error occurred in GDI+. " when I switch my working GIF to use PNG format instead?

A: You can''t use the Bitmap Save() method with a "non-seekable" stream. Some image formats require that the stream can seek.

Instead of streaming to the Response.OutputStream Save to a memory Stream, then copy from the memory Stream to the output Stream. See the example below.

Seeking? Seekable? What the - ?

"Seeking" is where the stream can be queried and the current position within a stream can be moved backwards and forwards.

Some streams, for example a network stream, have no concept of a current position so can not support seeking.

Creating and streaming a PNG with ASP.NET

Check out the source below which illustrates how to do this piece of stream gymnastics! It is a lot easier to do than it is to explain, honest ;O)

View Source
/chrisg/tools/view-png.aspx.aspx

/chrisg/tools/view-png.vb.aspx

Download
/chrisg/tools/download.asp?file=png.aspx

/chrisg/tools/download.asp?file=png.vb


Product Spotlight
Product Spotlight 

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-07 10:24:48 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search