Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zxing-cpp/core/src/BinaryBitmap.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * Copyright 2016 Nu-book Inc. | |
| 3 * Copyright 2016 ZXing authors | |
| 4 * Copyright 2021 Axel Waggershauser | |
| 5 */ | |
| 6 // SPDX-License-Identifier: Apache-2.0 | |
| 7 | |
| 8 #pragma once | |
| 9 | |
| 10 #include "ImageView.h" | |
| 11 | |
| 12 #include <cstdint> | |
| 13 #include <memory> | |
| 14 #include <vector> | |
| 15 | |
| 16 namespace ZXing { | |
| 17 | |
| 18 class BitMatrix; | |
| 19 | |
| 20 using PatternRow = std::vector<uint16_t>; | |
| 21 | |
| 22 /** | |
| 23 * This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects | |
| 24 * accept a BinaryBitmap and attempt to decode it. | |
| 25 */ | |
| 26 class BinaryBitmap | |
| 27 { | |
| 28 struct Cache; | |
| 29 std::unique_ptr<Cache> _cache; | |
| 30 bool _inverted = false; | |
| 31 bool _closed = false; | |
| 32 | |
| 33 protected: | |
| 34 const ImageView _buffer; | |
| 35 | |
| 36 /** | |
| 37 * Converts a 2D array of luminance data to 1 bit (true means black). | |
| 38 * | |
| 39 * @return The 2D array of bits for the image, nullptr on error. | |
| 40 */ | |
| 41 virtual std::shared_ptr<const BitMatrix> getBlackMatrix() const = 0; | |
| 42 | |
| 43 BitMatrix binarize(const uint8_t threshold) const; | |
| 44 | |
| 45 public: | |
| 46 BinaryBitmap(const ImageView& buffer); | |
| 47 virtual ~BinaryBitmap(); | |
| 48 | |
| 49 int width() const { return _buffer.width(); } | |
| 50 int height() const { return _buffer.height(); } | |
| 51 | |
| 52 /** | |
| 53 * Converts one row of luminance data to a vector of ints denoting the widths of the bars and spaces. | |
| 54 */ | |
| 55 virtual bool getPatternRow(int row, int rotation, PatternRow& res) const = 0; | |
| 56 | |
| 57 const BitMatrix* getBitMatrix() const; | |
| 58 | |
| 59 void invert(); | |
| 60 bool inverted() const { return _inverted; } | |
| 61 | |
| 62 void close(); | |
| 63 bool closed() const { return _closed; } | |
| 64 }; | |
| 65 | |
| 66 } // ZXing |
