【问题标题】:C# photo capture device wp8C#照片捕捉设备wp8
【发布时间】:2013-07-04 11:38:38
【问题描述】:

根据文档,C# 照片捕获设备中有一种方法是PhotoCaptureDevice.GetPreviewBufferYCbCr,它采用带有out 参数的一个字节数组。但是,当我尝试像captureDevice.GetPreviewBufferYCbCr(out byteArray); 这样的东西时,它会给我一个编译时错误,说Error 2 Argument 1 should not be passed with the 'out' keyword。 out 关键字的文档说我们必须在调用和方法定义中都使用 out 关键字。

Photo Capture device function documentation

out keyword documentation

任何帮助都会非常感谢

【问题讨论】:

  • 你的 byteArray 初始化了吗?
  • 我认为是的,就像byte[] byteArray = new byte[Convert.ToInt32((pWidth * pHeight) + (2 * (totalLength / 4)))]; captureDevice.GetPreviewBufferYCbCr(out byteArray);
  • 另外我认为ref关键字需要在传递之前初始化关键字
  • 关键字refout不同。
  • 是的,我知道这就是为什么我写 ref 需要初始化变量而不是 out

标签: c# out


【解决方案1】:

应该是这样的:

byte[] byteArray; // Initialization is not required
captureDevice.GetPreviewBufferYCbCr(out byteArray);

ref 要求变量在被传递之前被初始化,而不是 out

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-16
    • 2015-09-26
    相关资源
    最近更新 更多