using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Birdshome
{
/// <summary>
/// Summary description for _Default.
/// </summary>
public class _Default : System.Web.UI.Page
{
int m_Unit = 3;
private void Page_Load( object sender, System.EventArgs e)
{
// Put user code to initialize the page here
int counter_width = 32/8;
int counter_height =16;
Bitmap bmp = new Bitmap(counter_width*m_Unit*8, counter_height*m_Unit);
GenerateBitmap(bmp);
Response.Clear();
Response.ContentType = "image/jpeg";
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
}
Web Form Designer generated code
private void GenerateBitmap(Bitmap bmp)
{
// #define counter_width 32
// #define counter_height 16
int counter_width = 32/8;
int counter_height =16;
byte [] counter_bits = new byte[]
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3E, 0x1C, 0x7F, 0x7F, 0x63, 0x06, 0x03, 0x03,
0x60, 0x03, 0x03, 0x03, 0x60, 0x03, 0x03, 0x03,
0x3C, 0x3F, 0x3F, 0x3F, 0x60, 0x63, 0x60, 0x60,
0x60, 0x63, 0x60, 0x60, 0x60, 0x63, 0x60, 0x60,
0x63, 0x63, 0x63, 0x63, 0x3E, 0x3E, 0x3E, 0x3E
};
Graphics g = Graphics.FromImage(bmp);
for( int i=0 ; i < counter_height ; i++ )
{
for( int j=0 ; j < counter_width ; j++ )
{
byte by = counter_bits[counter_width*i+j];
for( int k=0 ; k < 8 ; k++ )
{
byte bit = 0;
bit = ( byte)(by & 0x01);
Rectangle rect = new Rectangle(k*m_Unit+j*8*m_Unit, i*m_Unit, m_Unit, m_Unit);
Brush brush;
if( bit == 0x01 )
{
brush = Brushes.Yellow;
}
else
{
brush = Brushes.Blue;
}
g.FillRectangle(brush, rect);
by = ( byte)(by >> 1);
}
}
}
}
}
}
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Birdshome
{
/// <summary>
/// Summary description for _Default.
/// </summary>
public class _Default : System.Web.UI.Page
{
int m_Unit = 3;
private void Page_Load( object sender, System.EventArgs e)
{
// Put user code to initialize the page here
int counter_width = 32/8;
int counter_height =16;
Bitmap bmp = new Bitmap(counter_width*m_Unit*8, counter_height*m_Unit);
GenerateBitmap(bmp);
Response.Clear();
Response.ContentType = "image/jpeg";
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
}
Web Form Designer generated code
private void GenerateBitmap(Bitmap bmp)
{
// #define counter_width 32
// #define counter_height 16
int counter_width = 32/8;
int counter_height =16;
byte [] counter_bits = new byte[]
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3E, 0x1C, 0x7F, 0x7F, 0x63, 0x06, 0x03, 0x03,
0x60, 0x03, 0x03, 0x03, 0x60, 0x03, 0x03, 0x03,
0x3C, 0x3F, 0x3F, 0x3F, 0x60, 0x63, 0x60, 0x60,
0x60, 0x63, 0x60, 0x60, 0x60, 0x63, 0x60, 0x60,
0x63, 0x63, 0x63, 0x63, 0x3E, 0x3E, 0x3E, 0x3E
};
Graphics g = Graphics.FromImage(bmp);
for( int i=0 ; i < counter_height ; i++ )
{
for( int j=0 ; j < counter_width ; j++ )
{
byte by = counter_bits[counter_width*i+j];
for( int k=0 ; k < 8 ; k++ )
{
byte bit = 0;
bit = ( byte)(by & 0x01);
Rectangle rect = new Rectangle(k*m_Unit+j*8*m_Unit, i*m_Unit, m_Unit, m_Unit);
Brush brush;
if( bit == 0x01 )
{
brush = Brushes.Yellow;
}
else
{
brush = Brushes.Blue;
}
g.FillRectangle(brush, rect);
by = ( byte)(by >> 1);
}
}
}
}
}
}
本文转自博客园鸟食轩的博客,原文链接:http://www.cnblogs.com/birdshome/,如需转载请自行联系原博主。