Skip to content

Commit 438b2c3

Browse files
authored
Update Frame.cpp
1 parent 2be5e5e commit 438b2c3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Frame.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ const unsigned char* Frame::GetPixels(int row)
481481
}
482482

483483
// Check a specific pixel color value (returns True/False)
484-
bool Frame::CheckPixel(int row, int col, int red, int green, int blue, int alpha) {
484+
bool Frame::CheckPixel(int row, int col, int red, int green, int blue, int alpha, int threshold) {
485485
int col_pos = col * 4; // Find column array position
486486
if (!image || row < 0 || row >= (height - 1) ||
487487
col_pos < 0 || col_pos >= (width - 1) ) {
@@ -490,10 +490,10 @@ bool Frame::CheckPixel(int row, int col, int red, int green, int blue, int alpha
490490
}
491491
// Check pixel color
492492
const unsigned char* pixels = GetPixels(row);
493-
if (pixels[col_pos + 0] == red &&
494-
pixels[col_pos + 1] == green &&
495-
pixels[col_pos + 2] == blue &&
496-
pixels[col_pos + 3] == alpha) {
493+
if (pixels[col_pos + 0] >= (red - threshold) && pixels[col_pos + 0] <= (red + threshold) &&
494+
pixels[col_pos + 0] >= (green - threshold) && pixels[col_pos + 0] <= (green + threshold) &&
495+
pixels[col_pos + 0] >= (blue - threshold) && pixels[col_pos + 0] <= (blue + threshold) &&
496+
pixels[col_pos + 0] >= (alpha - threshold) && pixels[col_pos + 0] <= (alpha + threshold)) {
497497
// Pixel color matches successfully
498498
return true;
499499
} else {

0 commit comments

Comments
 (0)