ftylitak / qzxing

Qt/QML wrapper library for the ZXing library. 1D/2D barcode image processing library
Apache License 2.0
621 stars 340 forks source link

UPC-A addon decoding issue #216

Open ov opened 2 years ago

ov commented 2 years ago

Hi, it looks like UPC-A addons are missed by decoder when EAN-13 reader's results are converted to UPCA. The code in MultiFormatUPCEANReader.cpp should look like this:

    if (ean13MayBeUPCA && canReturnUPCA)
    {
      // Transfer the metdata across
      QSharedPointer<Result> resultUPCA(new Result(result->getText()->substring(1),
                                        result->getRawBytes(),
                                        result->getResultPoints(),
                                        BarcodeFormat::UPC_A,
                                        {}, // default charset
                                        result->getMetadata())); // metadata with addon details
      // needs java metadata stuff
      return resultUPCA;
    }

See the two extra parameters after the BarcodeFormat::UPC_A.

Maybe something like this would also work, so we don't have to touch the charset parameter in the ctor, but I haven't tried it:

resultUPCA->getMetadata() = result->getMetadata();