| 99 | }; |
| 100 | |
| 101 | ImageView SetupLumImageView(ImageView iv, LumImage& lum, const DecodeHints& hints) |
| 102 | { |
| 103 | if (iv.format() == ImageFormat::None) |
| 104 | throw std::invalid_argument("Invalid image format"); |
| 105 | |
| 106 | if (hints.binarizer() == Binarizer::GlobalHistogram || hints.binarizer() == Binarizer::LocalAverage) { |
| 107 | if (iv.format() != ImageFormat::Lum) { |
| 108 | lum = ExtractLum(iv, [r = RedIndex(iv.format()), g = GreenIndex(iv.format()), b = BlueIndex(iv.format())]( |
| 109 | const uint8_t* src) { return RGBToLum(src[r], src[g], src[b]); }); |
| 110 | } else if (iv.pixStride() != 1) { |
| 111 | // GlobalHistogram and LocalAverage need dense line memory layout |
| 112 | lum = ExtractLum(iv, [](const uint8_t* src) { return *src; }); |
| 113 | } |
| 114 | if (lum.data()) |
| 115 | return lum; |
| 116 | } |
| 117 | return iv; |
| 118 | } |
| 119 | |
| 120 | std::unique_ptr<BinaryBitmap> CreateBitmap(ZXing::Binarizer binarizer, const ImageView& iv) |
| 121 | { |
no test coverage detected