private static void testXOR(BitMatrix dataMatrix, BitMatrix flipMatrix, BitMatrix expectedMatrix) { var matrix = (BitMatrix)dataMatrix.Clone(); matrix.xor(flipMatrix); Assert.AreEqual(expectedMatrix, matrix); }
/// <summary> /// <p>Detects a PDF417 Code in an image. Checks 0, 90, 180, and 270 degree rotations.</p> /// </summary> /// <param name="image">barcode image to decode</param> /// <param name="hints">optional hints to detector</param> /// <param name="multiple">if true, then the image is searched for multiple codes. If false, then at most one code will be found and returned</param> /// <returns> /// <see cref="PDF417DetectorResult"/> encapsulating results of detecting a PDF417 code /// </returns> public static PDF417DetectorResult detect(BinaryBitmap image, IDictionary <DecodeHintType, object> hints, bool multiple) { // TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even // different binarizers (SF: or different Skipped Row Counts/Steps?) //boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER); BitMatrix bitMatrix = image.BlackMatrix; if (bitMatrix == null) { return(null); } List <ResultPoint[]> barcodeCoordinates = detect(multiple, bitMatrix); // Try 180, 270, 90 degree rotations, in that order if (barcodeCoordinates.Count == 0) { bitMatrix = (BitMatrix)bitMatrix.Clone(); for (int rotate = 0; barcodeCoordinates.Count == 0 && rotate < 3; rotate++) { if (rotate != 1) { bitMatrix.rotate180(); } else { bitMatrix.rotate90(); } barcodeCoordinates = detect(multiple, bitMatrix); } } return(new PDF417DetectorResult(bitMatrix, barcodeCoordinates)); }
public void testUnset() { var emptyMatrix = new BitMatrix(3, 3); var matrix = (BitMatrix)emptyMatrix.Clone(); matrix[1, 1] = true; Assert.AreNotEqual(emptyMatrix, matrix); matrix[1, 1] = false; Assert.AreEqual(emptyMatrix, matrix); matrix[1, 1] = false; Assert.AreEqual(emptyMatrix, matrix); }
/// <summary> /// Switches the control into edit mode and allows to change values of the matrix. /// </summary> public void StartEditing() { oldMatrix = matrix.Clone(); oldDimension = Dimension; rowEditStatus = new List <EditStatus>(Dimension.Height); colEditStatus = new List <EditStatus>(Dimension.Width); for (int r = 0; r < Dimension.Height; r++) { rowEditStatus.Add(EditStatus.Fixed); } for (int r = 0; r < Dimension.Width; r++) { colEditStatus.Add(EditStatus.Fixed); } IsEditing = true; UpdateSize(); }
public void testXOR() { var emptyMatrix = new BitMatrix(3, 3); var fullMatrix = new BitMatrix(3, 3); fullMatrix.setRegion(0, 0, 3, 3); var centerMatrix = new BitMatrix(3, 3); centerMatrix.setRegion(1, 1, 1, 1); var invertedCenterMatrix = (BitMatrix)fullMatrix.Clone(); invertedCenterMatrix[1, 1] = false; var badMatrix = new BitMatrix(4, 4); testXOR(emptyMatrix, emptyMatrix, emptyMatrix); testXOR(emptyMatrix, centerMatrix, centerMatrix); testXOR(emptyMatrix, fullMatrix, fullMatrix); testXOR(centerMatrix, emptyMatrix, centerMatrix); testXOR(centerMatrix, centerMatrix, emptyMatrix); testXOR(centerMatrix, fullMatrix, invertedCenterMatrix); testXOR(invertedCenterMatrix, emptyMatrix, invertedCenterMatrix); testXOR(invertedCenterMatrix, centerMatrix, fullMatrix); testXOR(invertedCenterMatrix, fullMatrix, centerMatrix); testXOR(fullMatrix, emptyMatrix, fullMatrix); testXOR(fullMatrix, centerMatrix, invertedCenterMatrix); testXOR(fullMatrix, fullMatrix, emptyMatrix); try { ((BitMatrix)emptyMatrix.Clone()).xor(badMatrix); Assert.Fail(); } catch (ArgumentException) { } try { ((BitMatrix)badMatrix.Clone()).xor(emptyMatrix); Assert.Fail(); } catch (ArgumentException) { } }
public static void CloneBitMatrix(BitMatrix matrixToRead) { BitMatrix clone = matrixToRead.Clone(); }
private static void testXOR(BitMatrix dataMatrix, BitMatrix flipMatrix, BitMatrix expectedMatrix) { var matrix = (BitMatrix) dataMatrix.Clone(); matrix.xor(flipMatrix); Assert.AreEqual(expectedMatrix, matrix); }
public void testXOR() { var emptyMatrix = new BitMatrix(3, 3); var fullMatrix = new BitMatrix(3, 3); fullMatrix.setRegion(0, 0, 3, 3); var centerMatrix = new BitMatrix(3, 3); centerMatrix.setRegion(1, 1, 1, 1); var invertedCenterMatrix = (BitMatrix) fullMatrix.Clone(); invertedCenterMatrix[1, 1] = false; var badMatrix = new BitMatrix(4, 4); testXOR(emptyMatrix, emptyMatrix, emptyMatrix); testXOR(emptyMatrix, centerMatrix, centerMatrix); testXOR(emptyMatrix, fullMatrix, fullMatrix); testXOR(centerMatrix, emptyMatrix, centerMatrix); testXOR(centerMatrix, centerMatrix, emptyMatrix); testXOR(centerMatrix, fullMatrix, invertedCenterMatrix); testXOR(invertedCenterMatrix, emptyMatrix, invertedCenterMatrix); testXOR(invertedCenterMatrix, centerMatrix, fullMatrix); testXOR(invertedCenterMatrix, fullMatrix, centerMatrix); testXOR(fullMatrix, emptyMatrix, fullMatrix); testXOR(fullMatrix, centerMatrix, invertedCenterMatrix); testXOR(fullMatrix, fullMatrix, emptyMatrix); try { ((BitMatrix) emptyMatrix.Clone()).xor(badMatrix); Assert.Fail(); } catch (ArgumentException) { } try { ((BitMatrix) badMatrix.Clone()).xor(emptyMatrix); Assert.Fail(); } catch (ArgumentException) { } }
public void testUnset() { var emptyMatrix = new BitMatrix(3, 3); var matrix = (BitMatrix) emptyMatrix.Clone(); matrix[1, 1] = true; Assert.AreNotEqual(emptyMatrix, matrix); matrix[1, 1] = false; Assert.AreEqual(emptyMatrix, matrix); matrix[1, 1] = false; Assert.AreEqual(emptyMatrix, matrix); }