Solved

Images from asp pages

Posted on 2001-06-27
12
180 Views
Last Modified: 2006-11-17
Hi folks.

Just a short one. I think we all have seen graphical hit counters from CGI pages. Can it be done with ASP?

Another expamle of this sort of thing would be ICQ's online graphic like the dll link below.

http://wwp.icq.com/scripts/online.dll?icq=120640177&img=7
Where a query gives a result and a suitable picture is displayed.


Cheers, Rob.
0
Comment
Question by:robjohnston
12 Comments
 

Expert Comment

by:redl1ne
ID: 6232953
That doesn't seem so hard.. just create images for 0-9 and name them 0.jpg, 1.jpg and so on.

assume we store the recordcount into a variable called 'recordcount'

<%

' set recordcount equal to something
recordcount = 15556987

' get length of the count
recordlength = len(Recordcount)

' set position of count equal to starting point
position = 1

' go through each number in the count
for inti = 0 to recordlength
   "<IMG SRC=" & mid(recordcount, position, 1) & ".jpg>"
   
  ' up the default position by one.
   position = position + 1
next


%>

that should do it for ya.
0
 
LVL 7

Expert Comment

by:John844
ID: 6232954
if you have a hit count available, you can just parse the number of hits and then show a small image file of the number, move the the next digin and show its number image.  Like 1234 you would show image for 1, image for 2, image for 3 and image for 4.  It is the easiest way to do this with pure asp and no dynamic image creation.
0
 
LVL 7

Expert Comment

by:John844
ID: 6232957
that sucks, got beat by seconds..:o|
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 1

Author Comment

by:robjohnston
ID: 6233012
Thank for the prompt replies, not quite what I'm looking for.

Something more like;
<IMG SRC="image.asp?x=y">

where the image shown would be generated by the page image.asp

Cheers, Rob.
0
 
LVL 7

Expert Comment

by:John844
ID: 6233039
you can use something like the following:

<%
response.buffer=true
response.clear
response.contenttype="image/GIF"
response.binarywrite(<binary stream of data from sql or file system object>)
response.flush
%>
0
 
LVL 7

Expert Comment

by:John844
ID: 6233046
you can search msdn(or microsofts site) for "Delivering Web Images from SQL Server"
0
 
LVL 15

Expert Comment

by:robbert
ID: 6233286
Are you looking for the code to identify a referer and his hits number (and increment that, and so on), or just to send some picture by an ASP (from a database or from a file)? - Please think of it, and be straight.
0
 
LVL 1

Author Comment

by:robjohnston
ID: 6233346
John844 is on the right line.

This type of thing has got loads of app it could be used it, logging visitors to your sites and other many more.

Trying to get it to work reading a gif file like below, but it comes ups with a red cross, any ideas?

File: Image.asp

<%
response.buffer=true
response.clear
response.contenttype="image/GIF"

Const ForReading = 1             ' Input OutPut Mode
Const Create = False              

' Declare local variables
Dim FSO                          ' FileSystemObject
Dim TS                           ' TextStreamObject
Dim strLine                      ' local variable to store Line
Dim strFileName                  ' local variable to store fileName
strFileName = Server.MapPath("1.gif")

' Instantiate the FileSystemObject
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile(strFileName, ForReading, Create)
ImgLine = TS.Readall     ' Read the file

response.binarywrite ImgLine
response.flush
' close TextStreamObject and destroy local variables to relase memory
TS.Close        
Set TS = Nothing
Set FSO = Nothing
%>

Cheers, Rob.
0
 
LVL 7

Expert Comment

by:John844
ID: 6235023
here is a link to something.  have not tried the code yet.

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6142
0
 
LVL 7

Expert Comment

by:John844
ID: 6235668
Have heard that aspUpload does the same thing as well.
0
 
LVL 7

Accepted Solution

by:
John844 earned 100 total points
ID: 6235831
just got it to work.  Here is how I did it.

make a activeX dll.
set the project name to prjGetImage
set the class name to GetImage

add the following code to the class

Function GetImage(ByVal bfilename As String)
On Error GoTo errHandler
    Dim fl As Long
    Dim binbyte() As Byte
    Dim binfilestr As String
   
    Open bfilename For Binary Access Read As #1
    fl = FileLen(bfilename)
    ReDim binbyte(fl)
    Get #1, , binbyte
    Close #1
   
    GetImage = binbyte
   
    Exit Function
errHandler:
    Exit Function
End Function


compile the dll and put it onto the web server.  (i would put it in MTS to make it easier to recompile new versions)




















----------my asp page  --------

<%@ Language=VBScript %>

<%
response.buffer=true
response.clear
response.contenttype="image/GIF"

' Declare local variables
Dim strFileName                  ' local variable to store strFileName = Server.MapPath("curve.gif")

dim objGetImage
set objGetImage = server.CreateObject("prjGetImage.GetImage")
Response.binarywrite objGetImage.GetImage(strFileName)
set objGetImage = nothing

Response.End
%>
0
 
LVL 1

Author Comment

by:robjohnston
ID: 6246258
Hi folks.

Well John844, you're solution works, but when I approached my hosting co about installing dll's they said "no way".

There is another solution though, outlined here:
http://www.4guysfromrolla.com/webtech/052400-1.shtml

Basically the method is to do the work in the asp page then use response.redirect to the required image. Easy as that!

Anyway points to John844 as his solution is valid. Thanks everyone for your help, Rob.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now