如何从RenderTargetBitmap Bitblit到WriteableBitmap?

我将RenderTargetBitmap渲染成几十个视觉效果。 每个都在它自己的Rect中呈现。 我想要做的是将从RenderTargetBitmap实例渲染的这些Rect区域之一复制到WriteableBitmap的相同区域...快速复制矩形像素或smth。 像那样。

那么,有没有办法以快速的方式将RenderTargetBitmap中的rect复制到WriteableBitmap?

提前致谢。


通过像这样将整个RenderTargetBitmap复制到WriteableBitmap解决:

 protected override void OnRender(DrawingContext drawingContext)
 {
   if (ActualWidth == 0 || ActualHeight == 0) return;
   // Create destination bitmap
   wb = new WriteableBitmap((int) ActualWidth, (int) ActualHeight, 96, 96, PixelFormats.Pbgra32, null);
   wb.Lock();
   rtb = new RenderTargetBitmap(wb.PixelWidth, wb.PixelHeight, wb.DpiX, wb.DpiY, PixelFormats.Pbgra32);
   foreach (MyVisual visual in visuals)
   {
     visual.Render(rtb);
   }

   rtb.CopyPixels(new Int32Rect(0,0, rtb.PixelWidth, rtb.PixelHeight), 
   wb.BackBuffer,
   wb.BackBufferStride * wb.PixelHeight,  wb.BackBufferStride);

   wb.AddDirtyRect(new Int32Rect(0, 0, (int)ActualWidth, (int)ActualHeight));
   wb.Unlock();

   drawingContext.DrawImage(wb, new Rect(0, 0, ActualWidth, ActualHeight));
}
链接地址: http://www.djcxy.com/p/4565.html

上一篇: How to bitblit from RenderTargetBitmap to WriteableBitmap?

下一篇: CouchDB / NoSQL and Domain Driven Design?