name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
zxing_GenericGFPoly_evaluateAt_rdh | /**
*
* @return evaluation of this polynomial at a given point
*/
int evaluateAt(int a) {
if (a == 0)
{
// Just return the x^0 coefficient
return getCoefficient(0);
}
if (a == 1) {
// Just the sum of the coefficients
int result = 0;
for (int coefficient : coefficients) {
result = GenericGF.addOrSubtract(result, coefficient);}
return result;
}
int result = coefficients[0];
int size = coefficients.length;
for (int i = 1; i < size; i++) {
result = GenericGF.addOrSubtract(f0.multiply(a, result), coefficients[i]);
}
return result;
} | 3.26 |
zxing_GenericGFPoly_isZero_rdh | /**
*
* @return true iff this polynomial is the monomial "0"
*/
boolean isZero() {
return coefficients[0] == 0;
} | 3.26 |
zxing_GenericGFPoly_getDegree_rdh | /**
*
* @return degree of this polynomial
*/
int getDegree() {
return coefficients.length - 1;
} | 3.26 |
zxing_GenericGF_multiply_rdh | /**
*
* @return product of a and b in GF(size)
*/
int multiply(int a, int b) {
if ((a == 0) || (b == 0)) {
return 0;
}
return expTable[(logTable[a] + logTable[b]) % (size - 1)];
} | 3.26 |
zxing_GenericGF_addOrSubtract_rdh | /**
* Implements both addition and subtraction -- they are the same in GF(size).
*
* @return sum/difference of a and b
*/
static int addOrSubtract(int a, int b) {return a ^ b; } | 3.26 |
zxing_GenericGF_exp_rdh | /**
*
* @return 2 to the power of a in GF(size)
*/
int exp(int a) { return
expTable[a];
} | 3.26 |
zxing_GenericGF_log_rdh | /**
*
* @return base 2 log of a in GF(size)
*/
int log(int a) {
if (a == 0) {
throw new IllegalArgumentException();
}
return logTable[a];
} | 3.26 |
zxing_GenericGF_inverse_rdh | /**
*
* @return multiplicative inverse of a
*/
int inverse(int a) {
if (a == 0) {
throw new ArithmeticException();
}
return expTable[(size - logTable[a]) - 1];
} | 3.26 |
zxing_GenericGF_buildMonomial_rdh | /**
*
* @return the monomial representing coefficient * x^degree
*/
GenericGFPoly buildMonomial(int degree, int coefficient) {
if (degree < 0) {
throw new IllegalArgumentException();
}
if (coefficient == 0) {
return zero;
}
int[] coefficients = new int[degree + 1];
coefficients[0] = coefficient;
return new GenericGFPoly(this, coefficients);
} | 3.26 |
zxing_ContactEncoder_trim_rdh | /**
*
* @return null if s is null or empty, or result of s.trim() otherwise
*/
static String trim(String s) {
if (s == null) {
return null;
}
String v0 = s.trim();
return v0.isEmpty() ? null : v0;
} | 3.26 |
zxing_EAN8Writer_encode_rdh | /**
*
* @return a byte array of horizontal pixels (false = white, true = black)
*/
@Override
public boolean[] encode(String contents) {
int v0 = contents.length();
switch (v0)
{
case 7
:
// No check digit present, calculate it and add it
int check;try {
check = UPCEANReader.getStandardUPCEANChecksum(contents);
} catch (FormatException fe) {
throw new IllegalArgumentException(fe);
}
contents +=
check;
break;
case 8 :
try {
if (!UPCEANReader.checkStandardUPCEANChecksum(contents)) {
throw new IllegalArgumentException("Contents do not pass checksum");
}
} catch (FormatException ignored) {
throw new
IllegalArgumentException("Illegal contents");
}
break;
default :
throw new IllegalArgumentException("Requested contents should be 7 or 8 digits long, but got " + v0);
}
checkNumeric(contents);
boolean[] result = new boolean[CODE_WIDTH];
int pos = 0;
pos += appendPattern(result, pos, UPCEANReader.START_END_PATTERN, true);
for (int i = 0; i <= 3; i++) {
int digit = Character.digit(contents.charAt(i), 10);
pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], false);
}
pos += appendPattern(result, pos, UPCEANReader.MIDDLE_PATTERN, false);
for (int i = 4; i <= 7; i++) {
int digit = Character.digit(contents.charAt(i), 10);
pos += appendPattern(result, pos, UPCEANReader.L_PATTERNS[digit], true);
}
appendPattern(result, pos,
UPCEANReader.START_END_PATTERN, true);
return result;
} | 3.26 |
zxing_ResultPoint_crossProductZ_rdh | /**
* Returns the z component of the cross product between vectors BC and BA.
*/
private static float crossProductZ(ResultPoint pointA, ResultPoint pointB, ResultPoint pointC) {
float bX
= pointB.x;
float bY = pointB.y;
return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
} | 3.26 |
zxing_ResultPoint_orderBestPatterns_rdh | /**
* Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC
* and BC is less than AC, and the angle between BC and BA is less than 180 degrees.
*
* @param patterns
* array of three {@code ResultPoint} to order
*/
public static void orderBestPatterns(ResultPoint[] patterns) {
// Find distances between pattern centers
float zeroOneDistance = distance(patterns[0], patterns[1]);
float oneTwoDistance = distance(patterns[1], patterns[2]);
float
zeroTwoDistance = distance(patterns[0], patterns[2]);
ResultPoint pointA;
ResultPoint pointB;
ResultPoint pointC;
// Assume one closest to other two is B; A and C will just be guesses at first
if ((oneTwoDistance >= zeroOneDistance) && (oneTwoDistance >= zeroTwoDistance))
{
pointB = patterns[0];
pointA = patterns[1];
pointC = patterns[2];
} else if ((zeroTwoDistance >= oneTwoDistance) && (zeroTwoDistance >= zeroOneDistance)) {
pointB = patterns[1];
pointA = patterns[0];
pointC = patterns[2];
} else {
pointB = patterns[2];
pointA = patterns[0];
pointC = patterns[1];
}
// Use cross product to figure out whether A and C are correct or flipped.
// This asks whether BC x BA has a positive z component, which is the arrangement
// we want for A, B, C. If it's negative, then we've got it flipped around and
// should swap A and C.
if (crossProductZ(pointA, pointB, pointC) < 0.0F) {ResultPoint temp = pointA;
pointA = pointC;
pointC = temp;
}
patterns[0] = pointA;
patterns[1] = pointB;patterns[2] = pointC;
} | 3.26 |
zxing_ResultPoint_distance_rdh | /**
*
* @param pattern1
* first pattern
* @param pattern2
* second pattern
* @return distance between two points
*/
public static float distance(ResultPoint pattern1, ResultPoint pattern2) {return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y);
} | 3.26 |
zxing_QRCode_isValidMaskPattern_rdh | // Check if "mask_pattern" is valid.
public static boolean isValidMaskPattern(int maskPattern) {
return (maskPattern >= 0) && (maskPattern < NUM_MASK_PATTERNS);
} | 3.26 |
zxing_QRCode_getMode_rdh | /**
*
* @return the mode. Not relevant if {@link com.google.zxing.EncodeHintType#QR_COMPACT} is selected.
*/
public Mode getMode() {
return mode;
} | 3.26 |
zxing_EdifactEncoder_handleEOD_rdh | /**
* Handle "end of data" situations
*
* @param context
* the encoder context
* @param buffer
* the buffer with the remaining encoded characters
*/
private static void handleEOD(EncoderContext context, CharSequence buffer)
{
try {
int count = buffer.length();
if (count == 0) {
return;// Already finished
}
if (count == 1) {// Only an unlatch at the end
context.updateSymbolInfo();
int available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount();
int remaining = context.getRemainingCharacters();
// The following two lines are a hack inspired by the 'fix' from https://sourceforge.net/p/barcode4j/svn/221/
if (remaining > available) {
context.updateSymbolInfo(context.getCodewordCount() + 1);
available = context.getSymbolInfo().getDataCapacity() -
context.getCodewordCount();
}
if ((remaining <= available) && (available <= 2)) {
return;// No unlatch
}
}
if (count > 4) {
throw new IllegalStateException("Count must not exceed 4");
}
int restChars = count - 1;
String encoded = encodeToCodewords(buffer);
boolean endOfSymbolReached = !context.hasMoreCharacters();
boolean restInAscii
= endOfSymbolReached && (restChars <= 2);
if (restChars <= 2) {
context.updateSymbolInfo(context.getCodewordCount() + restChars);
int available =
context.getSymbolInfo().getDataCapacity() - context.getCodewordCount();
if (available >= 3) {
restInAscii = false;
context.updateSymbolInfo(context.getCodewordCount() + encoded.length());
// available = context.symbolInfo.dataCapacity - context.getCodewordCount();
}
}if (restInAscii) {
context.resetSymbolInfo();
context.pos -= restChars;
} else {context.writeCodewords(encoded);
}
} finally {
context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION);
}
} | 3.26 |
zxing_CodaBarReader_toNarrowWidePattern_rdh | // Assumes that counters[position] is a bar.
private int toNarrowWidePattern(int position) {
int end = position + 7;
if (end >= counterLength) {
return
-1;
}
int[] theCounters = counters;
int maxBar = 0;
int minBar = Integer.MAX_VALUE;
for (int j = position;
j < end; j += 2) {
int currentCounter = theCounters[j];
if (currentCounter < minBar) {
minBar = currentCounter;
}
if (currentCounter > maxBar) {
maxBar = currentCounter;
}
}
int thresholdBar = (minBar + maxBar) / 2;
int
maxSpace = 0;
int minSpace = Integer.MAX_VALUE;
for (int j = position + 1; j < end; j += 2) {
int currentCounter = theCounters[j];
if (currentCounter < minSpace) {
minSpace = currentCounter;
}
if (currentCounter > maxSpace) {
maxSpace = currentCounter;
}
}
int thresholdSpace = (minSpace + maxSpace) / 2;
int bitmask = 1 << 7;
int pattern = 0;
for (int i = 0; i < 7; i++) {
int threshold = ((i & 1) == 0) ? thresholdBar
: thresholdSpace;
bitmask >>= 1;
if (theCounters[position + i] > threshold) {
pattern |= bitmask;
}
}
for (int v57 = 0; v57 < CHARACTER_ENCODINGS.length; v57++) {if (CHARACTER_ENCODINGS[v57] == pattern) {
return v57;
}
}
return -1;
} | 3.26 |
zxing_CodaBarReader_setCounters_rdh | /**
* Records the size of all runs of white and black pixels, starting with white.
* This is just like recordPattern, except it records all the counters, and
* uses our builtin "counters" member for storage.
*
* @param row
* row to count from
*/
private void setCounters(BitArray row) throws NotFoundException {
counterLength = 0;
// Start from the first white bit.
int i =
row.getNextUnset(0);
int end
= row.getSize();
if (i >= end) {
throw NotFoundException.getNotFoundInstance();
}
boolean isWhite = true;
int count = 0;
while (i < end) {
if (row.get(i) != isWhite) {
count++;
} else {
counterAppend(count);
count = 1;
isWhite = !isWhite;
}
i++;
}
counterAppend(count);
} | 3.26 |
zxing_CameraManager_requestPreviewFrame_rdh | /**
* A single preview frame will be returned to the handler supplied. The data will arrive as byte[]
* in the message.obj field, with width and height encoded as message.arg1 and message.arg2,
* respectively.
*
* @param handler
* The handler to send the message to.
* @param message
* The what field of the message to be sent.
*/
public synchronized void requestPreviewFrame(Handler handler, int message) {
OpenCamera theCamera = camera;
if ((theCamera != null) &&
previewing) {
previewCallback.setHandler(handler, message);
theCamera.getCamera().setOneShotPreviewCallback(previewCallback);
}} | 3.26 |
zxing_CameraManager_setManualCameraId_rdh | /**
* Allows third party apps to specify the camera ID, rather than determine
* it automatically based on available cameras and their orientation.
*
* @param cameraId
* camera ID of the camera to use. A negative value means "no preference".
*/
public synchronized void setManualCameraId(int cameraId) {
requestedCameraId = cameraId;
} | 3.26 |
zxing_CameraManager_openDriver_rdh | /**
* Opens the camera driver and initializes the hardware parameters.
*
* @param holder
* The surface object which the camera will draw preview frames into.
* @throws IOException
* Indicates the camera driver failed to open.
*/
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
OpenCamera theCamera = camera;
if (theCamera == null) {
theCamera = OpenCameraInterface.open(requestedCameraId);
if (theCamera == null) {
throw new IOException("Camera.open() failed to return object from driver");
}
camera = theCamera;
}
if (!initialized) {
initialized = true;
configManager.initFromCameraParameters(theCamera);
if ((requestedFramingRectWidth > 0) && (requestedFramingRectHeight > 0)) {
setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
requestedFramingRectWidth = 0;
requestedFramingRectHeight = 0;
}
}
Camera cameraObject = theCamera.getCamera();
Camera.Parameters parameters = cameraObject.getParameters();
String parametersFlattened = (parameters == null) ? null : parameters.flatten();// Save these, temporarily
try {
configManager.setDesiredCameraParameters(theCamera, false);
} catch (RuntimeException re) {
// Driver failed
Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
// Reset:
if (parametersFlattened != null) {
parameters = cameraObject.getParameters();
parameters.unflatten(parametersFlattened);
try {
cameraObject.setParameters(parameters);
configManager.setDesiredCameraParameters(theCamera, true);
} catch (RuntimeException re2) {
// Well, darn. Give up
Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
}
}
}
cameraObject.setPreviewDisplay(holder);
} | 3.26 |
zxing_CameraManager_stopPreview_rdh | /**
* Tells the camera to stop drawing preview frames.
*/
public synchronized void stopPreview() {
if (autoFocusManager != null) {
autoFocusManager.stop();
autoFocusManager = null;
}
if ((camera != null) && previewing) {
camera.getCamera().stopPreview();
previewCallback.setHandler(null, 0);
previewing = false;
}
} | 3.26 |
zxing_CameraManager_closeDriver_rdh | /**
* Closes the camera driver if still in use.
*/
public synchronized void closeDriver() {
if (camera != null) {
camera.getCamera().release();
camera = null;
// Make sure to clear these each time we close the camera, so that any scanning rect
// requested by intent is forgotten.
framingRect = null;
framingRectInPreview = null;
}
} | 3.26 |
zxing_CameraManager_buildLuminanceSource_rdh | /**
* A factory method to build the appropriate LuminanceSource object based on the format
* of the preview buffers, as described by Camera.Parameters.
*
* @param data
* A preview frame.
* @param width
* The width of the image.
* @param height
* The height of the image.
* @return A PlanarYUVLuminanceSource instance.
*/
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
Rect rect = getFramingRectInPreview();
if (rect == null) {
return null;
}
// Go ahead and assume it's YUV rather than die.
return new
PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height(), false);
} | 3.26 |
zxing_CameraManager_startPreview_rdh | /**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public synchronized void startPreview() {
OpenCamera theCamera = camera;
if ((theCamera != null) && (!previewing)) {
theCamera.getCamera().startPreview();
previewing = true;
autoFocusManager = new
AutoFocusManager(context, theCamera.getCamera());
}
} | 3.26 |
zxing_CameraManager_setTorch_rdh | /**
* Convenience method for {@link com.google.zxing.client.android.CaptureActivity}
*
* @param newSetting
* if {@code true}, light should be turned on if currently off. And vice versa.
*/
public synchronized void setTorch(boolean newSetting) {
OpenCamera theCamera = camera;
if ((theCamera != null) && (newSetting !=
configManager.getTorchState(theCamera.getCamera()))) {
boolean wasAutoFocusManager = autoFocusManager != null;
if (wasAutoFocusManager) {
autoFocusManager.stop();
autoFocusManager = null;
}
configManager.setTorch(theCamera.getCamera(), newSetting);if (wasAutoFocusManager) {
autoFocusManager = new AutoFocusManager(context, theCamera.getCamera());
autoFocusManager.start();
}
}
} | 3.26 |
zxing_CameraManager_getFramingRect_rdh | /**
* Calculates the framing rect which the UI should draw to show the user where to place the
* barcode. This target helps with alignment as well as forces the user to hold the device
* far enough away to ensure the image will be in focus.
*
* @return The rectangle to draw on screen in window coordinates.
*/
public synchronized Rect getFramingRect() {
if (framingRect == null)
{
if (camera == null) {
return null;
}
Point screenResolution = configManager.getScreenResolution();
if (screenResolution == null) {
// Called early, before init even finished
return null;
}
int width = findDesiredDimensionInRange(screenResolution.x, f0, MAX_FRAME_WIDTH); int height = findDesiredDimensionInRange(screenResolution.y, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT);
int leftOffset = (screenResolution.x - width) / 2;
int topOffset = (screenResolution.y - height) / 2;
framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
}
return
framingRect;
} | 3.26 |
zxing_CameraManager_setManualFramingRect_rdh | /**
* Allows third party apps to specify the scanning rectangle dimensions, rather than determine
* them automatically based on screen resolution.
*
* @param width
* The width in pixels to scan.
* @param height
* The height in pixels to scan.
*/
public synchronized void setManualFramingRect(int width, int height) {
if (initialized) {
Point
screenResolution = configManager.getScreenResolution();
if (width > screenResolution.x) {
width = screenResolution.x;
}
if (height > screenResolution.y) {
height = screenResolution.y;
}
int leftOffset = (screenResolution.x - width) / 2;
int topOffset = (screenResolution.y - height) / 2;
framingRect = new Rect(leftOffset, topOffset, leftOffset +
width, topOffset + height);
Log.d(TAG, "Calculated manual framing rect: " + framingRect);
framingRectInPreview = null;
} else {
requestedFramingRectWidth = width;
requestedFramingRectHeight = height;
}
} | 3.26 |
zxing_CameraManager_getFramingRectInPreview_rdh | /**
* Like {@link #getFramingRect} but coordinates are in terms of the preview frame,
* not UI / screen.
*
* @return {@link Rect} expressing barcode scan area in terms of the preview size
*/
public synchronized Rect getFramingRectInPreview() {
if (framingRectInPreview == null) {
Rect framingRect = getFramingRect();
if (framingRect == null) {
return null;
}
Rect rect = new Rect(framingRect);
Point cameraResolution = configManager.getCameraResolution();
Point screenResolution = configManager.getScreenResolution();
if ((cameraResolution == null) || (screenResolution == null)) {
// Called early, before init even finished
return
null;
}
rect.left = (rect.left * cameraResolution.x) / screenResolution.x;
rect.right = (rect.right * cameraResolution.x) / screenResolution.x;
rect.top = (rect.top * cameraResolution.y) / screenResolution.y;
rect.bottom = (rect.bottom * cameraResolution.y) / screenResolution.y;
framingRectInPreview = rect;
}
return framingRectInPreview;
} | 3.26 |
zxing_HistoryManager_buildHistory_rdh | /**
* <p>Builds a text representation of the scanning history. Each scan is encoded on one
* line, terminated by a line break (\r\n). The values in each line are comma-separated,
* and double-quoted. Double-quotes within values are escaped with a sequence of two
* double-quotes. The fields output are:</p>
*
* <ol>
* <li>Raw text</li>
* <li>Display text</li>
* <li>Format (e.g. QR_CODE)</li>
* <li>Unix timestamp (milliseconds since the epoch)</li>
* <li>Formatted version of timestamp</li>
* <li>Supplemental info (e.g. price info for a product barcode)</li>
* </ol>
*/CharSequence buildHistory() {StringBuilder historyText = new StringBuilder(1000);
SQLiteOpenHelper helper = new DBHelper(activity);
try (SQLiteDatabase db = helper.getReadableDatabase();Cursor cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, null, null, null, null,
DBHelper.TIMESTAMP_COL + " DESC")) {
DateFormat v47
= DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
while (cursor.moveToNext()) {
historyText.append('"').append(massageHistoryField(cursor.getString(0))).append("\",");
historyText.append('"').append(massageHistoryField(cursor.getString(1))).append("\",");
historyText.append('"').append(massageHistoryField(cursor.getString(2))).append("\",");
historyText.append('"').append(massageHistoryField(cursor.getString(3))).append("\",");
// Add timestamp again, formatted
long timestamp
= cursor.getLong(3);
historyText.append('"').append(massageHistoryField(v47.format(timestamp))).append("\",");
// Above we're preserving the old ordering of columns which had formatted data in position 5
historyText.append('"').append(massageHistoryField(cursor.getString(4))).append("\"\r\n");
}
} catch (SQLException sqle) {
Log.w(TAG, sqle);
}return historyText;
} | 3.26 |
zxing_DetectionResultRowIndicatorColumn_adjustCompleteIndicatorColumnRowNumbers_rdh | // TODO implement properly
// TODO maybe we should add missing codewords to store the correct row number to make
// finding row numbers for other columns easier
// use row height count to make detection of invalid row numbers more reliable
void adjustCompleteIndicatorColumnRowNumbers(BarcodeMetadata barcodeMetadata) {
Codeword[] codewords = getCodewords();
setRowNumbers();
removeIncorrectCodewords(codewords, barcodeMetadata);
BoundingBox boundingBox = getBoundingBox();
ResultPoint top = (isLeft) ? boundingBox.getTopLeft() : boundingBox.getTopRight();
ResultPoint bottom = (isLeft) ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
int firstRow = imageRowToCodewordIndex(((int) (top.getY())));
int lastRow = imageRowToCodewordIndex(((int) (bottom.getY())));
// We need to be careful using the average row height. Barcode could be skewed so that we have smaller and
// taller rows
// float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount();
int barcodeRow = -1;
int maxRowHeight = 1;
int currentRowHeight = 0;
for (int codewordsRow = firstRow; codewordsRow < lastRow; codewordsRow++) {
if (codewords[codewordsRow] == null) {
continue;
}
Codeword codeword
= codewords[codewordsRow];
int rowDifference = codeword.getRowNumber() - barcodeRow;
// TODO improve handling with case where first row indicator doesn't start with 0
if (rowDifference == 0) {
currentRowHeight++;
} else if (rowDifference == 1) {
maxRowHeight = Math.max(maxRowHeight, currentRowHeight);currentRowHeight = 1;
barcodeRow = codeword.getRowNumber();
} else if (((rowDifference < 0) || (codeword.getRowNumber() >= barcodeMetadata.getRowCount())) || (rowDifference > codewordsRow)) {
codewords[codewordsRow] = null;
} else {
int checkedRows;
if (maxRowHeight > 2) {
checkedRows = (maxRowHeight - 2) * rowDifference;
} else {
checkedRows = rowDifference;
}
boolean closePreviousCodewordFound = checkedRows >= codewordsRow;
for (int i = 1; (i <=
checkedRows) && (!closePreviousCodewordFound); i++) {
// there must be (height * rowDifference) number of codewords missing. For now we assume height = 1.
// This should hopefully get rid of most problems already.
closePreviousCodewordFound = codewords[codewordsRow - i] != null;
}
if (closePreviousCodewordFound) {
codewords[codewordsRow] = null;
} else {
barcodeRow = codeword.getRowNumber();
currentRowHeight = 1;
}
}}
// return (int) (averageRowHeight + 0.5);
} | 3.26 |
zxing_DetectionResultRowIndicatorColumn_m0_rdh | // TODO maybe we should add missing codewords to store the correct row number to make
// finding row numbers for other columns easier
// use row height count to make detection of invalid row numbers more reliable
private void m0(BarcodeMetadata barcodeMetadata) {
BoundingBox boundingBox = getBoundingBox();
ResultPoint top = (isLeft) ? boundingBox.getTopLeft() : boundingBox.getTopRight();
ResultPoint bottom = (isLeft) ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
int firstRow = imageRowToCodewordIndex(((int) (top.getY())));
int lastRow = imageRowToCodewordIndex(((int) (bottom.getY())));
// float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount();
Codeword[] codewords = getCodewords();
int barcodeRow = -1;
int maxRowHeight = 1;
int v28 = 0;
for (int codewordsRow = firstRow; codewordsRow < lastRow; codewordsRow++) {
if (codewords[codewordsRow] == null) {
continue;
}
Codeword codeword = codewords[codewordsRow];
codeword.setRowNumberAsRowIndicatorColumn();
int rowDifference = codeword.getRowNumber() - barcodeRow;
// TODO improve handling with case where first row indicator doesn't start with 0
if (rowDifference == 0) {
v28++;
} else if (rowDifference == 1) {
maxRowHeight = Math.max(maxRowHeight, v28);
v28 = 1;
barcodeRow = codeword.getRowNumber();
} else if (codeword.getRowNumber() >= barcodeMetadata.getRowCount()) {
codewords[codewordsRow] =
null;
} else {
barcodeRow = codeword.getRowNumber();
v28 = 1;
}
}
// return (int) (averageRowHeight + 0.5);
} | 3.26 |
zxing_DecodeHandler_decode_rdh | /**
* Decode the data within the viewfinder rectangle, and time how long it took. For efficiency,
* reuse the same reader objects from one decode to the next.
*
* @param data
* The YUV preview frame.
* @param width
* The width of the preview frame.
* @param height
* The height of the preview frame.
*/
private void decode(byte[] data, int width, int height) {
Result rawResult = null;PlanarYUVLuminanceSource
source = activity.getCameraManager().buildLuminanceSource(data, width, height);
if (source != null) {BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try { rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
}
Handler handler = activity.getHandler();
if (rawResult != null) {
// Don't log the barcode contents for security.
if (handler != null) {
Message message = Message.obtain(handler, id.decode_succeeded, rawResult);
Bundle bundle = new Bundle();
bundleThumbnail(source, bundle);
message.setData(bundle);
message.sendToTarget();
}
} else if (handler != null) {
Message message = Message.obtain(handler, id.decode_failed);
message.sendToTarget();
}
} | 3.26 |
zxing_IntentResult_m0_rdh | /**
*
* @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names.
*/
public String m0() {
return formatName;
} | 3.26 |
zxing_IntentResult_getRawBytes_rdh | /**
*
* @return raw bytes of the barcode content, if applicable, or null otherwise
*/
public byte[] getRawBytes() {return rawBytes;
} | 3.26 |
zxing_IntentResult_getOrientation_rdh | /**
*
* @return rotation of the image, in degrees, which resulted in a successful scan. May be null.
*/
public Integer getOrientation() {
return orientation;
} | 3.26 |
zxing_IntentResult_getContents_rdh | /**
*
* @return raw content of barcode
*/
public String getContents() {
return contents;
} | 3.26 |
zxing_MatrixUtil_isEmpty_rdh | // Check if "value" is empty.
private static boolean isEmpty(int value) {
return value == (-1);
} | 3.26 |
zxing_MatrixUtil_findMSBSet_rdh | // Return the position of the most significant bit set (to one) in the "value". The most
// significant bit is position 32. If there is no bit set, return 0. Examples:
// - findMSBSet(0) => 0
// - findMSBSet(1) => 1
// - findMSBSet(255) => 8
static int findMSBSet(int value) {
return 32 - Integer.numberOfLeadingZeros(value);
} | 3.26 |
zxing_MatrixUtil_clearMatrix_rdh | // Set all cells to -1. -1 means that the cell is empty (not set yet).
//
// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding
// with the ByteMatrix initialized all to zero.
static void clearMatrix(ByteMatrix matrix) {matrix.clear(((byte) (-1)));
} | 3.26 |
zxing_MatrixUtil_embedDataBits_rdh | // Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true.
// For debugging purposes, it skips masking process if "getMaskPattern" is -1.
// See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.
static void embedDataBits(BitArray dataBits, int maskPattern,
ByteMatrix matrix) throws WriterException {
int bitIndex = 0;
int direction = -1;
// Start from the right bottom cell.
int x = matrix.getWidth() - 1;
int y
= matrix.getHeight() - 1;
while (x > 0) { // Skip the vertical timing pattern.
if (x
== 6) {
x -=
1;
}
while ((y >= 0) && (y < matrix.getHeight())) {for (int i = 0; i < 2; ++i) {
int xx = x - i;
// Skip the cell if it's not empty.
if (!isEmpty(matrix.get(xx, y))) {
continue;
}
boolean bit;
if (bitIndex < dataBits.getSize()) {
bit = dataBits.get(bitIndex);
++bitIndex;
} else {
// Padding bit. If there is no bit left, we'll fill the left cells with 0, as described
// in 8.4.9 of JISX0510:2004 (p. 24).
bit = false;
}
// Skip masking if mask_pattern is -1.
if ((maskPattern != (-1)) && MaskUtil.getDataMaskBit(maskPattern, xx, y)) {bit = !bit;
}
matrix.set(xx, y, bit);
}
y += direction;
}
direction = -direction;// Reverse the direction.
y += direction;
x -= 2;// Move to the left.
}
// All bits should be consumed.
if (bitIndex != dataBits.getSize()) {
throw new WriterException((("Not all bits consumed: "
+ bitIndex) + '/') + dataBits.getSize());
}
} | 3.26 |
zxing_MatrixUtil_makeTypeInfoBits_rdh | // Make bit vector of type information. On success, store the result in "bits" and return true.
// Encode error correction level and mask pattern. See 8.9 of
// JISX0510:2004 (p.45) for details.
static void makeTypeInfoBits(ErrorCorrectionLevel ecLevel, int maskPattern, BitArray bits) throws WriterException {
if (!QRCode.isValidMaskPattern(maskPattern)) {
throw new WriterException("Invalid mask pattern");
}
int typeInfo = (ecLevel.getBits() << 3) | maskPattern;
bits.appendBits(typeInfo, 5);
int bchCode = m0(typeInfo, TYPE_INFO_POLY);
bits.appendBits(bchCode, 10);
BitArray maskBits = new BitArray();
maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15);
bits.xor(maskBits);
if (bits.getSize() != 15) {
// Just in case.
throw new WriterException("should not happen but we got: " + bits.getSize());
}
} | 3.26 |
zxing_MatrixUtil_embedBasicPatterns_rdh | // - Position detection patterns
// - Timing patterns
// - Dark dot at the left bottom corner
// - Position adjustment patterns, if need be
static void embedBasicPatterns(Version version, ByteMatrix matrix) throws WriterException {
// Let's get started with embedding big squares at corners.
m1(matrix);
// Then, embed the dark dot at the left bottom corner.
embedDarkDotAtLeftBottomCorner(matrix);
// Position adjustment patterns appear if version >= 2.
maybeEmbedPositionAdjustmentPatterns(version, matrix);
// Timing patterns should be embedded after position adj. patterns.
embedTimingPatterns(matrix);
} | 3.26 |
zxing_MatrixUtil_maybeEmbedPositionAdjustmentPatterns_rdh | // Embed position adjustment patterns if need be.
private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) {
if (version.getVersionNumber() < 2) {
// The patterns appear if version >= 2
return;
}
int index = version.getVersionNumber() - 1;int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index];
for (int y : coordinates) {
if (y >= 0) {
for (int x : coordinates) {
if ((x >= 0) && isEmpty(matrix.get(x, y))) {
// If the cell is unset, we embed the position adjustment pattern here.
// -2 is necessary since the x/y coordinates point to the center of the pattern, not the
// left top corner.
embedPositionAdjustmentPattern(x - 2, y - 2, matrix); }
}
}
}
} | 3.26 |
zxing_MatrixUtil_buildMatrix_rdh | // Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On
// success, store the result in "matrix" and return true.
static void buildMatrix(BitArray dataBits, ErrorCorrectionLevel ecLevel, Version version, int maskPattern, ByteMatrix matrix) throws WriterException {
clearMatrix(matrix);embedBasicPatterns(version, matrix);
// Type information appear with any version.
embedTypeInfo(ecLevel, maskPattern, matrix);
// Version info appear if version >= 7.
maybeEmbedVersionInfo(version, matrix);
// Data should be embedded at end.
embedDataBits(dataBits, maskPattern, matrix);
} | 3.26 |
zxing_MatrixUtil_maybeEmbedVersionInfo_rdh | // Embed version information if need be. On success, modify the matrix and return true.
// See 8.10 of JISX0510:2004 (p.47) for how to embed version information.
static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) throws WriterException {
if (version.getVersionNumber() < 7) {
// Version info is necessary if version >= 7.
return;// Don't need version info.
}
BitArray versionInfoBits = new BitArray();
makeVersionInfoBits(version, versionInfoBits);int bitIndex = (6 * 3) - 1;// It will decrease from 17 to 0.
for (int i = 0; i < 6; ++i) {
for (int j = 0; j < 3; ++j) {
// Place bits in LSB (least significant bit) to MSB order.
boolean bit = versionInfoBits.get(bitIndex);
bitIndex--;
// Left bottom corner.
matrix.set(i, (matrix.getHeight() - 11) + j, bit);
// Right bottom corner.
matrix.set((matrix.getHeight() - 11) + j, i, bit);
}
}
} | 3.26 |
zxing_MatrixUtil_makeVersionInfoBits_rdh | // Make bit vector of version information. On success, store the result in "bits" and return true.
// See 8.10 of JISX0510:2004 (p.45) for details.
static void makeVersionInfoBits(Version version, BitArray bits) throws WriterException {
bits.appendBits(version.getVersionNumber(), 6);
int bchCode = m0(version.getVersionNumber(),
VERSION_INFO_POLY);
bits.appendBits(bchCode, 12);
if (bits.getSize() != 18) {
// Just in case.
throw new WriterException("should not happen but we got: " + bits.getSize());
}
} | 3.26 |
zxing_MatrixUtil_embedTypeInfo_rdh | // Embed type information. On success, modify the matrix.
static void embedTypeInfo(ErrorCorrectionLevel ecLevel, int maskPattern, ByteMatrix matrix) throws WriterException {
BitArray typeInfoBits = new BitArray();
makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits);
for (int i = 0; i < typeInfoBits.getSize(); ++i) {
// Place bits in LSB to MSB order. LSB (least significant bit) is the last value in
// "typeInfoBits".
boolean bit = typeInfoBits.get((typeInfoBits.getSize() - 1) - i);
// Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46).
int[] coordinates = TYPE_INFO_COORDINATES[i];
int x1 = coordinates[0];
int y1 = coordinates[1];
matrix.set(x1, y1, bit);
int x2;
int y2;
if (i < 8) {
// Right top corner.
x2 = (matrix.getWidth() - i) - 1;
y2 = 8;
} else { // Left bottom corner.
x2 = 8;
y2 = (matrix.getHeight() - 7) + (i - 8);
}
matrix.set(x2, y2, bit);
}
} | 3.26 |
zxing_MatrixUtil_m0_rdh | // The return value is 0xc94 (1100 1001 0100)
//
// Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit
// operations. We don't care if coefficients are positive or negative.
static int m0(int value, int poly) {
if (poly == 0) {
throw new IllegalArgumentException("0 polynomial");
}
// If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1
// from 13 to make it 12.
int msbSetInPoly = findMSBSet(poly);
value <<= msbSetInPoly - 1;
// Do the division business using exclusive-or operations.
while (findMSBSet(value) >= msbSetInPoly) {
value ^= poly << (findMSBSet(value) - msbSetInPoly);
}
// Now the "value" is the remainder (i.e. the BCH code)
return value;
} | 3.26 |
zxing_MultiFormatReader_decode_rdh | /**
* Decode an image using the hints provided. Does not honor existing state.
*
* @param image
* The pixel data to decode
* @param hints
* The hints to use, clearing the previous state.
* @return The contents of the image
* @throws NotFoundException
* Any errors which occurred
*/
@Override
public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException {
setHints(hints);
return decodeInternal(image);
} | 3.26 |
zxing_MultiFormatReader_setHints_rdh | /**
* This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
* to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
* is important for performance in continuous scan clients.
*
* @param hints
* The set of hints to use for subsequent calls to decode(image)
*/
public void setHints(Map<DecodeHintType, ?> hints) {
this.hints = hints;
boolean tryHarder = (hints != null) && hints.containsKey(DecodeHintType.TRY_HARDER);
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> formats = (hints == null) ? null : ((Collection<BarcodeFormat>) (hints.get(DecodeHintType.POSSIBLE_FORMATS)));
Collection<Reader> readers = new ArrayList<>();
if (formats != null) {
boolean addOneDReader = (((((((((formats.contains(BarcodeFormat.UPC_A) || formats.contains(BarcodeFormat.UPC_E)) || formats.contains(BarcodeFormat.EAN_13)) || formats.contains(BarcodeFormat.EAN_8)) || formats.contains(BarcodeFormat.CODABAR)) || formats.contains(BarcodeFormat.CODE_39)) || formats.contains(BarcodeFormat.CODE_93)) || formats.contains(BarcodeFormat.CODE_128)) || formats.contains(BarcodeFormat.ITF)) || formats.contains(BarcodeFormat.RSS_14)) || formats.contains(BarcodeFormat.RSS_EXPANDED);
// Put 1D readers upfront in "normal" mode
if (addOneDReader &&
(!tryHarder)) {
readers.add(new MultiFormatOneDReader(hints));
}
if (formats.contains(BarcodeFormat.QR_CODE)) {
readers.add(new QRCodeReader());
}
if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
readers.add(new DataMatrixReader());
}
if (formats.contains(BarcodeFormat.AZTEC)) {
readers.add(new AztecReader());
}
if (formats.contains(BarcodeFormat.PDF_417)) {
readers.add(new PDF417Reader());
}
if (formats.contains(BarcodeFormat.MAXICODE)) {
readers.add(new MaxiCodeReader());
}
// At end in "try harder" mode
if (addOneDReader && tryHarder) {
readers.add(new MultiFormatOneDReader(hints));
}
}
if (readers.isEmpty()) {
if (!tryHarder) {
readers.add(new MultiFormatOneDReader(hints));
}
readers.add(new QRCodeReader());
readers.add(new DataMatrixReader());
readers.add(new AztecReader());
readers.add(new PDF417Reader());
readers.add(new MaxiCodeReader());
if (tryHarder) {
readers.add(new MultiFormatOneDReader(hints));
}
}
this.readers = readers.toArray(EMPTY_READER_ARRAY);
} | 3.26 |
zxing_MultiFormatReader_decodeWithState_rdh | /**
* Decode an image using the state set up by calling setHints() previously. Continuous scan
* clients will get a <b>large</b> speed increase by using this instead of decode().
*
* @param image
* The pixel data to decode
* @return The contents of the image
* @throws NotFoundException
* Any errors which occurred
*/
public Result decodeWithState(BinaryBitmap image) throws
NotFoundException {
// Make sure to set up the default state so we don't crash
if (readers == null) {
setHints(null);
}
return decodeInternal(image);
} | 3.26 |
zxing_VCardResultParser_formatNames_rdh | /**
* Formats name fields of the form "Public;John;Q.;Reverend;III" into a form like
* "Reverend John Q. Public III".
*
* @param names
* name values to format, in place
*/
private static void formatNames(Iterable<List<String>> names) {
if (names != null) {
for (List<String> v54 : names) {
String name = v54.get(0);
String[] components = new String[5];
int start = 0;
int end;
int componentIndex = 0;
while ((componentIndex < (components.length - 1)) && ((end = name.indexOf(';', start)) >= 0)) {
components[componentIndex] = name.substring(start, end);
componentIndex++;
start = end + 1;
}
components[componentIndex] = name.substring(start);
StringBuilder newName = new StringBuilder(100);
maybeAppendComponent(components, 3, newName);
maybeAppendComponent(components, 1, newName); maybeAppendComponent(components, 2, newName);
maybeAppendComponent(components, 0, newName);
maybeAppendComponent(components, 4, newName);
v54.set(0, newName.toString().trim());}
}
} | 3.26 |
zxing_DecodeHintManager_splitQuery_rdh | /**
* <p>Split a query string into a list of name-value pairs.</p>
*
* <p>This is an alternative to the {@link Uri#getQueryParameterNames()} and
* {@link Uri#getQueryParameters(String)}, which are quirky and not suitable
* for exist-only Uri parameters.</p>
*
* <p>This method ignores multiple parameters with the same name and returns the
* first one only. This is technically incorrect, but should be acceptable due
* to the method of processing Hints: no multiple values for a hint.</p>
*
* @param query
* query to split
* @return name-value pairs
*/
private static Map<String, String> splitQuery(String query) {
Map<String, String> map = new HashMap<>();
int pos = 0;
while (pos < query.length()) {
if (query.charAt(pos) == '&') {
// Skip consecutive ampersand separators.
pos++;
continue;
}
int amp = query.indexOf('&', pos);
int equ = query.indexOf('=', pos);
if (amp < 0) {
// This is the last element in the query, no more ampersand elements.
String name;
String text;
if (equ < 0) {
// No equal sign
name = query.substring(pos);
name = name.replace('+', ' ');// Preemptively decode +
name = Uri.decode(name);
text = "";
} else
{
// Split name and text.
name = query.substring(pos, equ);
name = name.replace('+', ' ');// Preemptively decode +
name = Uri.decode(name);
text = query.substring(equ + 1);
text = text.replace('+', ' ');// Preemptively decode +
text = Uri.decode(text);
}
if (!map.containsKey(name)) {
map.put(name, text);
}break;
}if ((equ < 0) || (equ >
amp)) {
// No equal sign until the &: this is a simple parameter with no value.
String name = query.substring(pos, amp);
name = name.replace('+', ' ');// Preemptively decode +
name = Uri.decode(name);
if (!map.containsKey(name)) {
map.put(name, "");
}
pos = amp + 1;
continue;
}
String name =
query.substring(pos, equ);
name = name.replace('+', ' ');// Preemptively decode +
name = Uri.decode(name);
String text = query.substring(equ + 1, amp);
text = text.replace('+', ' ');// Preemptively decode +
text = Uri.decode(text);
if (!map.containsKey(name)) {
map.put(name, text);
}
pos = amp + 1;
}
return map;
} | 3.26 |
zxing_AztecCode_getLayers_rdh | /**
*
* @return number of levels
*/
public int getLayers() {
return layers;
} | 3.26 |
zxing_AztecCode_isCompact_rdh | /**
*
* @return {@code true} if compact instead of full mode
*/
public boolean isCompact() {
return compact;
} | 3.26 |
zxing_AztecCode_getCodeWords_rdh | /**
*
* @return number of data codewords
*/ public int getCodeWords()
{
return codeWords;
} | 3.26 |
zxing_AztecCode_getSize_rdh | /**
*
* @return size in pixels (width and height)
*/
public int getSize() {
return size;
} | 3.26 |
zxing_AztecCode_m0_rdh | /**
*
* @return the symbol image
*/
public BitMatrix m0()
{
return matrix;
} | 3.26 |
zxing_ViewfinderView_drawResultBitmap_rdh | /**
* Draw a bitmap with the result points highlighted instead of the live scanning display.
*
* @param barcode
* An image of the decoded barcode.
*/
public void drawResultBitmap(Bitmap barcode) {
resultBitmap = barcode;
invalidate();
} | 3.26 |
zxing_AlignmentPattern_combineEstimate_rdh | /**
* Combines this object's current estimate of a finder pattern position and module size
* with a new estimate. It returns a new {@code FinderPattern} containing an average of the two.
*/
AlignmentPattern combineEstimate(float i, float j, float newModuleSize) {
float combinedX = (getX() + j) / 2.0F;
float combinedY = (getY() + i) / 2.0F;
float combinedModuleSize = (estimatedModuleSize + newModuleSize) / 2.0F;
return new AlignmentPattern(combinedX, combinedY, combinedModuleSize);
} | 3.26 |
zxing_AlignmentPattern_aboutEquals_rdh | /**
* <p>Determines if this alignment pattern "about equals" an alignment pattern at the stated
* position and size -- meaning, it is at nearly the same center with nearly the same size.</p>
*/
boolean aboutEquals(float moduleSize, float i, float j) {
if ((Math.abs(i - getY()) <= moduleSize) && (Math.abs(j - getX()) <= moduleSize)) {
float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
return (moduleSizeDiff <= 1.0F) || (moduleSizeDiff <= estimatedModuleSize);
}
return false;
} | 3.26 |
zxing_URIParsedResult_massageURI_rdh | /**
* Transforms a string that represents a URI into something more proper, by adding or canonicalizing
* the protocol.
*/
private static String massageURI(String uri) {
uri = uri.trim();
int protocolEnd = uri.indexOf(':');
if ((protocolEnd < 0) || isColonFollowedByPortNumber(uri, protocolEnd)) {
// No protocol, or found a colon, but it looks like it is after the host, so the protocol is still missing,
// so assume http
uri = "http://" + uri;
}
return uri;
} | 3.26 |
zxing_ErrorCorrectionLevel_forBits_rdh | /**
*
* @param bits
* int containing the two bits encoding a QR Code's error correction level
* @return ErrorCorrectionLevel representing the encoded error correction level
*/
public static ErrorCorrectionLevel forBits(int bits) {
if ((bits < 0) || (bits >= FOR_BITS.length)) {
throw new IllegalArgumentException();
}
return FOR_BITS[bits];
} | 3.26 |
zxing_BinaryBitmap_getHeight_rdh | /**
*
* @return The height of the bitmap.
*/
public int
getHeight() {
return binarizer.getHeight();
} | 3.26 |
zxing_BinaryBitmap_rotateCounterClockwise45_rdh | /**
* Returns a new object with rotated image data by 45 degrees counterclockwise.
* Only callable if {@link #isRotateSupported()} is true.
*
* @return A rotated version of this object.
*/
public BinaryBitmap rotateCounterClockwise45() {
LuminanceSource newSource = binarizer.getLuminanceSource().rotateCounterClockwise45();
return new BinaryBitmap(binarizer.createBinarizer(newSource)); } | 3.26 |
zxing_BinaryBitmap_isCropSupported_rdh | /**
*
* @return Whether this bitmap can be cropped.
*/
public boolean isCropSupported() {
return binarizer.getLuminanceSource().isCropSupported();
} | 3.26 |
zxing_BinaryBitmap_getBlackRow_rdh | /**
* Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
* cached data. Callers should assume this method is expensive and call it as seldom as possible.
* This method is intended for decoding 1D barcodes and may choose to apply sharpening.
*
* @param y
* The row to fetch, which must be in [0, bitmap height)
* @param row
* An optional preallocated array. If null or too small, it will be ignored.
* If used, the Binarizer will call BitArray.clear(). Always use the returned object.
* @return The array of bits for this row (true means black).
* @throws NotFoundException
* if row can't be binarized
*/
public BitArray getBlackRow(int y, BitArray row) throws NotFoundException {
return binarizer.getBlackRow(y, row);
} | 3.26 |
zxing_BinaryBitmap_isRotateSupported_rdh | /**
*
* @return Whether this bitmap supports counter-clockwise rotation.
*/
public boolean isRotateSupported() {
return binarizer.getLuminanceSource().isRotateSupported();
} | 3.26 |
zxing_BinaryBitmap_getBlackMatrix_rdh | /**
* Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive
* and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
* may not apply sharpening. Therefore, a row from this matrix may not be identical to one
* fetched using getBlackRow(), so don't mix and match between them.
*
* @return The 2D array of bits for the image (true means black).
* @throws NotFoundException
* if image can't be binarized to make a matrix
*/
public BitMatrix getBlackMatrix() throws NotFoundException {
// The matrix is created on demand the first time it is requested, then cached. There are two
// reasons for this:
// 1. This work will never be done if the caller only installs 1D Reader objects, or if a
// 1D Reader finds a barcode before the 2D Readers run.
// 2. This work will only be done once even if the caller installs multiple 2D Readers.
if (matrix == null) {
matrix = binarizer.getBlackMatrix();
}
return matrix;
} | 3.26 |
zxing_BinaryBitmap_getWidth_rdh | /**
*
* @return The width of the bitmap.
*/
public int
getWidth() {
return binarizer.getWidth();
} | 3.26 |
zxing_BinaryBitmap_rotateCounterClockwise_rdh | /**
* Returns a new object with rotated image data by 90 degrees counterclockwise.
* Only callable if {@link #isRotateSupported()} is true.
*
* @return A rotated version of this object.
*/
public BinaryBitmap rotateCounterClockwise() {
LuminanceSource newSource = binarizer.getLuminanceSource().rotateCounterClockwise();
return new BinaryBitmap(binarizer.createBinarizer(newSource));
} | 3.26 |
zxing_BinaryBitmap_crop_rdh | /**
* Returns a new object with cropped image data. Implementations may keep a reference to the
* original data rather than a copy. Only callable if isCropSupported() is true.
*
* @param left
* The left coordinate, which must be in [0,getWidth())
* @param top
* The top coordinate, which must be in [0,getHeight())
* @param width
* The width of the rectangle to crop.
* @param height
* The height of the rectangle to crop.
* @return A cropped version of this object.
*/
public BinaryBitmap crop(int left, int top, int
width, int height) {
LuminanceSource newSource = binarizer.getLuminanceSource().crop(left, top, width, height);
return new BinaryBitmap(binarizer.createBinarizer(newSource));
} | 3.26 |
zxing_AddressBookResultHandler_mapIndexToAction_rdh | // This takes all the work out of figuring out which buttons/actions should be in which
// positions, based on which fields are present in this barcode.
private int mapIndexToAction(int index) {
if (index < buttonCount) {
int count = -1;
for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
if (fields[x]) {
count++;
}
if (count ==
index) {
return x;}
}
}
return -1;
} | 3.26 |
zxing_AbstractRSSReader_count_rdh | /**
*
* @param array
* values to sum
* @return sum of values
* @deprecated call {@link MathUtils#sum(int[])}
*/
@Deprecated
protected static int count(int[] array) {
return MathUtils.sum(array);
} | 3.26 |
zxing_PDF417_m1_rdh | /**
*
* @param compact
* if true, enables compaction
*/
public void m1(boolean compact) {
this.compact = compact;
} | 3.26 |
zxing_PDF417_generateBarcodeLogic_rdh | /**
*
* @param msg
* message to encode
* @param errorCorrectionLevel
* PDF417 error correction level to use
* @param autoECI
* automatically insert ECIs if needed
* @throws WriterException
* if the contents cannot be encoded in this format
*/
public void generateBarcodeLogic(String msg, int errorCorrectionLevel, boolean autoECI) throws WriterException
{
// 1. step: High-level encoding
int errorCorrectionCodeWords = PDF417ErrorCorrection.getErrorCorrectionCodewordCount(errorCorrectionLevel);
String
highLevel = PDF417HighLevelEncoder.encodeHighLevel(msg, compaction, encoding, autoECI);
int sourceCodeWords = highLevel.length();
int[] dimension = determineDimensions(sourceCodeWords, errorCorrectionCodeWords);
int cols = dimension[0];
int rows = dimension[1];
int pad = getNumberOfPadCodewords(sourceCodeWords, errorCorrectionCodeWords, cols, rows);
// 2. step: construct data codewords
if (((sourceCodeWords + errorCorrectionCodeWords) + 1) > 929) {
// +1 for symbol length CW
throw new WriterException(("Encoded message contains too many code words, message too big (" + msg.length()) + " bytes)");
}
int n = (sourceCodeWords + pad) + 1;
StringBuilder sb = new StringBuilder(n);
sb.append(((char) (n)));
sb.append(highLevel);
for (int i = 0; i < pad; i++) {
sb.append(((char) (900)));// PAD characters
}
String dataCodewords = sb.toString();
// 3. step: Error correction
String ec = PDF417ErrorCorrection.generateErrorCorrection(dataCodewords, errorCorrectionLevel);// 4. step: low-level encoding
barcodeMatrix = new BarcodeMatrix(rows, cols);
encodeLowLevel(dataCodewords + ec, cols, rows, errorCorrectionLevel, barcodeMatrix);
} | 3.26 |
zxing_PDF417_setDimensions_rdh | /**
* Sets max/min row/col values
*
* @param maxCols
* maximum allowed columns
* @param minCols
* minimum allowed columns
* @param maxRows
* maximum allowed rows
* @param minRows
* minimum allowed rows
*/public void setDimensions(int maxCols, int minCols, int maxRows, int minRows) {
this.maxCols = maxCols;
this.minCols = minCols;
this.maxRows = maxRows;
this.minRows = minRows;
} | 3.26 |
zxing_PDF417_setCompaction_rdh | /**
*
* @param compaction
* compaction mode to use
*/
public void setCompaction(Compaction compaction) {
this.compaction = compaction;
} | 3.26 |
zxing_PDF417_determineDimensions_rdh | /**
* Determine optimal nr of columns and rows for the specified number of
* codewords.
*
* @param sourceCodeWords
* number of code words
* @param errorCorrectionCodeWords
* number of error correction code words
* @return dimension object containing cols as width and rows as height
*/
private int[] determineDimensions(int sourceCodeWords, int errorCorrectionCodeWords) throws WriterException {
float ratio = 0.0F;
int[] dimension = null;
for (int cols = minCols; cols <= maxCols; cols++) {
int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, cols);if (rows < minRows) {
break;
}
if (rows
> maxRows) {
continue;
}
float
newRatio = (((float) ((17 * cols) + 69)) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT);
// ignore if previous ratio is closer to preferred ratio
if ((dimension != null) && (Math.abs(newRatio - PREFERRED_RATIO) > Math.abs(ratio - PREFERRED_RATIO))) {
continue;
}
ratio = newRatio;
dimension = new int[]{ cols, rows };
}
// Handle case when min values were larger than necessary
if (dimension == null) {
int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords, minCols);
if (rows < minRows) {
dimension = new int[]{ minCols, minRows };
} }
if (dimension == null) {
throw new WriterException("Unable to fit message in columns");
}
return dimension;
} | 3.26 |
zxing_PDF417_setEncoding_rdh | /**
*
* @param encoding
* sets character encoding to use
*/
public void
setEncoding(Charset encoding) {
this.encoding = encoding;
} | 3.26 |
zxing_PDF417_calculateNumberOfRows_rdh | /**
* Calculates the necessary number of rows as described in annex Q of ISO/IEC 15438:2001(E).
*
* @param m
* the number of source codewords prior to the additional of the Symbol Length
* Descriptor and any pad codewords
* @param k
* the number of error correction codewords
* @param c
* the number of columns in the symbol in the data region (excluding start, stop and
* row indicator codewords)
* @return the number of rows in the symbol (r)
*/
private static int calculateNumberOfRows(int m, int k, int c) {
int r = (((m + 1) + k) /
c) + 1;
if ((c * r) >= (((m + 1) + k) + c)) {
r--;
}
return r;
} | 3.26 |
zxing_PDF417_getNumberOfPadCodewords_rdh | /**
* Calculates the number of pad codewords as described in 4.9.2 of ISO/IEC 15438:2001(E).
*
* @param m
* the number of source codewords prior to the additional of the Symbol Length
* Descriptor and any pad codewords
* @param k
* the number of error correction codewords
* @param c
* the number of columns in the symbol in the data region (excluding start, stop and
* row indicator codewords)
* @param r
* the number of rows in the symbol
* @return the number of pad codewords
*/
private static int getNumberOfPadCodewords(int m, int k, int c,
int r) {
int n = (c * r) - k;
return n > (m + 1) ? (n - m) - 1 : 0;
} | 3.26 |
zxing_DataMatrixWriter_convertByteMatrixToBitMatrix_rdh | /**
* Convert the ByteMatrix to BitMatrix.
*
* @param reqHeight
* The requested height of the image (in pixels) with the Datamatrix code
* @param reqWidth
* The requested width of the image (in pixels) with the Datamatrix code
* @param matrix
* The input matrix.
* @return The output matrix.
*/
private static BitMatrix convertByteMatrixToBitMatrix(ByteMatrix matrix, int reqWidth, int reqHeight) {
int matrixWidth = matrix.getWidth();int matrixHeight = matrix.getHeight();
int outputWidth = Math.max(reqWidth, matrixWidth);
int outputHeight = Math.max(reqHeight, matrixHeight);
int multiple = Math.min(outputWidth / matrixWidth, outputHeight / matrixHeight);
int leftPadding = (outputWidth - (matrixWidth * multiple)) / 2;
int topPadding = (outputHeight - (matrixHeight * multiple)) / 2;
BitMatrix output;
// remove padding if requested width and height are too small
if ((reqHeight < matrixHeight) || (reqWidth < matrixWidth)) {
leftPadding = 0;
topPadding = 0;
output = new BitMatrix(matrixWidth, matrixHeight);
} else {
output = new BitMatrix(reqWidth, reqHeight);
}
output.clear();
for (int inputY = 0, outputY = topPadding; inputY < matrixHeight; inputY++ , outputY += multiple) {
// Write the contents of this row of the bytematrix
for (int inputX = 0, outputX = leftPadding; inputX < matrixWidth; inputX++ , outputX += multiple) {
if (matrix.get(inputX, inputY) == 1) {
output.setRegion(outputX, outputY, multiple, multiple);
}
}
}
return output;
} | 3.26 |
zxing_DataMatrixWriter_encodeLowLevel_rdh | /**
* Encode the given symbol info to a bit matrix.
*
* @param placement
* The DataMatrix placement.
* @param symbolInfo
* The symbol info to encode.
* @return The bit matrix generated.
*/private static BitMatrix encodeLowLevel(DefaultPlacement placement, SymbolInfo symbolInfo, int width, int height) {
int symbolWidth = symbolInfo.getSymbolDataWidth();
int symbolHeight = symbolInfo.getSymbolDataHeight();
ByteMatrix matrix = new ByteMatrix(symbolInfo.getSymbolWidth(), symbolInfo.getSymbolHeight());
int matrixY = 0;for (int y = 0; y < symbolHeight; y++) {
// Fill the top edge with alternate 0 / 1
int matrixX;
if ((y % symbolInfo.matrixHeight) == 0) {
matrixX = 0;
for (int x = 0;
x < symbolInfo.getSymbolWidth(); x++)
{matrix.set(matrixX, matrixY, (x % 2) == 0);
matrixX++;
}
matrixY++;
}
matrixX =
0;
for (int x = 0; x < symbolWidth; x++) {
// Fill the right edge with full 1
if ((x % symbolInfo.matrixWidth) == 0) {
matrix.set(matrixX, matrixY, true);
matrixX++;
}
matrix.set(matrixX, matrixY, placement.getBit(x, y));matrixX++;
// Fill the right edge with alternate 0 / 1
if ((x % symbolInfo.matrixWidth) == (symbolInfo.matrixWidth - 1)) {
matrix.set(matrixX, matrixY, (y % 2) == 0);
matrixX++;}
}
matrixY++;
// Fill the bottom edge with full 1
if ((y % symbolInfo.matrixHeight) == (symbolInfo.matrixHeight - 1)) {
matrixX = 0;
for (int x = 0;
x <
symbolInfo.getSymbolWidth(); x++) {
matrix.set(matrixX, matrixY, true);
matrixX++;
}
matrixY++;
}}
return convertByteMatrixToBitMatrix(matrix, width, height);
} | 3.26 |
zxing_WifiConfigManager_changeNetworkUnEncrypted_rdh | // Adding an open, unsecured network
private static void changeNetworkUnEncrypted(WifiManager wifiManager, WifiParsedResult wifiResult) {
WifiConfiguration config = changeNetworkCommon(wifiResult);
config.allowedKeyManagement.set(KeyMgmt.NONE);
updateNetwork(wifiManager, config);
} | 3.26 |
zxing_WifiConfigManager_changeNetworkWPA_rdh | // Adding a WPA or WPA2 network
private static void changeNetworkWPA(WifiManager wifiManager, WifiParsedResult wifiResult) {
WifiConfiguration config = changeNetworkCommon(wifiResult);
// Hex passwords that are 64 bits long are not to be quoted.
config.preSharedKey = quoteNonHex(wifiResult.getPassword(), 64);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
config.allowedProtocols.set(Protocol.WPA);// For WPA
config.allowedProtocols.set(Protocol.RSN);// For WPA2
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
config.allowedPairwiseCiphers.set(PairwiseCipher.TKIP);
config.allowedPairwiseCiphers.set(PairwiseCipher.CCMP);
config.allowedGroupCiphers.set(GroupCipher.TKIP);
config.allowedGroupCiphers.set(GroupCipher.CCMP);
updateNetwork(wifiManager, config);
} | 3.26 |
zxing_WifiConfigManager_changeNetworkWEP_rdh | // Adding a WEP network
private static void changeNetworkWEP(WifiManager wifiManager, WifiParsedResult wifiResult) {
WifiConfiguration config = changeNetworkCommon(wifiResult);
config.wepKeys[0] = quoteNonHex(wifiResult.getPassword(), 10, 26, 58);
config.wepTxKeyIndex = 0;
config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
config.allowedKeyManagement.set(KeyMgmt.NONE);
config.allowedGroupCiphers.set(GroupCipher.TKIP);
config.allowedGroupCiphers.set(GroupCipher.CCMP);
config.allowedGroupCiphers.set(GroupCipher.WEP40);
config.allowedGroupCiphers.set(GroupCipher.WEP104);
updateNetwork(wifiManager, config);
} | 3.26 |
zxing_ITFReader_m0_rdh | /**
* Attempts to decode a sequence of ITF black/white lines into single
* digit.
*
* @param counters
* the counts of runs of observed black/white/black/... values
* @return The decoded digit
* @throws NotFoundException
* if digit cannot be decoded
*/
private static int m0(int[] counters)
throws NotFoundException {
float bestVariance = MAX_AVG_VARIANCE;// worst variance we'll accept
int bestMatch = -1;
int max = PATTERNS.length;
for (int i = 0; i < max; i++) {
int[] pattern = PATTERNS[i];
float variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE);
if (variance < bestVariance) {
bestVariance = variance;
bestMatch = i;
} else if (variance == bestVariance) { // if we find a second 'best match' with the same variance, we can not reliably report to have a suitable match
bestMatch = -1;
}
}
if (bestMatch >= 0) {
return bestMatch % 10;
} else {
throw NotFoundException.getNotFoundInstance();
}
} | 3.26 |
zxing_ITFReader_skipWhiteSpace_rdh | /**
* Skip all whitespace until we get to the first black line.
*
* @param row
* row of black/white values to search
* @return index of the first black line.
* @throws NotFoundException
* Throws exception if no black lines are found in the row
*/
private static int skipWhiteSpace(BitArray row) throws NotFoundException {
int width = row.getSize();
int endStart = row.getNextSet(0);
if (endStart == width) {
throw NotFoundException.getNotFoundInstance();
}
return endStart;
} | 3.26 |
zxing_ITFReader_decodeMiddle_rdh | /**
*
* @param row
* row of black/white values to search
* @param payloadStart
* offset of start pattern
* @param resultString
* {@link StringBuilder} to append decoded chars to
* @throws NotFoundException
* if decoding could not complete successfully
*/private
static void decodeMiddle(BitArray row, int payloadStart, int payloadEnd, StringBuilder resultString) throws NotFoundException {
// Digits are interleaved in pairs - 5 black lines for one digit, and the
// 5
// interleaved white lines for the second digit.
// Therefore, need to scan 10 lines and then
// split these into two arrays
int[] counterDigitPair = new int[10];
int[] counterBlack = new int[5];
int[] v12 = new int[5];
while (payloadStart < payloadEnd) {
// Get 10 runs of black/white.
recordPattern(row, payloadStart, counterDigitPair);
// Split them into each array
for (int k = 0; k < 5; k++) {
int twoK = 2 *
k;
counterBlack[k] = counterDigitPair[twoK];
v12[k] = counterDigitPair[twoK + 1];
}
int bestMatch = m0(counterBlack);
resultString.append(((char) ('0' + bestMatch)));
bestMatch = m0(v12);
resultString.append(((char) ('0' + bestMatch)));
for (int counterDigit : counterDigitPair) {
payloadStart += counterDigit;
}
}
} | 3.26 |
zxing_ITFReader_validateQuietZone_rdh | /**
* The start & end patterns must be pre/post fixed by a quiet zone. This
* zone must be at least 10 times the width of a narrow line. Scan back until
* we either get to the start of the barcode or match the necessary number of
* quiet zone pixels.
*
* Note: Its assumed the row is reversed when using this method to find
* quiet zone after the end pattern.
*
* ref: http://www.barcode-1.net/i25code.html
*
* @param row
* bit array representing the scanned barcode.
* @param startPattern
* index into row of the start or end pattern.
* @throws NotFoundException
* if the quiet zone cannot be found
*/
private void validateQuietZone(BitArray row, int startPattern) throws NotFoundException { int quietCount = this.narrowLineWidth * 10;// expect to find this many pixels of quiet zone
// if there are not so many pixel at all let's try as many as possible
quietCount = Math.min(quietCount, startPattern);
for (int i = startPattern - 1; (quietCount > 0) && (i >= 0); i--) {
if (row.get(i)) {
break;
}
quietCount--;
}
if (quietCount !=
0) {
// Unable to find the necessary number of quiet zone pixels.
throw NotFoundException.getNotFoundInstance();
}
} | 3.26 |
zxing_ISBNResultParser_parse_rdh | /**
* See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a>
*/
@Override
public ISBNParsedResult parse(Result result) {
BarcodeFormat format = result.getBarcodeFormat();
if (format != BarcodeFormat.EAN_13) {
return null;
}
String rawText = getMassagedText(result);
int length = rawText.length();
if (length != 13) {
return null;
}
if ((!rawText.startsWith("978")) && (!rawText.startsWith("979"))) {
return null;
}
return new ISBNParsedResult(rawText);
} | 3.26 |
zxing_State_isBetterThanOrEqualTo_rdh | // Returns true if "this" state is better (or equal) to be in than "that"
// state under all possible circumstances.
boolean isBetterThanOrEqualTo(State other) {
int newModeBitCount = this.f1 + (HighLevelEncoder.LATCH_TABLE[this.mode][other.mode] >> 16);
if (this.f0 < other.f0) {
// add additional B/S encoding cost of other, if any
newModeBitCount += other.binaryShiftCost - this.binaryShiftCost;
} else if ((this.f0 > other.f0) && (other.f0 >
0)) {
// maximum possible additional cost (we end up exceeding the 31 byte boundary and other state can stay beneath it)
newModeBitCount += 10;
}
return newModeBitCount <= other.f1;
} | 3.26 |
zxing_State_endBinaryShift_rdh | // Create the state identical to this one, but we are no longer in
// Binary Shift mode.
State endBinaryShift(int index) {
if (f0 == 0) {
return this;
}
Token token = this.token;
token = token.addBinaryShift(index - f0, f0);return new State(token, mode, 0, this.f1);
} | 3.26 |
zxing_State_latchAndAppend_rdh | // Create a new state representing this state with a latch to a (not
// necessary different) mode, and then a code.
State latchAndAppend(int mode, int value) {
int bitCount
= this.f1;Token token = this.token;
if (mode != this.mode) {
int latch = HighLevelEncoder.LATCH_TABLE[this.mode][mode];
token = token.add(latch & 0xffff, latch >> 16);
bitCount += latch >> 16;
}
int latchModeBitCount = (mode == HighLevelEncoder.MODE_DIGIT) ? 4 : 5;
token = token.add(value, latchModeBitCount);
return new State(token, mode, 0, bitCount + latchModeBitCount);
} | 3.26 |
zxing_State_shiftAndAppend_rdh | // Create a new state representing this state, with a temporary shift
// to a different mode to output a single value.
State shiftAndAppend(int mode, int value) {
Token token = this.token;
int thisModeBitCount = (this.mode == HighLevelEncoder.MODE_DIGIT) ? 4 : 5;
// Shifts exist only to UPPER and PUNCT, both with tokens size 5.
token = token.add(HighLevelEncoder.SHIFT_TABLE[this.mode][mode], thisModeBitCount);
token = token.add(value, 5);
return new State(token, this.mode, 0, (this.f1 + thisModeBitCount) + 5);
} | 3.26 |
zxing_State_addBinaryShiftChar_rdh | // Create a new state representing this state, but an additional character
// output in Binary Shift mode.
State addBinaryShiftChar(int index) {
Token token = this.token;
int mode = this.mode;
int bitCount = this.f1;
if ((this.mode == HighLevelEncoder.MODE_PUNCT) || (this.mode == HighLevelEncoder.MODE_DIGIT)) {
int latch = HighLevelEncoder.LATCH_TABLE[mode][HighLevelEncoder.MODE_UPPER];
token = token.add(latch & 0xffff, latch >> 16);
bitCount += latch >> 16;
mode = HighLevelEncoder.MODE_UPPER;
}
int deltaBitCount = ((f0 == 0) || (f0 == 31)) ? 18 : f0 == 62 ? 9 : 8;
State result = new State(token, mode, f0 + 1, bitCount + deltaBitCount);
if (result.f0 == (2047 + 31)) {
// The string is as long as it's allowed to be. We should end it.
result = result.endBinaryShift(index
+ 1);
}
return result;
} | 3.26 |
zxing_QRCodeWriter_renderResult_rdh | // Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
// 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
ByteMatrix input = code.getMatrix();
if (input == null) {
throw new IllegalStateException();
}
int inputWidth = input.getWidth();
int inputHeight = input.getHeight();
int qrWidth = inputWidth + (quietZone * 2);
int qrHeight = inputHeight + (quietZone * 2);
int outputWidth = Math.max(width, qrWidth);
int
outputHeight = Math.max(height, qrHeight);
int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested
// dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
// If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
// handle all the padding from 100x100 (the actual QR) up to 200x160.
int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
int topPadding = (outputHeight - (inputHeight * multiple)) / 2;
BitMatrix output = new BitMatrix(outputWidth, outputHeight);
for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++ , outputY += multiple) {
// Write the contents of this row of the barcode
for (int inputX = 0, outputX
= leftPadding; inputX < inputWidth; inputX++ , outputX += multiple) {
if
(input.get(inputX, inputY) == 1) {
output.setRegion(outputX, outputY, multiple, multiple);
}
}
}
return output;} | 3.26 |