MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / CheckPixel

Method CheckPixel

src/Frame.cpp:421–440  ·  view source on GitHub ↗

Check a specific pixel color value (returns True/False)

Source from the content-addressed store, hash-verified

419
420// Check a specific pixel color value (returns True/False)
421bool Frame::CheckPixel(int row, int col, int red, int green, int blue, int alpha, int threshold) {
422 int col_pos = col * 4; // Find column array position
423 if (!image || row < 0 || row >= (height - 1) ||
424 col_pos < 0 || col_pos >= (width - 1) ) {
425 // invalid row / col
426 return false;
427 }
428 // Check pixel color
429 const unsigned char* pixels = GetPixels(row);
430 if (pixels[col_pos + 0] >= (red - threshold) && pixels[col_pos + 0] <= (red + threshold) &&
431 pixels[col_pos + 1] >= (green - threshold) && pixels[col_pos + 1] <= (green + threshold) &&
432 pixels[col_pos + 2] >= (blue - threshold) && pixels[col_pos + 2] <= (blue + threshold) &&
433 pixels[col_pos + 3] >= (alpha - threshold) && pixels[col_pos + 3] <= (alpha + threshold)) {
434 // Pixel color matches successfully
435 return true;
436 } else {
437 // Pixel color does not match
438 return false;
439 }
440}
441
442// Set Pixel Aspect Ratio
443void Frame::SetPixelRatio(int num, int den)

Callers 1

FFmpegReader.cppFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected