- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
67 lines
1.4 KiB
C++
67 lines
1.4 KiB
C++
/*
|
|
* Copyright 2016 Nu-book Inc.
|
|
* Copyright 2016 ZXing authors
|
|
* Copyright 2021 Axel Waggershauser
|
|
*/
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#pragma once
|
|
|
|
#include "ImageView.h"
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace ZXing {
|
|
|
|
class BitMatrix;
|
|
|
|
using PatternRow = std::vector<uint16_t>;
|
|
|
|
/**
|
|
* This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
|
|
* accept a BinaryBitmap and attempt to decode it.
|
|
*/
|
|
class BinaryBitmap
|
|
{
|
|
struct Cache;
|
|
std::unique_ptr<Cache> _cache;
|
|
bool _inverted = false;
|
|
bool _closed = false;
|
|
|
|
protected:
|
|
const ImageView _buffer;
|
|
|
|
/**
|
|
* Converts a 2D array of luminance data to 1 bit (true means black).
|
|
*
|
|
* @return The 2D array of bits for the image, nullptr on error.
|
|
*/
|
|
virtual std::shared_ptr<const BitMatrix> getBlackMatrix() const = 0;
|
|
|
|
BitMatrix binarize(uint8_t threshold) const;
|
|
|
|
public:
|
|
BinaryBitmap(const ImageView& buffer);
|
|
virtual ~BinaryBitmap();
|
|
|
|
int width() const { return _buffer.width(); }
|
|
int height() const { return _buffer.height(); }
|
|
|
|
/**
|
|
* Converts one row of luminance data to a vector of ints denoting the widths of the bars and spaces.
|
|
*/
|
|
virtual bool getPatternRow(int row, int rotation, PatternRow& res) const = 0;
|
|
|
|
const BitMatrix* getBitMatrix(bool transposed = false) const;
|
|
|
|
void invert();
|
|
bool inverted() const { return _inverted; }
|
|
|
|
void close();
|
|
bool closed() const { return _closed; }
|
|
};
|
|
|
|
} // ZXing
|