Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
Dim businessId As Integer = 0
Dim strLogo As String = String.Empty
Dim FileLogo As String = String.Empty
Dim userId As Integer = 0
userId = Convert.ToInt32(Session(Common.SESSION_USERID).ToString())
If (flLogo.HasFile) Then
Dim strPath As String = Server.MapPath("Common/WebSiteImages/")
flLogo.SaveAs(strPath + flLogo.FileName)
FileLogo = flLogo.FileName
strLogo = "Common/WebSiteImages/" + flLogo.FileName
Dim big As String = "~Big"
big = resizeImageAndSave(strLogo, 450, 420, big)
Dim thumb As String = "~Thumb"
thumb = resizeImageAndSave(strLogo, 240, 172, thumb)
Else
strLogo = ViewState("Logo")
If (strLogo Is Nothing) Then
strLogo = String.Empty
Else
strLogo = ViewState("Logo")
End If
End If
Dim dt As New DataTable()
dt = GetWebsiteProfile(userId)
If (dt Is Nothing) Then
businessId = InsertUpdateBusinessSettings(0, userId, txtAddress.Text, txtPhoneNo.Text, editorDesc.Content, strLogo, txtCopyRight.Text,editorServices.Content)
If businessId > 0 Then
lblMsg.Text = "inserted successfuly...."
lblMsg.ForeColor = System.Drawing.Color.Green
End If
Else
Dim businessIdd As Integer = dt.Rows(0)("Id").ToString()
If dt IsNot Nothing Then
businessId = InsertUpdateBusinessSettings(businessIdd, userId, txtAddress.Text, txtPhoneNo.Text, editorDesc.Content, strLogo, txtCopyRight.Text,editorServices.Content)
If businessId > 0 Then
lblMsg.Text = "updated successfuly...."
lblMsg.ForeColor = System.Drawing.Color.Green
End If
End If
End If
End Sub
Private Function resizeImageAndSave(ByVal imagePath As String, ByVal width As Integer, ByVal height As Integer, ByVal name As String) As String
imagePath = "D:\Aman\FindURBiz\Abhi\250814findurbiz\findurbiz\FindurBiz\" & imagePath
Dim fullSizeImg As System.Drawing.Image = System.Drawing.Image.FromFile(imagePath)
Dim thumbnailImg = New Bitmap(width, height)
Dim thumbGraph = Graphics.FromImage(thumbnailImg)
thumbGraph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
thumbGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
thumbGraph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
Dim imageRectangle = New Rectangle(0, 0, width, height)
thumbGraph.DrawImage(fullSizeImg, imageRectangle)
Dim withoutExtension As String = imagePath
Dim strImage As String = String.Empty
Dim strArr() As String
strArr = withoutExtension.Split(".")
strImage = strArr(0)
imagePath = strImage + ".jpg"
Dim targetPath As String = imagePath.Replace(Path.GetFileNameWithoutExtension(imagePath), Path.GetFileNameWithoutExtension(imagePath) & name)
thumbnailImg.Save(targetPath, System.Drawing.Imaging.ImageFormat.Jpeg)
thumbnailImg.Dispose()
Dim bigimage As String = String.Empty
Return targetPath
ViewState("targetPath") = bigimage
End Function
My Problem-: When a small image to converted a big image then this image resolution is not good.
Please help me its very urgent...........