使用SharpDX从VB.net调用时调用Direct2d PngBitmapEncoder.Initialize失败

时间:2015-01-30 06:30:17

标签: vb.net direct2d sharpdx

我在Windows 8.1上运行的VB.NET 2010中编写了以下代码:

>Dim pixelFormat As System.Guid = WicPixelFormat.Format32bppBGR
>Dim wicFactory As ImagingFactory = New ImagingFactory()
>Dim wicBitmap As Bitmap = New Bitmap(wicFactory, width, height, pixelFormat, BitmapCreateCacheOption.CacheOnLoad)

>' A bunch of rendering code goes here.  The renderTarget is closed with endDraw
>'There don't seem to be any errors in the rendering code.

>Dim stream As WICStream = New WICStream(wicFactory, "test9.png", SharpDX.IO.NativeFileAccess.Write)
>Dim encoder As SharpDX.WIC.PngBitmapEncoder = New  SharpDX.WIC.PngBitmapEncoder(CType(wicFactory, System.IntPtr))
>encoder.Initialize(stream)

移植到C#的相同代码运行正常,但在VB中运行时,encoder.initialize语句失败并出现保护异常。我有什么想法可能做错了吗?我尝试将流设置为零(使用搜索),但没有区别。

布赖恩

0 个答案:

没有答案