ASPJPEG in vb.net ???

T

Tony

Hello I have a working code for asp that I want to use now in asp.net.
The code is included below.

With this code I create a red bar on the bottom of an image, in which
I give some comment on the image and the URL of the website. In the
code image.asp I define the file name of the image (img), the comment
(txt) and the url (url). In the later stage in the project, this info
will be created dynamically depending on the requested image. The code
of sendbinary creates on the fly a new image, based on the 3
parameters.

I want to have this code now in vb.net to use it in my new asp.net web
application. Calling the current sendbinary.asp from an asp.net page
doesn't work.

Can someone please help me to rewrite this code?

Many thanks in advance!
Tony.

--- Code of image.asp ---

<HTML>
<HEAD>
<TITLE>AspJpeg - Image with comment in red bar</title>
</HEAD>
<BODY>
<CENTER>

<%
img = Server.URLEncode(Server.MapPath("img014.jpg"))
txt = Server.URLEncode("014 Comment on bottom of image")
url = Server.URLEncode("www.domain.com")
%>
<IMG src="sendbinary.asp?img=<%=img%>&text=<%=txt%>&url=<%=url%>"><BR>

</CENTER>
</BODY>
</HTML>

--- End of code test.asp ---

--- Code of sendbinary.asp ---

<%
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open(Request("img"))

Set OK = Server.CreateObject("Persits.Jpeg")
OK.Open(Server.MapPath("empty.jpg"))

OK.Width = Jpeg.Width
OK.Height = Jpeg.Height + 21
OK.DrawImage 0, 0, Jpeg

OK.Canvas.Font.Color = &HFFFFFF 'white
OK.Canvas.Font.Family = "Arial"
OK.Canvas.Font.Size = 16
OK.Canvas.Print 10, Jpeg.Height+2, Request("text")
OK.Canvas.Print Jpeg.Width-134, Jpeg.Height+2, Request("url")

OK.Quality = 95

OK.SendBinary
%>

--- End of code sendbinary.asp ---
 
K

Kevin Spencer

Hi Tony,
Hello I have a working code for asp that I want to use now in asp.net.

No you don't. You just THINK you want to do that. Why? Let me explain.

First, ASP and ASP.Net have very little in common. You can't simply
"convert" ASP to ASP.Net in many cases. They are completely different
programming paradigms. One is scripted, and one is a fully-compiled
programming technology. One is procedural, and the other is object-oriented.
ASP uses COM to do the heavy lifting. ASP.Net has the full power of the .Net
platform behind it, and can lift anything you want all by itself. In fact,
the 2 technologies are so different that ASP.Net doesn't do COM. To do COM
with ASP.Net you have to do a nasty little workaround called Interop, which
is costly and dangerous.

In this specific case, you're using a third-party COM component (Persits) to
generate an image on the server side. What you would do in ASP.Net is use
the System.Drawing and System.Drawing.Imaging namespaces to generate an
image. Once the image is generated on the server side (by an ASP.Net page,
similarly to the way you're using an ASP page in your existing code), the
ASP.Net page would set the Response.ContentType property to "image/jpg" and
save the image to the Response.OutputStream.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top