J
John
I am trying to convert the regular sized images in a directory to
thumbnails and then display the thumbnails in a datalist. My code
below is displaying the first image and nothing else after it. What
do I have to do to have the thumbnails displayed in my datalist?
Thanks.
Dim strFile As String
Dim pics As ArrayList = New ArrayList
' Get image folder path on server - use "\" string if root
Dim strServerPath As String = Server.MapPath("photos\")
For Each strFile In System.IO.Directory.GetFiles(strServerPath,
"*.jpg")
' Get the regular sized image
Dim FullSizeImg As System.Drawing.Image
FullSizeImg = System.Drawing.Image.FromFile(strFile)
' Create the delegate
Dim dummyCallBack As System.Drawing.Image.GetThumbnailImageAbort
dummyCallBack = New
System.Drawing.Image.GetThumbnailImageAbort(AddressOf
ThumbnailCallback)
' Create the thumbnail
Dim ThumbNailImg As System.Drawing.Image
ThumbNailImg = FullSizeImg.GetThumbnailImage(160, 120,
dummyCallBack, IntPtr.Zero)
ThumbNailImg.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
pics.Add(ThumbNailImg)
Next
DataList1.DataSource = pics
DataList1.DataBind()
thumbnails and then display the thumbnails in a datalist. My code
below is displaying the first image and nothing else after it. What
do I have to do to have the thumbnails displayed in my datalist?
Thanks.
Dim strFile As String
Dim pics As ArrayList = New ArrayList
' Get image folder path on server - use "\" string if root
Dim strServerPath As String = Server.MapPath("photos\")
For Each strFile In System.IO.Directory.GetFiles(strServerPath,
"*.jpg")
' Get the regular sized image
Dim FullSizeImg As System.Drawing.Image
FullSizeImg = System.Drawing.Image.FromFile(strFile)
' Create the delegate
Dim dummyCallBack As System.Drawing.Image.GetThumbnailImageAbort
dummyCallBack = New
System.Drawing.Image.GetThumbnailImageAbort(AddressOf
ThumbnailCallback)
' Create the thumbnail
Dim ThumbNailImg As System.Drawing.Image
ThumbNailImg = FullSizeImg.GetThumbnailImage(160, 120,
dummyCallBack, IntPtr.Zero)
ThumbNailImg.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
pics.Add(ThumbNailImg)
Next
DataList1.DataSource = pics
DataList1.DataBind()