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