Create Image Using ASP
by Nirmala[ Edit ] 2009-08-11 15:28:48
Hi...
Create image using ASP use the below code.
<%
Function GetTempFileName(Byref FS)
GetTempFileName = FS.GetSpecialFolder(2) &".gif"
End Function
Sub CreateGifFromText(inText, FileName)
Dim chs: Set Chs = getOWC
Dim Chart: Set Chart = chs.Charts.Add //Get Chart Object
Chart.HasTitle = True //Enable Chart Title
Chart.Title.Caption = inText //Set the text
Chart.Title.Font.Color = "#660000"
Chart.Title.Font.italic = true
Chart.Title.font.bold = true
chs.Interior.Color="#d3d3d3" //Chart background
chs.ExportPicture FileName,, 60, 40 // Save the image as file
End Sub
Function getOWC
Dim chs : Set Chs = CreateObject("OWC10.ChartSpace") //create an OWC chart object. OWC(Office Web Components) is an library
if isempty(Chs) then Set Chs = CreateObject("OWC11.ChartSpace")
Set getOWC = Chs
End Function
Function ReadBinaryFile(FileName)
Const adTypeBinary = 1
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.LoadFromFile FileName
ReadBinaryFile = BinaryStream.Read
End Function
Function textToGIF(inText)
Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")
Dim FileName: FileName = GetTempFileName(FS)
CreateGifFromText inText, FileName //sub procedure
textToGIF = ReadBinaryFile(FileName)
FS.DeleteFile FileName
End Function
Response.ContentType = "image/gif"
Response.binarywrite textToGIF(2134)
%>