这看起来像是dup问题,但没有人回答实际的问题。
这里:基本上,我在代码中将ViewPort3D呈现为2D快照,但需要将该类型RenderTargetBitmap转换为System.Drawing.Bitmap类型(以便在2D端进行进一步处理)。
Dim bmpRen As New RenderTargetBitmap(1024, 550, 96, 96, PixelFormats.Pbgra32)
bmpRen.Render(Me.vp3dTiles) 'render the viewport as 2D snapshot虽然我知道如何将其保存到文件中,但我宁愿跳过这一步,将bmpRen转换为System.Drawing.Bitmap类型,但没有这样做的方法。
发布于 2013-11-20 06:37:41
RenderedTargetBitmap是一个BitmapSource,所以BmpBitmapEncoder可以为我们进行转换:
这是在C#中实现的,但它应该可以顺利地转换到VB中。
RenderTargetBitmap bmpRen = new RenderTargetBitmap(1024, 550, 96, 96, PixelFormats.Pbgra32);
bmpRen.Render(vp3dTiles);
MemoryStream stream = new MemoryStream();
BitmapEncoder encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmpRen));
encoder.Save(stream);
Bitmap bitmap = new Bitmap(stream);https://stackoverflow.com/questions/20083210
复制相似问题