テキストから画像を動的に生成し、asp.net Web サイトに既存の画像を作成しています。
コードは次のとおりです。
string barcode = Request.QueryString["BarCode"];
int w = barcode.Length * 40;
// Create a bitmap object of the width that we calculated and height of 100
Bitmap oBitmap = new Bitmap(w, 50);
// then create a Graphic object for the bitmap we just created.
Graphics oGraphics = Graphics.FromImage(oBitmap);
// Now create a Font object for the Barcode Font
// (in this case the IDAutomationHC39M) of 18 point size
Font oFont = new Font("BarcodeFont", 12);
// Let's create the Point and Brushes for the barcode
PointF oPoint = new PointF(2f, 2f);
SolidBrush oBrushWrite = new SolidBrush(Color.Black);
SolidBrush oBrush = new SolidBrush(Color.White);
// Now lets create the actual barcode image
// with a rectangle filled with white color
oGraphics.FillRectangle(oBrush, 0, 0, w, 100);
// We have to put prefix and sufix of an asterisk (*),
// in order to be a valid barcode
oGraphics.DrawString(barcode, oFont, oBrushWrite, oPoint);
// Then we send the Graphics with the actual barcode
Response.ContentType = "image/png";
oBitmap.Save(Response.OutputStream, ImageFormat.Png);
ご覧のとおり、ビットマップは保存され、ポストバック後に aspx ページに表示されます。私がしたいのは、ユーザーが Button1 をクリックすると、画像が生成され、サーバーに保存したりページに表示したりせずに、ブラウザーのダウンロード ウィンドウがポップアップすることです。これを行う方法?私を助けてください。