Fix cppcheck errors.

This commit is contained in:
Jonas Diemer 2026-01-10 14:26:04 +01:00
parent 904af4cdf3
commit 93a5c41cf2

View File

@ -15,7 +15,7 @@ int adjustPixel(int gray);
// Less error buildup = fewer artifacts than Floyd-Steinberg // Less error buildup = fewer artifacts than Floyd-Steinberg
class AtkinsonDitherer { class AtkinsonDitherer {
public: public:
AtkinsonDitherer(int width) : width(width) { explicit AtkinsonDitherer(int width) : width(width) {
errorRow0 = new int16_t[width + 4](); // Current row errorRow0 = new int16_t[width + 4](); // Current row
errorRow1 = new int16_t[width + 4](); // Next row errorRow1 = new int16_t[width + 4](); // Next row
errorRow2 = new int16_t[width + 4](); // Row after next errorRow2 = new int16_t[width + 4](); // Row after next
@ -26,6 +26,11 @@ class AtkinsonDitherer {
delete[] errorRow1; delete[] errorRow1;
delete[] errorRow2; delete[] errorRow2;
} }
// **1. EXPLICITLY DELETE THE COPY CONSTRUCTOR**
AtkinsonDitherer(const AtkinsonDitherer& other) = delete;
// **2. EXPLICITLY DELETE THE COPY ASSIGNMENT OPERATOR**
AtkinsonDitherer& operator=(const AtkinsonDitherer& other) = delete;
uint8_t processPixel(int gray, int x) { uint8_t processPixel(int gray, int x) {
// Add accumulated error // Add accumulated error
@ -111,7 +116,7 @@ class AtkinsonDitherer {
// 7/16 X // 7/16 X
class FloydSteinbergDitherer { class FloydSteinbergDitherer {
public: public:
FloydSteinbergDitherer(int width) : width(width), rowCount(0) { explicit FloydSteinbergDitherer(int width) : width(width), rowCount(0) {
errorCurRow = new int16_t[width + 2](); // +2 for boundary handling errorCurRow = new int16_t[width + 2](); // +2 for boundary handling
errorNextRow = new int16_t[width + 2](); errorNextRow = new int16_t[width + 2]();
} }
@ -121,6 +126,12 @@ class FloydSteinbergDitherer {
delete[] errorNextRow; delete[] errorNextRow;
} }
// **1. EXPLICITLY DELETE THE COPY CONSTRUCTOR**
FloydSteinbergDitherer(const FloydSteinbergDitherer& other) = delete;
// **2. EXPLICITLY DELETE THE COPY ASSIGNMENT OPERATOR**
FloydSteinbergDitherer& operator=(const FloydSteinbergDitherer& other) = delete;
// Process a single pixel and return quantized 2-bit value // Process a single pixel and return quantized 2-bit value
// x is the logical x position (0 to width-1), direction handled internally // x is the logical x position (0 to width-1), direction handled internally
uint8_t processPixel(int gray, int x, bool reverseDirection) { uint8_t processPixel(int gray, int x, bool reverseDirection) {