Click here to Skip to main content
16,018,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I want to show video in thumbnail mode.My application is working for images but not working for videos.

here is my code

for image:
VB
Private Function GetScaledImage(ImgMs As System.IO.Stream, MaxWidth As Integer, MaxHeight As Integer) As resizedimage
       Try
           ImgMs.Seek(0, IO.SeekOrigin.Begin)

           Dim tempi As New BitmapImage
           tempi.SetSource(ImgMs)

           Dim cx As Double = CDbl(MaxWidth)
           Dim cy As Double = tempi.PixelHeight * (cx / tempi.PixelWidth)

           If cy > CDbl(MaxHeight) Then
               cy = CDbl(MaxHeight)
               cx = tempi.PixelWidth * (cy / tempi.PixelHeight)
           End If

           Dim img As New Image
           img.Source = tempi

           Dim wb1 As New WriteableBitmap(CInt(cx), CInt(cy))
           Dim st As New ScaleTransform
           st.ScaleX = cx / tempi.PixelWidth
           st.ScaleY = cy / tempi.PixelHeight
           wb1.Render(img, st)
           wb1.Invalidate()

           Dim wb2 As New WriteableBitmap(CInt(cx), CInt(cy))

           For i As Integer = 0 To wb2.Pixels.Length - 1
               wb2.Pixels(i) = wb1.Pixels(i)
           Next
           wb2.Invalidate()



           Dim jj As New resizedimage With {.x = wb2.PixelWidth, .y = wb2.PixelHeight, .mebytes = wb2.ToByteArray}

           wb1 = Nothing
           wb2 = Nothing
           img = Nothing
           tempi = Nothing

           GC.Collect()

           Return jj
       Catch ex As Exception
           Return Nothing
       End Try

For Video:
VB
Private Function GetScaledImageNoResize(tempi As BitmapImage) As resizedimage
       Try

           Dim wb1 As New WriteableBitmap(tempi)

           wb1.Invalidate()

           Dim wb2 As New WriteableBitmap(wb1.PixelWidth, wb1.PixelHeight)

           For i As Integer = 0 To wb2.Pixels.Length - 1
               wb2.Pixels(i) = wb1.Pixels(i)
           Next
           wb2.Invalidate()



           Dim jj As New resizedimage With {.x = wb2.PixelWidth, .y = wb2.PixelHeight, .mebytes = wb2.ToByteArray}

           wb1 = Nothing
           wb2 = Nothing

           tempi = Nothing

           GC.Collect()

           Return jj
       Catch ex As Exception
           Return Nothing
       End Try


   End Function

whats wrong why video is not showing in thumbnail mode??
Posted
Updated 25-Jun-13 1:17am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900