本文整理匯總了C#中ZXing.Common.BitMatrix.getEnclosingRectangle方法的典型用法代碼示例。如果您正苦於以下問題:C# BitMatrix.getEnclosingRectangle方法的具體用法?C# BitMatrix.getEnclosingRectangle怎麽用?C# BitMatrix.getEnclosingRectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ZXing.Common.BitMatrix
的用法示例。
在下文中一共展示了BitMatrix.getEnclosingRectangle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: extractPureBits
/// <summary>
/// This method detects a code in a "pure" image -- that is, pure monochrome image
/// which contains only an unrotated, unskewed, image of a code, with some white border
/// around it. This is a specialized method that works exceptionally fast in this special
/// case.
///
/// @see com.google.zxing.pdf417.PDF417Reader#extractPureBits(BitMatrix)
/// @see com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix)
/// @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix)
/// </summary>
private static BitMatrix extractPureBits(BitMatrix image)
{
int[] enclosingRectangle = image.getEnclosingRectangle();
if (enclosingRectangle == null)
{
return null;
}
int left = enclosingRectangle[0];
int top = enclosingRectangle[1];
int width = enclosingRectangle[2];
int height = enclosingRectangle[3];
// Now just read off the bits
BitMatrix bits = new BitMatrix(MATRIX_WIDTH, MATRIX_HEIGHT);
for (int y = 0; y < MATRIX_HEIGHT; y++)
{
int iy = top + (y * height + height / 2) / MATRIX_HEIGHT;
for (int x = 0; x < MATRIX_WIDTH; x++)
{
int ix = left + (x * width + width / 2 + (y & 0x01) * width / 2) / MATRIX_WIDTH;
if (image[ix, iy])
{
bits[x, y] = true;
}
}
}
return bits;
}