This repository has been archived by the owner on Sep 4, 2019. It is now read-only.
forked from zxing/zxing
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PDF417 encoder, modified from Barcode4J
git-svn-id: http://zxing.googlecode.com/svn/trunk@1897 59b500cc-1b3d-0410-9834-0bbf25fbcc57
- Loading branch information
srowen
committed
Aug 29, 2011
1 parent
434c473
commit 4ea0281
Showing
9 changed files
with
1,818 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-------------------------------------------------------------------------------- | ||
NOTICES FOR BARCODE4J | ||
-------------------------------------------------------------------------------- | ||
|
||
Barcode4J | ||
Copyright 2002-2010 Jeremias Märki | ||
Copyright 2005-2006 Dietmar Bürkle | ||
|
||
Portions of this software were contributed under section 5 of the | ||
Apache License. Contributors are listed under: | ||
http://barcode4j.sourceforge.net/contributors.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
core/src/com/google/zxing/pdf417/encoder/BarcodeMatrix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2011 ZXing authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.zxing.pdf417.encoder; | ||
|
||
/** | ||
* Holds all of the information for a barcode in a format where it can be easily accessable | ||
* | ||
* @author Jacob Haynes | ||
*/ | ||
final class BarcodeMatrix { | ||
|
||
private final BarcodeRow[] matrix; | ||
private int currentRow; | ||
private final int height; | ||
private final int width; | ||
|
||
/** | ||
* @param height the height of the matrix (Rows) | ||
* @param width the width of the matrix (Cols) | ||
*/ | ||
BarcodeMatrix(int height, int width) { | ||
matrix = new BarcodeRow[height + 2]; | ||
//Initializes the array to the correct width | ||
for (int i = 0, matrixLength = matrix.length; i < matrixLength; i++) { | ||
matrix[i] = new BarcodeRow((width + 4) * 17 + 1); | ||
} | ||
this.width = width * 17; | ||
this.height = height + 2; | ||
this.currentRow = 0; | ||
} | ||
|
||
void set(int x, int y, byte value) { | ||
matrix[y].set(x, value); | ||
} | ||
|
||
void setMatrix(int x, int y, boolean black) { | ||
set(x, y, (byte) (black ? 1 : 0)); | ||
} | ||
|
||
void startRow() { | ||
++currentRow; | ||
} | ||
|
||
BarcodeRow getCurrentRow() { | ||
return matrix[currentRow]; | ||
} | ||
|
||
byte[][] getMatrix() { | ||
return getScaledMatrix(1, 1); | ||
} | ||
|
||
byte[][] getScaledMatrix(int Scale) { | ||
return getScaledMatrix(Scale, Scale); | ||
} | ||
|
||
byte[][] getScaledMatrix(int xScale, int yScale) { | ||
byte[][] matrixOut = new byte[height * yScale][width * xScale]; | ||
int yMax = height * yScale; | ||
for (int ii = 0; ii < yMax; ii++) { | ||
matrixOut[yMax - ii - 1] = matrix[ii / yScale].getScaledRow(xScale); | ||
} | ||
return matrixOut; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright 2011 ZXing authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.zxing.pdf417.encoder; | ||
|
||
/** | ||
* @author Jacob Haynes | ||
*/ | ||
final class BarcodeRow { | ||
|
||
private final byte[] row; | ||
//A tacker for position in the bar | ||
private int currentLocation; | ||
|
||
/** | ||
* Creates a Barcode row of the width | ||
* | ||
* @param width | ||
*/ | ||
BarcodeRow(int width) { | ||
this.row = new byte[width]; | ||
currentLocation = 0; | ||
} | ||
|
||
/** | ||
* Sets a specific location in the bar | ||
* | ||
* @param x The location in the bar | ||
* @param value Black if true, white if false; | ||
*/ | ||
void set(int x, byte value) { | ||
row[x] = value; | ||
} | ||
|
||
/** | ||
* Sets a specific location in the bar | ||
* | ||
* @param x The location in the bar | ||
* @param black Black if true, white if false; | ||
*/ | ||
void set(int x, boolean black) { | ||
row[x] = (byte) (black ? 1 : 0); | ||
} | ||
|
||
/** | ||
* @param black A boolean which is true if the bar black false if it is white | ||
* @param width How many spots wide the bar is. | ||
*/ | ||
void addBar(boolean black, int width) { | ||
for (int ii = 0; ii < width; ii++) { | ||
set(currentLocation++, black); | ||
} | ||
} | ||
|
||
byte[] getRow() { | ||
return row; | ||
} | ||
|
||
/** | ||
* This function scales the row | ||
* | ||
* @param scale How much you want the image to be scaled, must be greater than or equal to 1. | ||
* @return the scaled row | ||
*/ | ||
byte[] getScaledRow(int scale) { | ||
byte[] output = new byte[row.length * scale]; | ||
for (int ii = 0; ii < row.length * scale; ii++) { | ||
output[ii] = row[ii / scale]; | ||
} | ||
return output; | ||
} | ||
} |
Oops, something went wrong.