Image Branding On The Fly Asp. net

Results 1 to 2 of 2

Thread: Image Branding On The Fly Asp. net

  1. #1
    Join Date
    Dec 1969

    Default Image Branding On The Fly Asp. net

    Hi, i was making a photo gallery and because of the nature of the photos i didn&#039;t want anyone to take them, but i also didnt want to go through the tedious process of having to brand each image individually. So i got some info on image manipulation and came up with this piece of code (shown below)<BR><BR>However my problem is this when on my first batch of images the image displayed exactly how i expected with the shadow and the branding placed in the top left hand corner.<BR><BR>However on the second batch of images it still attempted to make the shadow and it still brands the image, but the original photo, the source of my images when placed onto my Graphics.Drawing working space becomes enlarged, i cant say by what factor.. but it is larger than the canvas i have created so you 1) do not see the shadow effect and 2) the image looks horrible and distorted , really bad quality.<BR><BR>Now i am using the SAME file with all the images but i cannot for the life of me figure out why it would react differently to different images. My code is shown below, i hope somebody can identify my horrible bug!<BR><BR>Thanks in advnace<BR>Gian franco<BR><BR>&#060;hr&#062;<BR>&#060;%@Import Namespace="System.Drawing" %&#062;<BR>&#060;%@Import Namespace="System.Drawing.Imaging" %&#062;<BR><BR><BR>&#060;script language="VB" runat="server"&#062;<BR> Function ThumbnailCallback() as Boolean<BR> Return False<BR> End Function<BR><BR><BR> Sub Page_Load(sender as Object, e as EventArgs)<BR> <BR> &#039;Read in the image filename to create a thumbnail of<BR> Dim imageUrl as String = Request.QueryString("img")<BR> Dim logoUrl as String = "media/logo.gif"<BR> &#039;Make sure that the image URL doesn&#039;t contain any /&#039;s or &#039;s<BR> <BR> If imageUrl.IndexOf("/") &#062;= 0 Or imageUrl.IndexOf("\") &#062;= 0 then<BR> &#039;We found a / or <BR> Response.End()<BR> End If<BR> <BR> &#039;Add on the appropriate directory<BR> imageUrl = "media/" & imageUrl<BR> <BR> <BR> Dim portLoc As New Point(3, 3)<BR> Dim landLoc As New Point(3, 3)<BR> Dim topLoc As New Point(0, 0)<BR> <BR> <BR> Dim oriPhoto as System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(image Url))<BR> Dim imageHeight as Long = oriPhoto.Height<BR> Dim imageWidth as Long = oriPhoto.Width<BR> <BR> Dim newImageHeight as Integer = imageHeight + 4<BR> Dim newImageWidth as Integer = imageWidth + 4<BR> <BR> Dim workSpace As System.Drawing.Bitmap = New Bitmap(newImageWidth, newImageHeight)<BR> Dim svLogo As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(logoU rl))<BR> Dim branPhoto as System.Drawing.Graphics = System.Drawing.Graphics.FromImage(workSpace)<BR> <BR> &#039;Dim svRed As Color = Color.FromArgb(204, 0, 0)<BR> Dim svGray As Color = Color.FromArgb(102,102,102)<BR> branPhoto.Clear(svGray)<BR> branPhoto.DrawImage(oriPhoto, New PointF(0F, 0F))<BR><BR> <BR> Dim redPen As new Pen(Color.Black, 1)<BR> Dim whiteBrush As new SolidBrush(Color.White)<BR> branPhoto.DrawRectangle(redPen, 0 , 0 , imageWidth, imageHeight)<BR> branPhoto.FillRectangle(whiteBrush, 0, imageHeight,4 ,4)<BR> branPhoto.FillRectangle(whiteBrush, imageWidth,0,4 ,4)<BR> Response.ContentType = "image/jpeg"<BR> <BR> IF imageHeight &#062; imageWidth then<BR> branPhoto.DrawImage(svLogo, landLoc)<BR> workSpace.Save(Response.OutputStream, ImageFormat.Jpeg) <BR> Else<BR> branPhoto.DrawImage(svLogo, portLoc)<BR> workSpace.Save(Response.OutputStream, ImageFormat.Jpeg) <BR> End If<BR> <BR> End Sub<BR>&#060;/script&#062;<BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Try ASP.NET Forum. (eop)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts