Sample 1 - Graphic Counter Graphic counter can be used to generate visitors number on your pages and other similar purposes. It creates image with a custom text and sends it directly to your browser data stream when temporary image files are not needed.
> pic.asp
> <% LANGUAGE="VBSCRIPT" %> <% Dim ImageType 'ImageType = 0 ' PNG ImageType = 1 ' Jpeg 'Request from querystring variable rqs = Request.QueryString("type") if rqs <> "" then if isNumeric(rqs) then if ((rqs >=0) and (rqs<2)) then ImageType = rqs end if end if ' Clear out the existing HTTP header information Response.Expires = 0 Response.Buffer = TRUE Response.Clear ' Change the HTTP header to reflect that an image is being passed. if ImageType = 0 then Response.ContentType = "image/png" else Response.ContentType = "image/jpeg" end if Dim im Dim a Set im = CreateObject("ActiveImage.Images.1") im.CreateImage 100,100 im.SetImageType ImageType im.SetColor 255, 255,255 im.Fill 0,0 im.SetColor 0,0,255 Randomize() im.DrawText 10,10,"Banner System" im.DrawText 20,80,"visitors:" & Round(Rnd()*100) im.DrawRectangle 1,1,99,99 'Diagram Dim d,r,g,b data = "20,45,15,9,11" red = "255,255 ,255,0,0 " green = "0,0,255,255,0" blue = "0,255,127,255,255" d = split(data,",") r = split(red,",") g = split(green,",") b = split(blue,",") x = 0 For i = 0 to 4 im.SetColor r(i),g(i),b(i) im.DrawFilledArc 40,50,40,40,(x*3.6),(d(i)+x)*3.6 x = x + d(i) next im.SetJpegQuality 100 a = im.WriteToVariable response.BinaryWrite a retval = im.DestroyImage Set im = Nothing Response.End %>
> 2stream.html
> <HTML> <HEAD> <TITLE>Test WriteToVariable method</TITLE> </HEAD> <BODY> <TABLE> <TR> <TD>PNG</TD> <TD>Jpeg</TD> </TR> <TR> <TD><img src="pic.asp?type=0"></TD> <TD><img src="pic.asp?type=1"></TD> </TR> </TABLE> </BODY> </HTML>
> Counter.jpg
> Picture 1. Stream.png 0.98 Kb
If you have any questions or bug reports, write to active.image@tonec.com for technical support.