示例#1
0
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            IBarCodeSettings settings =
                QueryStringSerializer.ParseQueryString(context.Request.QueryString);

            BarCodeGenerator generator = new BarCodeGenerator(settings);

            // TODO: put the image format in the settings??
            ImageFormat imageFormat = ImageFormat.Png;
            string      contentType = GetContentType(imageFormat);

            context.Response.ContentType = contentType;

            using (var image = generator.GenerateImage())
                using (var ms = new MemoryStream()) {
                    image.Save(ms, imageFormat);
                    ms.Seek(0, SeekOrigin.Begin);
                    CopyData(ms, context.Response.OutputStream);
                }
        }