- try {
- // Look for a barcode
- Ref<Result> result = decodeRow(rowNumber, row);
- // We found our barcode
- if (attempt == 1) {
- // // But it was upside down, so note that
- // result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(180));
- // // And remember to flip the result points horizontally.
- // ResultPoint[] points = result.getResultPoints();
- // points[0] = new ResultPoint(width - points[0].getX() - 1, points[0].getY());
- // points[1] = new ResultPoint(width - points[1].getX() - 1, points[1].getY());
- }
- return result;
- } catch (ReaderException re) {
- // continue -- just couldn't decode this row
- }
+
+ // Look for a barcode
+ Ref<Result> result = decodeRow(rowNumber, row);
+ // We found our barcode
+ if (!result.empty()) {
+ // // But it was upside down, so note that
+ // result.putMetadata(ResultMetadataType.ORIENTATION, new Integer(180));
+ // // And remember to flip the result points horizontally.
+ std::vector<Ref<ResultPoint> > points(result->getResultPoints());
+ // if there's exactly two points (which there should be), flip the x coordinate
+ // if there's not exactly 2, I don't know what do do with it
+ if (points.size() == 2) {
+ Ref<ResultPoint> pointZero(new OneDResultPoint(width - points[0]->getX() - 1,
+ points[0]->getY()));
+ points[0] = pointZero;
+
+ Ref<ResultPoint> pointOne(new OneDResultPoint(width - points[1]->getX() - 1,
+ points[1]->getY()));
+ points[1] = pointOne;
+
+ result.reset(new Result(result->getText(), result->getRawBytes(), points,
+ result->getBarcodeFormat()));
+ }
+ return result;
+ }