use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.
the class JMFCanvas method drawPolygon.
public void drawPolygon(Point[] points, int color) {
Graphics2D g2d = image.createGraphics();
g2d.setColor(new Color(color));
int numPoints = points.length;
int[] polygonX = new int[numPoints];
int[] polygonY = new int[numPoints];
for (int i = 0; i < numPoints; i++) {
polygonX[i] = points[i].getX();
polygonY[i] = points[i].getY();
}
g2d.drawPolygon(polygonX, polygonY, numPoints);
repaint();
}
use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.
the class JMFCanvas method drawCross.
public void drawCross(Point point, int color) {
int x = point.getX();
int y = point.getY();
Line[] lines = { new Line(x - 5, y - 1, x + 5, y - 1), new Line(x - 1, y - 5, x - 1, y + 5), new Line(x - 5, y + 1, x + 5, y + 1), new Line(x + 1, y - 5, x + 1, y + 5), new Line(x - 5, y, x + 5, y), new Line(x, y - 5, x, y + 5) };
drawLines(lines, color);
}
use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.
the class JMFCanvas method drawPoints.
public void drawPoints(Point[] points, int color) {
Graphics2D g2d = image.createGraphics();
g2d.setColor(new Color(color));
for (int i = 0; i < points.length; i++) g2d.drawLine(points[i].getX(), points[i].getY(), points[i].getX(), points[i].getY());
repaint();
}
use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.
the class QRCodeDecoder method decode.
public byte[] decode(QRCodeImage qrCodeImage) throws DecodingFailedException {
Point[] adjusts = getAdjustPoints();
Vector results = new Vector();
numTryDecode = 0;
while (numTryDecode < adjusts.length) {
try {
DecodeResult result = decode(qrCodeImage, adjusts[numTryDecode]);
if (result.isCorrectionSucceeded()) {
return result.getDecodedBytes();
} else {
results.addElement(result);
canvas.println("Decoding succeeded but could not correct");
canvas.println("all errors. Retrying..");
}
} catch (DecodingFailedException dfe) {
if (dfe.getMessage().indexOf("Finder Pattern") >= 0)
throw dfe;
} finally {
numTryDecode += 1;
}
}
if (results.size() == 0)
throw new DecodingFailedException("Give up decoding");
int minErrorIndex = -1;
int minError = Integer.MAX_VALUE;
for (int i = 0; i < results.size(); i++) {
DecodeResult result = (DecodeResult) results.elementAt(i);
if (result.getNumCorrectuionFailures() < minError) {
minError = result.getNumCorrectuionFailures();
minErrorIndex = i;
}
}
canvas.println("All trials need for correct error");
canvas.println("Reporting #" + (minErrorIndex) + " that,");
canvas.println("corrected minimum errors (" + minError + ")");
canvas.println("Decoding finished.");
return ((DecodeResult) results.elementAt(minErrorIndex)).getDecodedBytes();
}
use of jp.sourceforge.qrcode.geom.Point in project qrcode by yanbe.
the class J2SEDebugCanvas method drawCross.
public void drawCross(Point point, int color) {
int x = point.getX();
int y = point.getY();
Line[] lines = { new Line(x - 5, y, x + 5, y), new Line(x, y - 5, x, y + 5) };
drawLines(lines, color);
}
Aggregations