ASPJPEG in vb.net ???

Discussion in 'ASP .Net' started by Tony, Apr 26, 2005.

  1. Tony

    Tony Guest

    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 ---
     
    Tony, Apr 26, 2005
    #1
    1. Advertising

  2. Tony

    Josh Guest

    Your looking to use the System.Drawing namespace and GDI+. Hit google for
    the howto's
     
    Josh, Apr 26, 2005
    #2
    1. Advertising

  3. 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.

    "Tony" <> wrote in message
    news:...
    > 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 ---
     
    Kevin Spencer, Apr 26, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Elmhorst
    Replies:
    2
    Views:
    503
    Bassel Tabbara [MSFT]
    Jul 8, 2003
  2. Tony
    Replies:
    3
    Views:
    3,365
  3. Tony
    Replies:
    0
    Views:
    530
  4. Christopher Brandsdal

    AspJpeg

    Christopher Brandsdal, Jul 31, 2003, in forum: ASP General
    Replies:
    0
    Views:
    190
    Christopher Brandsdal
    Jul 31, 2003
  5. ASPJPEG Help

    , Oct 6, 2005, in forum: ASP General
    Replies:
    1
    Views:
    143
Loading...

Share This Page