Mixed drawing : Graphics « Development « ASP.NET Tutorial






<%@ Page language="c#" Inherits="MixedDrawing" CodeFile="Default.aspx.cs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
    <title>MixedDrawing</title>
    </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
    </form>
  </body>
</HTML>

File: Default.aspx.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing.Drawing2D;
using System.IO;

public partial class MixedDrawing : System.Web.UI.Page
{
  protected void Page_Load(object sender, System.EventArgs e)
  {
    Bitmap image = new Bitmap(450, 100);
    Graphics g = Graphics.FromImage(image);

    g.SmoothingMode = SmoothingMode.AntiAlias;

    g.FillRectangle(Brushes.White, 0, 0, 450, 100);

    g.FillEllipse(Brushes.PaleGoldenrod, 120, 13, 300, 50);

    Font font = new Font("Harrington", 20, FontStyle.Bold);
    g.DrawString("Oranges are tasty!", font, Brushes.DarkOrange, 150, 20);

    System.Drawing.Image orangeImage = System.Drawing.Image.FromFile(Server.MapPath("oranges.gif"));
    g.DrawImageUnscaled(orangeImage, 0, 0);

    image.Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Gif);

    g.Dispose();
    image.Dispose();
  }

}








9.22.Graphics
9.22.1.Simple Drawing
9.22.2.Mixed drawing
9.22.3.ThumbmailViewer