Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP.NET (Non-Forum Related)
 layout formating in .NET
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

weeweeslap
Senior Member

USA
1077 Posts

Posted - 10 September 2007 :  15:11:26  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
I have the following page that given the querystring it displays a picture:
http://www.weeweeslap.com/scrapbook/viewimage.aspx?img=09-03-06_1845.jpg
However I can't like change the background color or give the picture a border or hyperlink the picture. Here is the code I have coded into that page. I grabbed the code off 4guysfromrolla.com and they didn't have any <html> etc tags in thee, just the .NET code so I am sure I am doing something wrong. You think you guys can lend me a hand so I can format the page properly? Thanks.

<%@Import Namespace="System.Drawing.Imaging" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>WeeWeeSlap.com Pic Gallery</title>

<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<meta http-equiv="PRAGMA" content="NO-CACHE" />
</head>

<body bgcolor="#131313" link="#262626">
<center>
<script language="VB" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)

    'Read in the image filename to create a thumbnail of
    Dim imageUrl as String = Request.QueryString("img")

    'Make sure that the image URL doesn't contain any /'s or \'s
    If imageUrl.IndexOf("/") >= 0 Or imageUrl.IndexOf("\") >= 0 then
      'We found a / or       Response.End()
    End If

    'Add on the appropriate directory
    imageUrl = "/scrapbook/" & imageUrl

    'Get the image.
    Dim fullSizeImg as System.Drawing.Image
    fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath(imageUrl))

    'Set the ContentType to "image/jpeg" and output the image's data
    Response.ContentType = "image/jpeg"
    fullSizeImg.Save(Response.OutputStream, ImageFormat.Jpeg)
  End Sub
</script>
</center>
</body>
</html>

Thanks for helping this n0ob.

coaster crazy

Edited by - weeweeslap on 10 September 2007 15:13:06

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 September 2007 :  18:55:02  Show Profile  Visit HuwR's Homepage
your problem is that code is outputting an image not a web page. so you need to create a web page with an asp:image component on it and then use the http://www.weeweeslap.com/scrapbook/viewimage.aspx?img=09-03-06_1845.jpg as the src for the image component, that way you can style the page etc
Go to Top of Page

weeweeslap
Senior Member

USA
1077 Posts

Posted - 10 September 2007 :  19:53:08  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
ahh, I understand and after understanding I figured out a way to get the imge and have it do to it what it was doing here. Thanks Huwr for the info.

coaster crazy
Go to Top of Page

holker_lberkani
Starting Member

Morocco
8 Posts

Posted - 18 September 2007 :  10:34:26  Show Profile
your problem is that code is outputting an image not a web page. so you need to create a web page with an asp:image component on it and then use the http://www.weeweeslap.com/scrapbook/viewimage.aspx?img=09-03-06_1845.jpg as the src for the image component, that way you can style the page etc
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 18 September 2007 :  10:38:39  Show Profile  Visit HuwR's Homepage
quote:
Originally posted by holker_lberkani

your problem is that code is outputting an image not a web page. so you need to create a web page with an asp:image component on it and then use the http://www.weeweeslap.com/scrapbook/viewimage.aspx?img=09-03-06_1845.jpg as the src for the image component, that way you can style the page etc


was there a reason for that post ?
Go to Top of Page

balexandre
Junior Member

Denmark
418 Posts

Posted - 18 September 2007 :  11:09:46  Show Profile  Visit balexandre's Homepage  Send balexandre an ICQ Message
Hi HuwR, I have to Love your "Semi-Retired Admin" Member title, ehehehe

weeweeslap,

ASP.NET 2.0 is a beauty, but to Draw something in a image file you need to use the new GDI+ (Graphic Design Interface), and all you need to do to draw 1 red border in your images, is copy paste this code replacing yours:

add:
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging"  %>


then:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Try
            'Read in the image filename to create a thumbnail of
            Dim imageUrl As String = Request.QueryString("img")

            'Make sure that the image URL doesn't contain any /'s or \'s
            If imageUrl.IndexOf("/") >= 0 Or imageUrl.IndexOf("\") >= 0 Then
                'We found a / or       Response.End()
            End If

            'Add on the appropriate directory
            imageUrl = "/scrapbook/" & imageUrl

            'Get the image.
            Dim fullSizeImg As System.Drawing.Image
            fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath(imageUrl))
        
            Dim g As Graphics = Graphics.FromImage(fullSizeImg)

            Using pen1 As Pen = New Pen(Color.Red, 4)
                g.DrawRectangle(pen1, New Rectangle(0, 0, fullSizeImg.Width, fullSizeImg.Height))
                g.DrawRectangle(Pens.Yellow, New Rectangle(2, 2, fullSizeImg.Width - 5, fullSizeImg.Height - 5))
            End Using

            'clear and change the response type
            Response.Clear()
            Response.ContentType = "image/jpeg"
            fullSizeImg.Save(Response.OutputStream, ImageFormat.Jpeg)
        
            ' dispose variable
            g.Dispose()
            g = Nothing
            fullSizeImg.Dispose()
            fullSizeImg = Nothing
            
        Catch ex As Exception
            ' an error was ocorred    
            
            ' you can call a function that send you an email with the error
            ' sendEmailToAdmin(ex.ToString())
            
            ' send an error image instead the requested
            Dim fullSizeImg As System.Drawing.Image
            fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath("errorImage.jpg"))
            Response.Clear()
            Response.ContentType = "image/jpeg"
            fullSizeImg.Save(Response.OutputStream, ImageFormat.Jpeg)
        
        End Try
        
    End Sub


hope it helps

Bruno Alexandre
(Strøby, DANMARK)

"a Portuguese in Danmark"



Edited by - balexandre on 18 September 2007 11:10:47
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000 Version 3.4.07