Wednesday, September 3, 2008

Generate Counter Image runtime

1 <%@ page language="vb" contenttype="image/jpeg" %> 2 <%@ import namespace="system.drawing" %> 3 <%@ import namespace="system.drawing.imaging" %> 4 <%@ import namespace="system.drawing.drawing2d" %> 5 <% 6 7 response.clear ' make sure Nothing has gone to the client 8 9 10 dim imgOutput as New bitmap(120, 30, pixelformat.format24bpprgb) ' create a New 24bit, 120x30 pixel image 11 dim g as graphics = graphics.fromimage(imgOutput) ' create a New graphic object from the above bmp 12 13 application("intPageCount")+=1 ' really dumb page counter 14 15 g.clear(color.yellow) ' blank the image 16 g.smoothingMode = smoothingMode.antiAlias ' antialias objects 17 18 ' draw the number on the image canvas in verdana 10pt font bold 19 g.drawString("Count: " & application("intPageCount"), New font("verdana",14,fontstyle.bold),systembrushes.windowtext, New pointF(2,2)) 20 21 ' draw a graduated fill across the image 22 g.FillRectangle(New linearGradientBrush(New point(0,0), New point(120,30), color.fromArgb(0,0,0,0),color.fromArgb(255,255,255,255)),0,0,120,30) 23 24 25 imgOutput.save(response.outputstream, imageformat.jpeg) ' output to the user 26 27 28 ' tidy up 29 g.dispose() 30 imgOutput.dispose() 31 response.end 32 33 %>

No comments: