图像缺少一帧。 COMException(0x88982F62)

时间:2017-09-25 15:46:57

标签: wpf image-processing

我们在WPF应用程序中有以下弹出窗口,该应用程序应该显示从互联网返回的两个图像,但是用“'图像缺少框架”将玩具抛出。当它命中EndInit()

以前从未遇到此错误,也无法在线找到与此用途相关的任何解释 - 这可能是下载图片的问题,如果是,我该如何检查?

谢谢

Public Sub PopupModals_ChequeImages(ImageOne() As Byte, ImageTwo() As Byte)
    Try

        MainPopUp = New Window
        With MainPopUp
            .Width = 800
            .Height = 750
            .ResizeMode = ResizeMode.NoResize
            .Title = "Check Images"
            .Icon = BitmapFrame.Create(ReturnIconImage("GIF_ICO.ico"))
        End With
        MainPopUpGrid = New Grid
        NameScope.SetNameScope(MainPopUpGrid, New NameScope())

        Dim vGrid As New Grid
        For i As Integer = 0 To 2
            Dim vRow As New RowDefinition
            If i = 2 Then
                vRow.Height = New GridLength(35)
            Else
                vRow.Height = New GridLength(35, GridUnitType.Star)
            End If
            MainPopUpGrid.RowDefinitions.Add(vRow)
        Next

        Dim UpperSV As New ScrollViewer
        With UpperSV
            .VerticalScrollBarVisibility = ScrollBarVisibility.Auto
        End With
        Grid.SetRow(UpperSV, 0)
        MainPopUpGrid.Children.Add(UpperSV)


        Dim LowerSV As New ScrollViewer
        With LowerSV
            .VerticalScrollBarVisibility = ScrollBarVisibility.Auto
        End With
        Grid.SetRow(LowerSV, 1)
        MainPopUpGrid.Children.Add(LowerSV)

        'Convert the files and load into the scrollviewers'
        Dim vImage1 As New Image
        Dim vBitmap As New BitmapImage
        Using vStream As New IO.MemoryStream(ImageOne)
            With vBitmap
                .BeginInit()
                .CreateOptions = BitmapCreateOptions.PreservePixelFormat
                .CacheOption = BitmapCacheOption.OnLoad
                .StreamSource = vStream
                .EndInit()
                .Freeze()
            End With
            vImage1.Source = vBitmap
        End Using
        UpperSV.Content = vImage1

        Dim vImage2 As New Image
        vBitmap = New BitmapImage
        Using vStream As New IO.MemoryStream(ImageTwo)
            With vBitmap
                .BeginInit()
                .CreateOptions = BitmapCreateOptions.PreservePixelFormat
                .CacheOption = BitmapCacheOption.OnLoad
                .StreamSource = vStream
                .EndInit()
                .Freeze()
            End With
            vImage2.Source = vBitmap
        End Using
        LowerSV.Content = vImage2


        Dim DP As DockPanel = PopupStatusBar()
        Grid.SetRow(DP, 2)
        MainPopUpGrid.Children.Add(DP)
        StatusBarLoaded("Check images...")



        MainPopUp.Content = MainPopUpGrid
        MainPopUp.WindowStartupLocation = WindowStartupLocation.CenterOwner
        Dim CurApp As Application = Application.Current
        Dim vWindow As Window = CurApp.MainWindow
        MainPopUp.Owner = vWindow



        MainPopUp.ShowDialog()

    Catch ex As Exception
        EmailError(ex)
    End Try
End Sub

完全例外是

The image is missing a frame.
at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& safeFilehandle)
at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
at System.Windows.Media.Imaging.BitmapImage.FinalizeCreation()
at System.Windows.Media.Imaging.BitmapImage.EndInit()
at HOAManagerClient051.PopupModals.PopupModals_ChequeImages(Byte[] ImageOne, Byte[] ImageTwo) in C:\Users\Dave\Documents\Visual Studio 2017\Projects\HOAManagerClient051\HOAManagerClient051\PopupModals.vb:line 3125
System.Runtime.InteropServices.COMException (0x88982F62): Exception from HRESULT: 0x88982F62

像这样返回图像

Await Task.Run(Sub()
    Using response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
        Dim deserializer As New DataContractJsonSerializer(GetType(AllianceBank.CheckImageResponse))
        checkResponseObject = DirectCast(deserializer.ReadObject(response.GetResponseStream()), AllianceBank.CheckImageResponse)
    End Using
End Sub)

Dim frontImageRawGif As Byte() = Nothing
Dim backImageRawGif As Byte() = Nothing

Dim IsCheckImage As Boolean = True
Try
    frontImageRawGif = Convert.FromBase64String(checkResponseObject.FrontImage)
Catch ex As Exception
    IsCheckImage = False
End Try

Try
    backImageRawGif = Convert.FromBase64String(checkResponseObject.BackImage)
Catch ex As Exception
    IsCheckImage = False
End Try

0 个答案:

没有答案