Hi. I've written a script to create a chart image using the Bitmap and Graphics object. The image is created at each time the webpage is requested and is streamed direct to the web page. The chart is drawn based on data which it recieves via a querystring. The problem is that it works for a while, but if I return to it after lunch for example the whole script just hangs as if it is in a continuous loop. It doesn't display any errors, it just doesn't load. The data hasn't changed since the last time it worked. This is my first asp.net script so maybe I've overlooked something obvious. I've pasted the script below. Many thanks in advance. Modalman
<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%
' Declare Vars
Dim objBMP As System.Drawing.Bitmap
Dim objGraphics As System.Drawing.Graphics
Dim objFont As System.Drawing.Font
Dim objPenGray As System.Drawing.Pen
Dim objPenRed As System.Drawing.Pen
Dim objPenBlack As System.Drawing.Pen
Dim picH As Integer
Dim picW As Integer
Dim weightHis As String
Dim verScaleFrom As Integer
Dim verScaleSep As Integer
Dim verScaleCalib As Double
Dim horScaleSep As Integer
Dim tgtWeight As Double
Dim perWeight As Double
Dim verCalPix As Integer
Dim horCalPix As Integer
Dim verH As Integer
Dim i As Integer
Dim weightAr As Array
Dim prevX As Integer
Dim prevY As Integer
Dim newX As Integer
Dim newY As Integer
Dim tgtY As Integer
Dim tgtBound As Integer
picH=Request("h"
picW=Request("w"
weightHis=Request("weightHis"
'picH=280
'picW=600
'weightHis="84,83,80.5,81,79,77.5,75,72,72,71"
verScaleFrom=Request("verScaleFrom"
'verScaleFrom=80
verScaleSep=Request("verScaleSep"
verScaleCalib=Request("verScaleCalib"
'kgs or lbs
horScaleSep=Request("horScaleSep"
weightAr=Split(weightHis,","
tgtWeight=Request("tgtWeight"
objBMP = New Bitmap(picW, picH)
' Create a graphics object to work with from the BMP
objGraphics = System.Drawing.Graphics.FromImage(objBMP)
objPenBlack=new Pen(Color.Black, 2)
objPenRed=new Pen(Color.Red, 1)
objPenGray=new Pen(Color.FromArgb(200,200,200), 1)
' Configure font to use for text
objFont = New Font("Arial", 8, FontStyle.Regular)
' Fill the image with background color
'objGraphics.Clear(Color.Green)
objGraphics.FillRectangle(new SolidBrush(Color.White),0,0,picW,picH)
For i=picH-1 To 0 Step -verScaleSep
objGraphics.DrawLine(objPenGray,0,i,picW-1,i)
Next
For i=0 To picW Step horScaleSep
objGraphics.DrawLine(objPenGray,i,0,i,picH-1)
Next
'plot to chart
If UBound(weightAr)>0 Then
prevX=0
prevY=CInt(picH-((((weightAr(0)*1)-verScaleFrom)/verScaleCalib)*verScaleSep))
objGraphics.DrawString(weightAr(0)&" kg", objFont, Brushes.Black,prevX,prevY-20)
objGraphics.FillRectangle(Brushes.Black, prevX-2, prevY-2, 4, 4)
For i=1 To UBound(weightAr)
newX=prevX+horScaleSep
newY=CInt(picH-((((weightAr(i)*1)-verScaleFrom)/verScaleCalib)*verScaleSep))
objGraphics.DrawLine(objPenBlack,prevX,prevY,newX,newY)
objGraphics.FillRectangle(Brushes.Black, newX-2, newY-2, 4, 4)
objGraphics.DrawString(weightAr(i)&" kg", objFont, Brushes.Black,newX,newY-20)
prevX=newX
prevY=newY
Next
End If
'draw tgt lines based on perWeight
newY=CInt(picH-((((weightAr(0)*1)-verScaleFrom)/verScaleCalib)*verScaleSep))
tgtY=CInt(picH-((((tgtWeight*1)-verScaleFrom)/verScaleCalib)*verScaleSep))
objGraphics.DrawLine(objPenRed,0,newY,13*horScaleSep,tgtY)
tgtBound=(((weightAr(0)*.05)/verScaleCalib)*verScaleSep)
objGraphics.DrawLine(objPenRed,0,newY-tgtBound,13*horScaleSep,tgtY-tgtBound)
objGraphics.DrawLine(objPenRed,0,newY+tgtBound,13*horScaleSep,tgtY+tgtBound)
' Set the content type and return the image
Response.ContentType = "image/GIF"
objBMP.Save(Response.OutputStream, ImageFormat.Gif)
' Kill our objects
objFont.Dispose()
objGraphics.Dispose()
objBMP.Dispose()
objPenGray.Dispose()
objPenBlack.Dispose()
objPenRed.Dispose()
%>
ASCII silly question, get a silly ANSI
<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%
' Declare Vars
Dim objBMP As System.Drawing.Bitmap
Dim objGraphics As System.Drawing.Graphics
Dim objFont As System.Drawing.Font
Dim objPenGray As System.Drawing.Pen
Dim objPenRed As System.Drawing.Pen
Dim objPenBlack As System.Drawing.Pen
Dim picH As Integer
Dim picW As Integer
Dim weightHis As String
Dim verScaleFrom As Integer
Dim verScaleSep As Integer
Dim verScaleCalib As Double
Dim horScaleSep As Integer
Dim tgtWeight As Double
Dim perWeight As Double
Dim verCalPix As Integer
Dim horCalPix As Integer
Dim verH As Integer
Dim i As Integer
Dim weightAr As Array
Dim prevX As Integer
Dim prevY As Integer
Dim newX As Integer
Dim newY As Integer
Dim tgtY As Integer
Dim tgtBound As Integer
picH=Request("h"
picW=Request("w"
weightHis=Request("weightHis"
'picH=280
'picW=600
'weightHis="84,83,80.5,81,79,77.5,75,72,72,71"
verScaleFrom=Request("verScaleFrom"
'verScaleFrom=80
verScaleSep=Request("verScaleSep"
verScaleCalib=Request("verScaleCalib"
horScaleSep=Request("horScaleSep"
weightAr=Split(weightHis,","
tgtWeight=Request("tgtWeight"
objBMP = New Bitmap(picW, picH)
' Create a graphics object to work with from the BMP
objGraphics = System.Drawing.Graphics.FromImage(objBMP)
objPenBlack=new Pen(Color.Black, 2)
objPenRed=new Pen(Color.Red, 1)
objPenGray=new Pen(Color.FromArgb(200,200,200), 1)
' Configure font to use for text
objFont = New Font("Arial", 8, FontStyle.Regular)
' Fill the image with background color
'objGraphics.Clear(Color.Green)
objGraphics.FillRectangle(new SolidBrush(Color.White),0,0,picW,picH)
For i=picH-1 To 0 Step -verScaleSep
objGraphics.DrawLine(objPenGray,0,i,picW-1,i)
Next
For i=0 To picW Step horScaleSep
objGraphics.DrawLine(objPenGray,i,0,i,picH-1)
Next
'plot to chart
If UBound(weightAr)>0 Then
prevX=0
prevY=CInt(picH-((((weightAr(0)*1)-verScaleFrom)/verScaleCalib)*verScaleSep))
objGraphics.DrawString(weightAr(0)&" kg", objFont, Brushes.Black,prevX,prevY-20)
objGraphics.FillRectangle(Brushes.Black, prevX-2, prevY-2, 4, 4)
For i=1 To UBound(weightAr)
newX=prevX+horScaleSep
newY=CInt(picH-((((weightAr(i)*1)-verScaleFrom)/verScaleCalib)*verScaleSep))
objGraphics.DrawLine(objPenBlack,prevX,prevY,newX,newY)
objGraphics.FillRectangle(Brushes.Black, newX-2, newY-2, 4, 4)
objGraphics.DrawString(weightAr(i)&" kg", objFont, Brushes.Black,newX,newY-20)
prevX=newX
prevY=newY
Next
End If
'draw tgt lines based on perWeight
newY=CInt(picH-((((weightAr(0)*1)-verScaleFrom)/verScaleCalib)*verScaleSep))
tgtY=CInt(picH-((((tgtWeight*1)-verScaleFrom)/verScaleCalib)*verScaleSep))
objGraphics.DrawLine(objPenRed,0,newY,13*horScaleSep,tgtY)
tgtBound=(((weightAr(0)*.05)/verScaleCalib)*verScaleSep)
objGraphics.DrawLine(objPenRed,0,newY-tgtBound,13*horScaleSep,tgtY-tgtBound)
objGraphics.DrawLine(objPenRed,0,newY+tgtBound,13*horScaleSep,tgtY+tgtBound)
' Set the content type and return the image
Response.ContentType = "image/GIF"
objBMP.Save(Response.OutputStream, ImageFormat.Gif)
' Kill our objects
objFont.Dispose()
objGraphics.Dispose()
objBMP.Dispose()
objPenGray.Dispose()
objPenBlack.Dispose()
objPenRed.Dispose()
%>
ASCII silly question, get a silly ANSI