ナビゲーション リンクのスキップトップページ > コードの破片から > 動的な画像を出力
▼ 動的な画像を出力 ▼

  動的なXMLやCSSを出力と同様にContentTypeを指定する事によってASP.NETを利用して動的な画像を出力する事が出来ます。

動的な画像を出力

♣ aspxファイル

<%@ Page language="c#" Inherits="WebApplication" %>


♣ csファイル

using System;
using System.Drawing;
using System.Drawing.Imaging;

public class ShowImage : System.Web.UI.Page
{
    private void Page_Load(object sender, System.EventArgs e)
    {
        Response.ContentType = "image/jpeg";

        Image bitmap = Bitmap.FromFile(Request.MapPath("cultuer.jpg"));
        Font fn = new Font("MS UI Gothic",3);
        Graphics gr = Graphics.FromImage(bitmap);

        gr.DrawString(DateTime.UtcNow.ToString("r"),fn,Brushes.White,0,0);
        bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);

        gr.Dispose();
        bitmap.Dispose();
    }
}


♣ 実行例

作成されたファイル


Continue
ナビゲーション リンクのスキップトップページ > コードの破片から > 動的な画像を出力

2008年ですね。[1]
♥ 2008年01月01日 00:00:00

自由なスレ[3]
♥ 2007年09月22日 20:51:58

2007年ですね。[1]
♥ 2007年01月01日 00:00:00

こみゅぷらす発足[1]
♥ 2006年12月01日 12:01:23

TechED2006 日記[5]
♥ 2006年09月11日 18:44:51


RSS : FooPah!の更新情報
RSS : 掲示板全体の投稿情報
Copyright(C)2001-2008 FooPah!, All rights reserved.