Beispiel #1
0
Ref<Result> PDF417Reader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
  Ref<DecoderResult> decoderResult;
  /* 2012-05-30 hfn C++ DecodeHintType does not yet know a type "PURE_BARCODE", */
  /* therefore skip this for now, todo: may be add this type later */
  /*
    if (!hints.isEmpty() && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
    BitMatrix bits = extractPureBits(image.getBlackMatrix());
    decoderResult = decoder.decode(bits);
    points = NO_POINTS;
    } else {
  */
  Detector detector(image);
  Ref<DetectorResult> detectorResult = detector.detect(hints); /* 2012-09-17 hints ("try_harder") */
  ArrayRef< Ref<ResultPoint> > points(detectorResult->getPoints());
  
  if (!hints.isEmpty()) {
    Ref<ResultPointCallback> rpcb = hints.getResultPointCallback();
    /* .get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); */
    if (rpcb != NULL) {
      for (int i = 0; i < points->size(); i++) {
        rpcb->foundPossibleResultPoint(*points[i]);
      }
    }
  }
  decoderResult = decoder.decode(detectorResult->getBits(),hints);
  /*
    }
  */
  Ref<Result> r(new Result(decoderResult->getText(), decoderResult->getRawBytes(), points,
                           BarcodeFormat::PDF_417));
  return r;
}
Ref<Result> PDF417Reader::decode(Ref<BinaryBitmap> image, DecodeHints hints)
{
    Ref<DecoderResult> decoderResult;
	/* 2012-05-30 hfn C++ DecodeHintType does not yet know a type "PURE_BARCODE", */
	/* therefore skip this for now, todo: may be add this type later */
		/*
		if (!hints.isEmpty() && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
		  BitMatrix bits = extractPureBits(image.getBlackMatrix());
		  decoderResult = decoder.decode(bits);
		  points = NO_POINTS;
		} else {
		*/
	Detector detector(image);
	Ref<DetectorResult> detectorResult = detector.detect();
#if (defined _WIN32 && defined DEBUG)
	{
		WCHAR sz[256];
		wsprintf(sz,L"PDF417Reader::decode: detected, %d\n",detectorResult->getPoints()[0]);
		OutputDebugString(sz);
	}
#endif
	ArrayRef< Ref<ResultPoint> >  points(detectorResult->getPoints());

	if (!hints.isEmpty()) {
        Ref<ResultPointCallback> rpcb = hints.getResultPointCallback();
            /* .get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); */
        if (rpcb != NULL) {
          for (int i = 0; i < (int)points->size(); i++) {
            rpcb->foundPossibleResultPoint(*(points[i]));
          }
        }
      }
	decoderResult = decoder_.decode(detectorResult->getBits());
		/*
		}
		*/
	Ref<Result> r(new Result(decoderResult->getText(), decoderResult->getRawBytes(), points,
                             BarcodeFormat::PDF_417));
#if (defined _WIN32 && defined(DEBUG))
	  {
		  WCHAR sz[1024];
		  wsprintf(sz,L"PDF417Reader::decode: \"%S\"\n",decoderResult->getText().object_->getText().c_str());
		  OutputDebugString(sz);
	  }
#endif
    fprintf( stdout, "PDF417Reader::decode: \"%s\"\n", decoderResult->getText().object_->getText().c_str());
    return r;
}