public Result decode2(BinaryBitmap image, Dictionary<object, object> hints) { int width = image.Width; int height = image.Height; int halfWidth = Math.Floor(width / 2); int halfHeight = Math.Floor(height / 2); BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight); try { return delegate_Renamed.decode2(topLeft, hints); } catch (Exception e) { if (e.Message.IndexOf("ReaderException") < 0) throw e; // continue } BinaryBitmap topRight = image.crop(halfWidth, 0, halfWidth, halfHeight); try { return delegate_Renamed.decode2(topRight, hints); } catch (Exception e) { if (e.Message.IndexOf("ReaderException") < 0) throw e; // continue } BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight); try { return delegate_Renamed.decode2(bottomLeft, hints); } catch (Exception e) { if (e.Message.IndexOf("ReaderException") < 0) throw e; // continue } BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight); try { return delegate_Renamed.decode2(bottomRight, hints); } catch (Exception e) { if (e.Message.IndexOf("ReaderException") < 0) throw e; // continue } int quarterWidth = Math.Floor(halfWidth / 2); int quarterHeight = Math.Floor(halfHeight / 2); BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight); return delegate_Renamed.decode2(center, hints); }
public Result decode(BinaryBitmap image, System.Collections.Hashtable hints) { int width = image.Width; int height = image.Height; int halfWidth = width / 2; int halfHeight = height / 2; BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight); try { return(delegate_Renamed.decode(topLeft, hints)); } catch (ReaderException) { // continue } BinaryBitmap topRight = image.crop(halfWidth, 0, halfWidth, halfHeight); try { return(delegate_Renamed.decode(topRight, hints)); } catch (ReaderException) { // continue } BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight); try { return(delegate_Renamed.decode(bottomLeft, hints)); } catch (ReaderException) { // continue } BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight); try { return(delegate_Renamed.decode(bottomRight, hints)); } catch (ReaderException) { // continue } int quarterWidth = halfWidth / 2; int quarterHeight = halfHeight / 2; BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight); return(delegate_Renamed.decode(center, hints)); }
// public Result decode(BinaryBitmap image, System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com) public Result decode(BinaryBitmap image, System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com) { int width = image.Width; int height = image.Height; int halfWidth = width / 2; int halfHeight = height / 2; BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight); try { return(delegate_Renamed.decode(topLeft, hints)); } catch (ReaderException re) { // continue } BinaryBitmap topRight = image.crop(halfWidth, 0, halfWidth, halfHeight); try { return(delegate_Renamed.decode(topRight, hints)); } catch (ReaderException re) { // continue } BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight); try { return(delegate_Renamed.decode(bottomLeft, hints)); } catch (ReaderException re) { // continue } BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight); try { return(delegate_Renamed.decode(bottomRight, hints)); } catch (ReaderException re) { // continue } int quarterWidth = halfWidth / 2; int quarterHeight = halfHeight / 2; BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight); return(delegate_Renamed.decode(center, hints)); }
public Result decode(BinaryBitmap image, System.Collections.Hashtable hints) { int width = image.Width; int height = image.Height; int halfWidth = width / 2; int halfHeight = height / 2; BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight); try { return delegate_Renamed.decode(topLeft, hints); } catch (ReaderException re) { // continue } BinaryBitmap topRight = image.crop(halfWidth, 0, halfWidth, halfHeight); try { return delegate_Renamed.decode(topRight, hints); } catch (ReaderException re) { // continue } BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight); try { return delegate_Renamed.decode(bottomLeft, hints); } catch (ReaderException re) { // continue } BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight); try { return delegate_Renamed.decode(bottomRight, hints); } catch (ReaderException re) { // continue } int quarterWidth = halfWidth / 2; int quarterHeight = halfHeight / 2; BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight); return delegate_Renamed.decode(center, hints); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap image, java.util.Map<com.google.zxing.DecodeHintType,?> hints) throws com.google.zxing.NotFoundException, com.google.zxing.ChecksumException, com.google.zxing.FormatException public Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hints) { int width = image.Width; int height = image.Height; int halfWidth = width / 2; int halfHeight = height / 2; BinaryBitmap topLeft = image.crop(0, 0, halfWidth, halfHeight); try { return @delegate.decode(topLeft, hints); } catch (NotFoundException re) { // continue } BinaryBitmap topRight = image.crop(halfWidth, 0, halfWidth, halfHeight); try { return @delegate.decode(topRight, hints); } catch (NotFoundException re) { // continue } BinaryBitmap bottomLeft = image.crop(0, halfHeight, halfWidth, halfHeight); try { return @delegate.decode(bottomLeft, hints); } catch (NotFoundException re) { // continue } BinaryBitmap bottomRight = image.crop(halfWidth, halfHeight, halfWidth, halfHeight); try { return @delegate.decode(bottomRight, hints); } catch (NotFoundException re) { // continue } int quarterWidth = halfWidth / 2; int quarterHeight = halfHeight / 2; BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight); return @delegate.decode(center, hints); }
// added by .net follower (http://dotnetfollower.com) // private void doDecodeMultiple(BinaryBitmap image, System.Collections.Hashtable hints, System.Collections.ArrayList results, int xOffset, int yOffset) // commented by .net follower (http://dotnetfollower.com) private void doDecodeMultiple(BinaryBitmap image, System.Collections.Generic.Dictionary<Object, Object> hints, System.Collections.Generic.List<Object> results, int xOffset, int yOffset) { Result result; try { result = delegate_Renamed.decode(image, hints); } catch (ReaderException re) { return ; } bool alreadyFound = false; for (int i = 0; i < results.Count; i++) { Result existingResult = (Result) results[i]; if (existingResult.Text.Equals(result.Text)) { alreadyFound = true; break; } } if (alreadyFound) { return ; } results.Add(translateResultPoints(result, xOffset, yOffset)); ResultPoint[] resultPoints = result.ResultPoints; if (resultPoints == null || resultPoints.Length == 0) { return ; } int width = image.Width; int height = image.Height; float minX = width; float minY = height; float maxX = 0.0f; float maxY = 0.0f; for (int i = 0; i < resultPoints.Length; i++) { ResultPoint point = resultPoints[i]; float x = point.X; float y = point.Y; if (x < minX) { minX = x; } if (y < minY) { minY = y; } if (x > maxX) { maxX = x; } if (y > maxY) { maxY = y; } } // Decode left of barcode if (minX > MIN_DIMENSION_TO_RECUR) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" doDecodeMultiple(image.crop(0, 0, (int) minX, height), hints, results, xOffset, yOffset); } // Decode above barcode if (minY > MIN_DIMENSION_TO_RECUR) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" doDecodeMultiple(image.crop(0, 0, width, (int) minY), hints, results, xOffset, yOffset); } // Decode right of barcode if (maxX < width - MIN_DIMENSION_TO_RECUR) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" doDecodeMultiple(image.crop((int) maxX, 0, width - (int) maxX, height), hints, results, xOffset + (int) maxX, yOffset); } // Decode below barcode if (maxY < height - MIN_DIMENSION_TO_RECUR) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" doDecodeMultiple(image.crop(0, (int) maxY, width, height - (int) maxY), hints, results, xOffset, yOffset + (int) maxY); } }
private void doDecodeMultiple(BinaryBitmap image, System.Collections.Hashtable hints, System.Collections.ArrayList results, int xOffset, int yOffset) { Result result; try { result = delegate_Renamed.decode(image, hints); } catch (ReaderException) { return; } bool alreadyFound = false; for (int i = 0; i < results.Count; i++) { Result existingResult = (Result)results[i]; if (existingResult.Text.Equals(result.Text)) { alreadyFound = true; break; } } if (alreadyFound) { return; } results.Add(translateResultPoints(result, xOffset, yOffset)); ResultPoint[] resultPoints = result.ResultPoints; if (resultPoints == null || resultPoints.Length == 0) { return; } int width = image.Width; int height = image.Height; float minX = width; float minY = height; float maxX = 0.0f; float maxY = 0.0f; for (int i = 0; i < resultPoints.Length; i++) { ResultPoint point = resultPoints[i]; float x = point.X; float y = point.Y; if (x < minX) { minX = x; } if (y < minY) { minY = y; } if (x > maxX) { maxX = x; } if (y > maxY) { maxY = y; } } // Decode left of barcode if (minX > MIN_DIMENSION_TO_RECUR) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" doDecodeMultiple(image.crop(0, 0, (int)minX, height), hints, results, xOffset, yOffset); } // Decode above barcode if (minY > MIN_DIMENSION_TO_RECUR) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" doDecodeMultiple(image.crop(0, 0, width, (int)minY), hints, results, xOffset, yOffset); } // Decode right of barcode if (maxX < width - MIN_DIMENSION_TO_RECUR) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" doDecodeMultiple(image.crop((int)maxX, 0, width - (int)maxX, height), hints, results, xOffset + (int)maxX, yOffset); } // Decode below barcode if (maxY < height - MIN_DIMENSION_TO_RECUR) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" doDecodeMultiple(image.crop(0, (int)maxY, width, height - (int)maxY), hints, results, xOffset, yOffset + (int)maxY); } }
private void doDecodeMultiple(BinaryBitmap image, IDictionary<DecodeHintType, object> hints, IList<Result> results, int xOffset, int yOffset) { Result result; try { result = @delegate.decode(image, hints); } catch (ReaderException re) { return; } bool alreadyFound = false; foreach (Result existingResult in results) { if (existingResult.Text.Equals(result.Text)) { alreadyFound = true; break; } } if (!alreadyFound) { results.Add(translateResultPoints(result, xOffset, yOffset)); } ResultPoint[] resultPoints = result.ResultPoints; if (resultPoints == null || resultPoints.Length == 0) { return; } int width = image.Width; int height = image.Height; float minX = width; float minY = height; float maxX = 0.0f; float maxY = 0.0f; foreach (ResultPoint point in resultPoints) { float x = point.X; float y = point.Y; if (x < minX) { minX = x; } if (y < minY) { minY = y; } if (x > maxX) { maxX = x; } if (y > maxY) { maxY = y; } } // Decode left of barcode if (minX > MIN_DIMENSION_TO_RECUR) { doDecodeMultiple(image.crop(0, 0, (int) minX, height), hints, results, xOffset, yOffset); } // Decode above barcode if (minY > MIN_DIMENSION_TO_RECUR) { doDecodeMultiple(image.crop(0, 0, width, (int) minY), hints, results, xOffset, yOffset); } // Decode right of barcode if (maxX < width - MIN_DIMENSION_TO_RECUR) { doDecodeMultiple(image.crop((int) maxX, 0, width - (int) maxX, height), hints, results, xOffset + (int) maxX, yOffset); } // Decode below barcode if (maxY < height - MIN_DIMENSION_TO_RECUR) { doDecodeMultiple(image.crop(0, (int) maxY, width, height - (int) maxY), hints, results, xOffset, yOffset + (int) maxY); } }