Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将win phone 8.1(silverlight)的WriteableBitmap转换为com.google.zxing的二进制位图_C#_Silverlight_Zxing_Win Phone Silverlight 8.1 - Fatal编程技术网

C# 将win phone 8.1(silverlight)的WriteableBitmap转换为com.google.zxing的二进制位图

C# 将win phone 8.1(silverlight)的WriteableBitmap转换为com.google.zxing的二进制位图,c#,silverlight,zxing,win-phone-silverlight-8.1,C#,Silverlight,Zxing,Win Phone Silverlight 8.1,花了将近一天的时间搜索,但找不到合适的解决方案。我正在为基于Silverlight的win 8.1手机应用程序开发QR读取模块(不是win 8.1手机原生版) 我正在使用zxing库添加完整的QR模块。我已经达到了从照相机(MediaCapture)获取图像的程度,这是一个对象WriteableBitmap,我想使用api QRCodeReader.decode(BinaryBitmap bb) 正如大多数文章所述,我曾尝试使用RGBLuminanceSource,但这在本机应用程序中有效(因为

花了将近一天的时间搜索,但找不到合适的解决方案。我正在为基于Silverlight的win 8.1手机应用程序开发QR读取模块(不是win 8.1手机原生版)

我正在使用zxing库添加完整的QR模块。我已经达到了从照相机(MediaCapture)获取图像的程度,这是一个对象WriteableBitmap,我想使用api QRCodeReader.decode(BinaryBitmap bb)

正如大多数文章所述,我曾尝试使用RGBLuminanceSource,但这在本机应用程序中有效(因为它需要引用System.Windows,这对基于Silverlight的应用程序无效)


有人能指导我如何将WriteableBitmap转换为BinaryBitmap吗?

我在使用PhotoCamera类的zxing的pre-window phone 8.1上使用了以下代码。现在我不确定这是否仍然适用于您,但这里是
LuminanceSource
派生类

internal class PhotoCameraLuminanceSource : LuminanceSource
{
    public byte[] PreviewBufferY { get; private set; }

    public PhotoCameraLuminanceSource(int width, int height)
        : base(width, height)
    {
        PreviewBufferY = new byte[width * height];
    }

    public override byte[] Matrix
    {
        get { return (byte[])(Array)PreviewBufferY; }
    }

    public override byte[] getRow(int y, byte[] row)
    {
        if (row == null || row.Length < Width)
        {
            row = new byte[Width];
        }

        for (int i = 0; i < Height; i++)
            row[i] = (byte)PreviewBufferY[i * Width + y];

        return row;
    }
}

其中,
\u luminance
类型为
光测光源

我在带zxing的预开窗手机8.1上使用了以下代码,并使用了PhotoCamera类。现在我不确定这是否对您仍然有效,但这里是
LuminanceSource
派生类

internal class PhotoCameraLuminanceSource : LuminanceSource
{
    public byte[] PreviewBufferY { get; private set; }

    public PhotoCameraLuminanceSource(int width, int height)
        : base(width, height)
    {
        PreviewBufferY = new byte[width * height];
    }

    public override byte[] Matrix
    {
        get { return (byte[])(Array)PreviewBufferY; }
    }

    public override byte[] getRow(int y, byte[] row)
    {
        if (row == null || row.Length < Width)
        {
            row = new byte[Width];
        }

        for (int i = 0; i < Height; i++)
            row[i] = (byte)PreviewBufferY[i * Width + y];

        return row;
    }
}
其中,
\u亮度
光电照明灯源类型