c#を使用してasp.netページでGDIを使用して画像を作成するチュートリアルを行っているだけです
私のコードは以下です
html ページ コード
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Image1.aspx.cs" Inherits="GDI_1.Image1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Image runat="server" ID="img" ImageUrl="Image1.aspx" />
</div>
</form>
</body>
</html>
asp.net page behind code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace GDI_1
{
public partial class Image1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Bitmap image = new Bitmap(300, 50);
Graphics g = Graphics.FromImage(image);
g.FillRectangle(Brushes.Red, 1, 1, 298, 48);
Font font = new Font("Impact", 20, FontStyle.Regular);
g.DrawString("test text", font, Brushes.Yellow, 10, 5);
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
g.Dispose();
image.Dispose();
}
}
}
私の問題は、それをコンパイルしてページを表示すると、これが大量に表示されることです
GIF89a,2�3f���++3+f+�+�+�UU3UfU�U�U�3�f��������3�f��������3� f��������3�f������3333f3�3�3�3+3+33+f3+�3+�3+�3U3U33Uf3U�3U�3U�3�3�33�f3� �3�3�3�3�33�f3�3�3�3�3�33�f3�3�3�3�3�33�f3�3�3�ff3fff �f�f�f+f+3f+ff+�f+�f+�fUfU3fUffU�fU�fU�f�f�3f�ff�f�f�f�f�3f�ff�f�� f��f�f�3f�ff�f�f�f�f�3f�ff�f�f����3�f���̙��+�+3�+f�+ ��+̙
そしてすべてhtmlタグの前に
ありがとう