Dynamic Image Titles
ASP.net is getting to be a lot cooler as I find out more about what I can do. I’m now dynamically creating the text headers for each blog entry. And it was really simple to do. Here’s how it’s done.
Bitmap imageForText;
Font drawFont = new Font(“AvantGarde BK BT”,16,FontStyle.Bold);
imageForText = new Bitmap(500,30,PixelFormat.Format32bppPArgb);
Graphics myGraphics;
myGraphics = Graphics.FromImage(imageForText);
mySize = myGraphics.MeasureString(text,drawFont);
myGraphics.Clear(Color.White);
myGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//Makes a shadow
myGraphics.DrawString(text,drawFont,new SolidBrush(Color.FromArgb(229,229,229)),2,2);
myGraphics.DrawString(text,drawFont,new SolidBrush(Color.FromArgb(140,31,57)),0,0);
imageForText.Save(Response.OutputStream,ImageFormat.Jpeg);
try{
imageForText.Save(Server.MapPath(“images/textheaders/”)+
text+”.jpg”,ImageFormat.Jpeg);
}
catch(Exception exc){}
Response.Flush();
//Clean Up
imageForText.Dispose();
The try ... catch block is used in case there is a funky character in the title that can’t be saved to file, then I just ignore it.
Nice eh?
Search
Archives
Stuff Dan Likes
This text is not inteneded to be seen. Rather, it is junk text to force themes with auto widths to extend to there full measures. This text is not inteneded to be seen. Rather, it is junk text to force themes with auto widths to extend to there full measures. This text is not inteneded to be seen. Rather, it is junk text to force themes with auto widths to extend to there full measures.
Stuff Tammy Likes
This text is not inteneded to be seen. Rather, it is junk text to force themes with auto widths to extend to there full measures. This text is not inteneded to be seen. Rather, it is junk text to force themes with auto widths to extend to there full measures. This text is not inteneded to be seen. Rather, it is junk text to force themes with auto widths to extend to there full measures.









