C#学习教程:从一个图像复制ROI并复制到wpf中的另一个图像,点InBottomRight,ImageSourceoutputImage,点outTopLeft);该函数复制一部分输入图像(inTopLeft和inBottomRight定义的ROI),复制到outTopLeft的outputImage中。我可以在WPF中通过操纵像素来完成此操作,但我正在寻找一种可以更快地完成此操作的解决方案。在WPF中执行此操作的最快方法是什么?你的方法可能是这样的:以上就是C#学习教程:从一张图片复制ROI,复制到wpf中的另一张图片分享的全部内容,如果对大家有用需要进一步了解C#学习教程,希望大家多多关注privateBitmapSourceCopyRegion(BitmapSourcesourceBitmap,Int32RectsourceRect,BitmapSourcetargetBitmap,inttargetX,inttargetY){if(sourceBitmap.Format!=targetBitmap.Format){thrownewArgumentException("源和目标位图必须有mat相同的像素。”);}varbytesPerPixel=(sourceBitmap.Format.BitsPerPixel+7)/8;varstride=bytesPerPixel*sourceRect.Width;varpixelBuffer=newbyte[stride*sourceRect.Height];sourceBitmap.CopyPixels(sourceRect,pixelBuffer,stride,0);varoutputBitmap=newWriteableBitmap(targetBitmap);sourceRect.X=targetX;sourceRect.Y=targetY;outputBitmap.WritePixels(sourceRect,pixelBuffer,stride,0);返回输出位图;如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
