GDI+

APR 17 2008

Date Image Thing
Author: Joe Maddalone

I want to be trendy, too

For shiggles, I wanted to add a nice little trendy date format to my postings, but everything I found seemed a bit too wordy for me. It always looks like this:

<div class="post-date">
<span class="month">10</span>
<span class="day">04</span>
<span class="year">1977</span>
</div>

This site is dynamically generated, so it wouldn't take too much effort in order to implement such a structure, but I'm stubborn... so here goes

Overprocessed, Nerdy Post Date Image Generation


<%@ Import Namespace="System.Drawing" %>
 <%@ Import Namespace="System.Drawing.Imaging" %>
 <script language="VB" runat="server">
 Sub Page_Load(sender as Object, e as EventArgs)
 dim strDt as string = request.querystring("dt")
 dim strMonth as string = left(MonthName(Month(strDt)),3).ToUpper()
 dim strDay as string = Day(strDt).ToString()
 if strDay.Length=1
 	strDay="0" & strDay
 end if
 dim strYear as string = Year(strDt).ToString()
 
  Dim baseMap as Bitmap = new Bitmap(95, 13)
  '13 cuts it off, which looks cool -- see emersian.com
  Dim myGraphic as Graphics = Graphics.FromImage(baseMap)
  Dim upBrush as SolidBrush = new SolidBrush(Color.black)
  Dim downBrush as SolidBrush = new SolidBrush(Color.steelblue)
  Dim MonthFont as Font = new Font("tahoma", 11,FontStyle.Bold)
  Dim dtFont as Font = new Font("tahoma", 14,FontStyle.Bold)
  myGraphic.FillRectangle(new SolidBrush(Color.white), 0, 0, 100, 25)  
  myGraphic.DrawString(strMonth, MonthFont, upBrush, 0, 0)
  myGraphic.DrawString(strDay, MonthFont, downBrush, 30, 0)
  myGraphic.DrawString(strYear, MonthFont, upBrush, 50, 0)
  myGraphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias 
  
  Response.ContentType = "image/gif"
  baseMap.Save(Response.OutputStream, ImageFormat.GIF)

  myGraphic.Dispose()
  baseMap.Dispose()
 End Sub
 </script>
%>

Usage

< img src="dt.aspx?dt=DATE STRING HERE" />

3 Comments

OCT 28 2005

GDI+ Font Embedding
Author: Joe Maddalone

The Code: h1.aspx

Usage

Example

0 Comments

SEP 10 2005

Dynamic Color Shifting
Author: Joe Maddalone

The Code: colorshift.aspx

Usage

Example

4 Comments

SEP 10 2005

GDI+ Security String image
Author: Joe Maddalone

The Code: verify.aspx

Usage

Real Time Example

10 Comments

SEP 10 2005

Dynamic GDI+ meets CSS
Author: Joe Maddalone

The Code: nav.aspx

The Code 2: nav.html

The Result

click here

2 Comments

SEP 10 2005

Quick Watermark
Author: Joe Maddalone

The Code: watermark.aspx

Usage

Example

13 Comments

SEP 10 2005

Quick Dropshadow
Author: Joe Maddalone

The Code: shadow.aspx

Usage

Example

1 Comments


LATEST POSTS

Portfolio of the Future Just a random bit of sketching I was doing. Random things this month On my way to the interwebs I recall all I have learned today. CSV Splitter Reinventing the wheel one app at a time. Competetive Data Scraping Not yet an Olympic sport. Date Image Thing GDI+ to overprocess blog post dates!

ADS

MOST POPULAR

Multiple IEs in Windows Firefox Vs. The World Who Is Xperya? ActionScript Form Fields Quick Watermark IE 7 beta 2 standalone Text Link Ads

IP Address Tool Chicago Web Design Free Text Messaging