我正在尝试编写一些能够方便地处理视频帧的代码.我收到框架作为System.Windows.Media.Imaging.WriteableBitmap.出于测试目的,我只是应用一个简单的阈值滤波器来处理BGRA格式图像,并根据BGR像素的平均值将每个像素分配为黑色或白色.
这是我的"安全"版本:
public static void ApplyFilter(WriteableBitmap Bitmap, byte Threshold)
{
// Let's just make this work for this format
if (Bitmap.Format != PixelFormats.Bgr24
&& Bitmap.Format != PixelFormats.Bgr32)
{
return;
}
// Calculate the number of bytes per pixel (should be 4 for this format).
var bytesPerPixel = (Bitmap.Format.BitsPerPixel + 7) / 8;
// Stride is bytes per pixel times the number of pixels.
// Stride is the byte width of a single rectangle row.
var stride = Bitmap.PixelWidth …Run Code Online (Sandbox Code Playgroud) 我是一名想成为游戏开发者的人,我更喜欢使用C#.当我问到在C#中编写实时应用程序的缺点是什么时,我得到了一个重要的观点:垃圾收集及其对性能的不可预测的影响.
我的反问题是,非托管C#怎么样?它与C++的比较(性能方面)如何?它是开发软件的有效选择吗?
我没有听到很多关于非托管c#和所有"非托管c#与C++"的问题,我看到的问题没有得到答复或回答不准确.这些问题不是堆栈溢出.
编辑:
我相信无管理的C#是"不安全代码".