Monday, May 07, 2007

Uploading Image and Creating Water Mark

Uploading Image and Creating Water Mark

Dim MyFile As HtmlControls.HtmlInputFile = CType(Page.FindControl("File1"), HtmlControls.HtmlInputFile)
Dim fileName As String = MyFile.PostedFile.FileName.Substring

(MyFile.PostedFile.FileName.LastIndexOf("\") + 1)
Dim image As System.Drawing.Image = System.Drawing.Image.FromStream(MyFile.PostedFile.InputStream)
MyFile.PostedFile.SaveAs(filePath)
Dim bitmap_Large As Bitmap = New Bitmap(image)
Dim bitmap_Thumb As Bitmap = New Bitmap(image, 118, 118)
Dim GraphicsWriter As Graphics = Graphics.FromImage(bitmap_Large)
Dim stringFormat As New StringFormat
stringFormat.FormatFlags = StringFormatFlags.DirectionVertical GraphicsWriter.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias GraphicsWriter.FillRectangle(Brushes.Green, 0, 0, 25, bitmap_Large.Height) GraphicsWriter.DrawString("Copyright MyDomain.com " & DateTime.Now.Year, New Font("Verdana", 12, FontStyle.Bold), Brushes.White, New PointF(0, (bitmap_Large.Height / 2) - 122), stringFormat)
bitmap_Large.Save(MapPath("..\upload\Large\" & FileName & ".jpg"), image.RawFormat)
bitmap_Thumb.Save(MapPath("..\upload\thumb\" & FileName & ".jpg"), image.RawFormat)

8 comments:

Anonymous said...

Nice code snippet!

Qaiser said...

Good Example.
Simple and Objective (y)

Anonymous said...

good stuff!!

put it on dotnetmadness as well

Anonymous said...

Good man tha Lal tain .. but I have seen the same code infact the same variable name on several of my projects.
I guess... you have steal it ...
Good ...
AN EVERAGE ARTIST COPIES
BUT A GREAT ARTIST STEALS.

you are the great one

cheers

Anonymous said...

Good work Mr Arshad
Does this link belong to you or some other arshad
http://www.myhpf.co.uk/apply001.asp?Friend=298034

Anonymous said...

hi friend i m arshad rasheed from india www.artshadrsd.blogspot.com

Anonymous said...

www.arshadrsd.blogspot.com

Anonymous said...

porn [url=http://pornushi.ru/english-version/extrem-sex/site-373.htm]www extreme sex tube[/url]