我在window 7移动应用程序中创建了一个扫描二维码图像的应用程序,但我的问题是类似内容类型的URL被成功解码,但是关于人或大文本的信息没有解码,它会导致渲染异常.
我的代码如下:
private void ScanPreviewBuffer()
{
try
{
_photoCamera.GetPreviewBufferY(_luminance.PreviewBufferY);
var binarizer = new HybridBinarizer(_luminance);
var binBitmap = new BinaryBitmap(binarizer);
var result = _reader.decode(binBitmap);
Dispatcher.BeginInvoke(() => DisplayResult(result.Text));
}
catch(Exception ex)
{
ex.ToString();
}
}
public 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 sbyte[] Matrix
{
get { return (sbyte[])(Array)PreviewBufferY; }
}
public override sbyte[] getRow(int y, sbyte[] row)
{
if (row == null || row.Length < Width)
{
row = new sbyte[Width];
}
for (int i = 0; i < Height; i++)
row[i] = (sbyte)PreviewBufferY[i * Width + y];
return row;
}
此代码在解码具有大量数据的二维码图像时会导致渲染异常。它有什么问题?