my_blithe
دوشنبه 06 اسفند 1386, 20:12 عصر
سلام
من برای کوچک ننمایی تصاویر از این کدها استفاده میکنم ولی در پایان تصویر با همون حجم اولیه روی صفحه لود میشه مشکل چیه ؟؟
برای قسمت loadpage در صفحه ShowThumbnail.aspx از این کد :
'Read in the image filename to create a thumbnail of
Dim imageUrl As String = Request.QueryString("img"(
'Read in the width and height
Dim imageHeight As Integer = Request.QueryString("h")
Dim imageWidth As Integer = Request.QueryString("w")
'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 = "mypics/" & imageUrl
Dim fullSizeImg As System.Drawing.Image
fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath(image Url))
'Do we need to create a thumbnail?
Response.ContentType = "image/jpg"
If imageHeight > 0 And imageWidth > 0 Then
Dim dummyCallBack As System.Drawing.Image.GetThumbnailImageAbort
dummyCallBack = New System.Drawing.Image.GetThumbnailImageAbort(Addres sOf ThumbnailCallback)
Dim thumbNailImg As System.Drawing.Image
thumbNailImg = fullSizeImg.GetThumbnailImage(imageWidth, imageHeight, dummyCallBack, IntPtr.Zero)
fullSizeImg.Save(Response.OutputStream, ImageFormat.Gif)
Else
fullSizeImg.Save(Response.OutputStream, ImageFormat.Gif)
End If
و در صفحه آلبومم از این کدها
Public Function img_resize(ByVal picname As String,ByVal maxHeight As Integer, ByVal maxWidth As Integer) As String
Dim currentImage As System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath("mypics\") + picname)
Dim imgHeight, imgWidth As Integer
imgHeight = currentImage.Height
imgWidth = currentImage.Width
If imgWidth > maxWidth Or imgHeight > maxHeight Then
'Determine what dimension is off by more
Dim deltaWidth As Integer = imgWidth - maxWidth
Dim deltaHeight As Integer = imgHeight - maxHeight
Dim scaleFactor As Double
If deltaHeight > deltaWidth Then
'Scale by the height
scaleFactor = maxHeight / imgHeight
Else
'Scale by the Width
scaleFactor = maxWidth / imgWidth
End If
imgWidth *= scaleFactor
imgHeight *= scaleFactor
End If
Dim html As String
If imgHeight <> currentImage.Height Or imgWidth <> currentImage.Width Then
html = "<a href=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>" & _
"<img src=""ShowThumbnail.aspx?img=" & Path.GetFileName(s) & "&w=" & _
imgWidth & "&h=" & imgHeight & """ " & _
"height=""" & imgHeight & """ width=""" & imgWidth & """ border=1>" & _
"</a>"
Else
html = "<a href=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>" & _
"<img src=""ShowThumbnail.aspx?img=" & Path.GetFileName(s) & """ " & _
"height=""" & imgHeight & """ width=""" & imgWidth & """ border=1>" & _
"</a>"
End If
Return html
End Function
و در خود صفحه از این کد برای یک گریدویو
<asp:GridView ID="GridView3" runat="server" AllowPaging="True" AllowSorting="True"AutoGenerateColumns="False" DataKeyNames="reply_pk" DataSourceID="reply_source"Width="100%" GridLines="None">
<Columns>
<asp:TemplateFieldSortExpression="reply_user">
<ItemTemplate>
<%#img_resize(Eval("my_img"),100, 80)%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
حالا مشکل از کجاست ؟؟؟؟؟
البته من متن کامل مقاله آموزشی این موضوع رو گذاشتم اگه کسی کمکم کنه ممنون میشم....
من برای کوچک ننمایی تصاویر از این کدها استفاده میکنم ولی در پایان تصویر با همون حجم اولیه روی صفحه لود میشه مشکل چیه ؟؟
برای قسمت loadpage در صفحه ShowThumbnail.aspx از این کد :
'Read in the image filename to create a thumbnail of
Dim imageUrl As String = Request.QueryString("img"(
'Read in the width and height
Dim imageHeight As Integer = Request.QueryString("h")
Dim imageWidth As Integer = Request.QueryString("w")
'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 = "mypics/" & imageUrl
Dim fullSizeImg As System.Drawing.Image
fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath(image Url))
'Do we need to create a thumbnail?
Response.ContentType = "image/jpg"
If imageHeight > 0 And imageWidth > 0 Then
Dim dummyCallBack As System.Drawing.Image.GetThumbnailImageAbort
dummyCallBack = New System.Drawing.Image.GetThumbnailImageAbort(Addres sOf ThumbnailCallback)
Dim thumbNailImg As System.Drawing.Image
thumbNailImg = fullSizeImg.GetThumbnailImage(imageWidth, imageHeight, dummyCallBack, IntPtr.Zero)
fullSizeImg.Save(Response.OutputStream, ImageFormat.Gif)
Else
fullSizeImg.Save(Response.OutputStream, ImageFormat.Gif)
End If
و در صفحه آلبومم از این کدها
Public Function img_resize(ByVal picname As String,ByVal maxHeight As Integer, ByVal maxWidth As Integer) As String
Dim currentImage As System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath("mypics\") + picname)
Dim imgHeight, imgWidth As Integer
imgHeight = currentImage.Height
imgWidth = currentImage.Width
If imgWidth > maxWidth Or imgHeight > maxHeight Then
'Determine what dimension is off by more
Dim deltaWidth As Integer = imgWidth - maxWidth
Dim deltaHeight As Integer = imgHeight - maxHeight
Dim scaleFactor As Double
If deltaHeight > deltaWidth Then
'Scale by the height
scaleFactor = maxHeight / imgHeight
Else
'Scale by the Width
scaleFactor = maxWidth / imgWidth
End If
imgWidth *= scaleFactor
imgHeight *= scaleFactor
End If
Dim html As String
If imgHeight <> currentImage.Height Or imgWidth <> currentImage.Width Then
html = "<a href=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>" & _
"<img src=""ShowThumbnail.aspx?img=" & Path.GetFileName(s) & "&w=" & _
imgWidth & "&h=" & imgHeight & """ " & _
"height=""" & imgHeight & """ width=""" & imgWidth & """ border=1>" & _
"</a>"
Else
html = "<a href=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>" & _
"<img src=""ShowThumbnail.aspx?img=" & Path.GetFileName(s) & """ " & _
"height=""" & imgHeight & """ width=""" & imgWidth & """ border=1>" & _
"</a>"
End If
Return html
End Function
و در خود صفحه از این کد برای یک گریدویو
<asp:GridView ID="GridView3" runat="server" AllowPaging="True" AllowSorting="True"AutoGenerateColumns="False" DataKeyNames="reply_pk" DataSourceID="reply_source"Width="100%" GridLines="None">
<Columns>
<asp:TemplateFieldSortExpression="reply_user">
<ItemTemplate>
<%#img_resize(Eval("my_img"),100, 80)%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
حالا مشکل از کجاست ؟؟؟؟؟
البته من متن کامل مقاله آموزشی این موضوع رو گذاشتم اگه کسی کمکم کنه ممنون میشم....