Advertisement
Advertisement
| 04.03.2008 at 04:07PM PDT, ID: 23294551 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: |
<%@ Page Language="C#" %>
<%@Import Namespace="System" %>
<%@Import Namespace="System.IO" %>
<%@Import Namespace="System.Reflection" %>
<%@Import Namespace="System.Drawing" %>
<%@Import Namespace="System.Drawing.Imaging" %>
<%@Import Namespace="System.Drawing.Drawing2D" %>
<%@Import Namespace="System.Drawing.Text" %>
<%Response.ContentType="image/jpg";%>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
Bitmap myBitmap = new Bitmap(10,100);
//"C:\\inetpub\\wwwroot\\winxp2.jpg"
//Graphics grf = Graphics.FromImage(myBitmap);
/*
System.Drawing.Graphics formGraphics = Graphics.FromImage(myBitmap);
formGraphics.Clear(Color.White);
string drawString = "Sample Text";
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
float x = 0.0f;
float y = 0.0f;
formGraphics.DrawString(drawString, drawFont, drawBrush, x, y);
//myBitmap.Save("C:\\inetpub\\wwwroot\\winxp23.jpg");
myBitmap.Save(Response.OutputStream, ImageFormat.Gif);
drawFont.Dispose();
drawBrush.Dispose();
formGraphics.Dispose();
*/
//Image i = Image.FromFile(filename);
// Set Content Type to GIF
Response.ContentType = "image/gif";
String theText = "123456789";
// Create Image
Bitmap objBitmapTMP = new Bitmap(1,1);
Graphics g = Graphics.FromImage(objBitmapTMP);//CreateGraphics();
Font fontDesc = new Font("IDAutomationHC39M-Scaled",10);
SizeF stringSize = g.MeasureString(theText,fontDesc);
int width =(int) stringSize.Width;
int height = (int) stringSize.Height;
Bitmap objBitmap = new Bitmap(width, height);
Graphics objGraphics = Graphics.FromImage(objBitmap);
objGraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
// Create Font and String Format
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Near;
stringFormat.LineAlignment = StringAlignment.Center;
//SizeF stringSize = new SizeF();
//stringSize = e.Graphics.MeasureString(theText, fontDesc);
// Draw the String
objGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
objGraphics.TextContrast = 0;
objGraphics.InterpolationMode=InterpolationMode.HighQualityBicubic;
//objGraphics.SetResolution(600f, 600f);
objBitmap.SetResolution(1200f, 1200f);
objGraphics.DrawString(theText, fontDesc, new SolidBrush(Color.Black), new Rectangle(0, 0, width, height), stringFormat);
// Save the Image to the OutputStream
objBitmap.Save(Response.OutputStream, ImageFormat.Gif);
// Clean Up
objGraphics.Dispose();
}
</script>
|