<btn_save_click_event>
Dim fileName As String = fileImage.FileName
Dim thumbName As String = "sm_" & fileImage.FileName
fileImage.SaveAs(Server.MapPath("~/GalleryImages/" & fileName))
Using Img As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("~/GalleryImages/") & fileImage.FileName)
Dim ThumbNailSize As System.Drawing.Size = NewImageSize(Img.Height, Img.Width, 75)
Using ImgThnail As System.Drawing.Image = New System.Drawing.Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height)
ImgThnail.Save(Server.MapPath("~/GalleryImages/") & thumbName, Img.RawFormat)
ImgThnail.Dispose()
End Using
Img.Dispose()
End Using
Private Function NewImageSize(ByVal OriginalHeight As Integer, ByVal OriginalWidth As Integer, ByVal FormatSize As Double) As Size
Dim NewSize As Size
Dim tempval As Double
If OriginalHeight > FormatSize AndAlso OriginalWidth > FormatSize Then
If OriginalHeight > OriginalWidth Then
tempval = FormatSize / Convert.ToDouble(OriginalHeight)
Else
tempval = FormatSize / Convert.ToDouble(OriginalWidth)
End If
NewSize = New Size(Convert.ToInt32(tempval * OriginalWidth), Convert.ToInt32(tempval * OriginalHeight))
Else
NewSize = New Size(OriginalWidth, OriginalHeight)
End If
Return NewSize
End Function
Have you read the book? - ASP.Net 3.5 CMS Development (now on Kindle)
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
Marked as answer by Qi Wu - MSFT on Apr 08, 2012 01:43 PM
Arfath_pasha
Member
21 Points
31 Posts
problem in image clearity while running the app
Mar 26, 2012 08:28 AM|LINK
am doing B2C project in which the images i inserted in the home page is not clear.
i tryed to run the app with mozilla i have used .jpeg file format same problem accours
but it looks great in Iexplorer
please suggest me the solution
Curt_C
All-Star
66014 Points
7639 Posts
Moderator
Re: problem in image clearity while running the app
Mar 26, 2012 01:06 PM|LINK
I'm not sure how this could affect the images... are you dynamically creating the images or such?
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
Arfath_pasha
Member
21 Points
31 Posts
Re: problem in image clearity while running the app
Mar 27, 2012 05:56 AM|LINK
no its all static images. some images where edited in photoshop ...some dotes is appering on image....when imags
is viewed large enoughf in another page its clear.
Curt_C
All-Star
66014 Points
7639 Posts
Moderator
Re: problem in image clearity while running the app
Mar 27, 2012 12:06 PM|LINK
then I'm pretty confident it's nothing to do with Asp.Net.
Sounds like a browser issue with resizing images.
Only suggesting I can make is size them appropriately before display.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
Arfath_pasha
Member
21 Points
31 Posts
Re: problem in image clearity while running the app
Mar 29, 2012 01:32 PM|LINK
so shall i make use thumnails...if so any idea how use thumnails
Curt_C
All-Star
66014 Points
7639 Posts
Moderator
Re: problem in image clearity while running the app
Mar 29, 2012 02:07 PM|LINK
I use this to create a thumbnail
<btn_save_click_event>
Dim fileName As String = fileImage.FileName
Dim thumbName As String = "sm_" & fileImage.FileName
fileImage.SaveAs(Server.MapPath("~/GalleryImages/" & fileName))
Using Img As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath("~/GalleryImages/") & fileImage.FileName)
Dim ThumbNailSize As System.Drawing.Size = NewImageSize(Img.Height, Img.Width, 75)
Using ImgThnail As System.Drawing.Image = New System.Drawing.Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height)
ImgThnail.Save(Server.MapPath("~/GalleryImages/") & thumbName, Img.RawFormat)
ImgThnail.Dispose()
End Using
Img.Dispose()
End Using
Private Function NewImageSize(ByVal OriginalHeight As Integer, ByVal OriginalWidth As Integer, ByVal FormatSize As Double) As Size
Dim NewSize As Size
Dim tempval As Double
If OriginalHeight > FormatSize AndAlso OriginalWidth > FormatSize Then
If OriginalHeight > OriginalWidth Then
tempval = FormatSize / Convert.ToDouble(OriginalHeight)
Else
tempval = FormatSize / Convert.ToDouble(OriginalWidth)
End If
NewSize = New Size(Convert.ToInt32(tempval * OriginalWidth), Convert.ToInt32(tempval * OriginalHeight))
Else
NewSize = New Size(OriginalWidth, OriginalHeight)
End If
Return NewSize
End Function
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!