locked
how to read image stream? RRS feed

  • Question

  • User1087005990 posted

    Dear all here is my code, 

     i want to display thumbnail in my image box, its working fine, but for this i have to save thumbnail first

    is it possible that without saving thumbnail i use it?


    Private Sub makeThumb(ByVal thumbWidth As Int32, ByVal thumbHight As Int32, ByVal img As String, ByVal thumbName As String)
            'Dim thumbHight As Int32 = h
            'Dim thumbWidth As Int32 = w
            Dim fullImg As String = img
            'Dim thumbName As String
            Dim img1 As System.Drawing.Image
            Dim thumbStream As New System.IO.MemoryStream
            ' Todo

            Try
                img1 = System.Drawing.Image.FromFile(Server.MapPath(fullImg))
                Dim dummyCallBack As System.Drawing.Image.GetThumbnailImageAbort
                dummyCallBack = New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
                Dim thumbImg As System.Drawing.Image
                thumbImg = img1.GetThumbnailImage(thumbWidth, thumbHight, dummyCallBack, IntPtr.Zero)
                thumbImg.Save(thumbStream, System.Drawing.Imaging.ImageFormat.Jpeg)
                MsgBox(thumbStream.Length)

                'thumbImg.Save(Server.MapPath("images/" & thumbName), ImageFormat.Jpeg)
                'imgThumb.ImageUrl = "images\smallReal.jpeg"
            Catch ex As Exception
                Response.Write("there is some problem in code <br />" & ex.ToString)
            End Try
        End Sub 

     

     Private Sub makeThumb(ByVal thumbWidth As Int32, ByVal thumbHight As Int32, ByVal img As String, ByVal thumbName As String)
         
            Dim fullImg As String = img
         
            Dim img1 As System.Drawing.Image

         
            Try
                img1 = System.Drawing.Image.FromFile(Server.MapPath(fullImg))
                Dim dummyCallBack As System.Drawing.Image.GetThumbnailImageAbort
                dummyCallBack = New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
                Dim thumbImg As System.Drawing.Image
                thumbImg = img1.GetThumbnailImage(thumbWidth, thumbHight, dummyCallBack, IntPtr.Zero)
                   
               thumbImg.Save(Server.MapPath("images/" & thumbName), ImageFormat.Jpeg)
               imgThumb.ImageUrl = "images\smallReal.jpeg"
            Catch ex As Exception
                Response.Write("there is some problem in code <br />" & ex.ToString)
            End Try
        End Sub

     

    thanks

     

    Friday, October 24, 2008 10:37 AM

All replies