MCPcopy Create free account
hub / github.com/IENT/YUView / getPixelValues

Method getPixelValues

YUViewLib/src/video/FrameHandler.cpp:448–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448QStringPairList
449FrameHandler::getPixelValues(const QPoint &pixelPos, int, FrameHandler *item2, const int)
450{
451 auto width = (item2) ? std::min(frameSize.width, item2->frameSize.width) : frameSize.width;
452 auto height = (item2) ? std::min(frameSize.height, item2->frameSize.height) : frameSize.height;
453
454 if (pixelPos.x() < 0 || pixelPos.x() >= int(width) || pixelPos.y() < 0 ||
455 pixelPos.y() >= int(height))
456 return {};
457
458 // Is the format (of both items) valid?
459 if (!isFormatValid())
460 return {};
461 if (item2 && !item2->isFormatValid())
462 return {};
463
464 // Get the RGB values from the image
465 QStringPairList values;
466
467 if (item2)
468 {
469 // There is a second item. Return the difference values.
470 auto pixel1 = getPixelVal(pixelPos);
471 auto pixel2 = item2->getPixelVal(pixelPos);
472
473 int r = int(qRed(pixel1)) - int(qRed(pixel2));
474 int g = int(qGreen(pixel1)) - int(qGreen(pixel2));
475 int b = int(qBlue(pixel1)) - int(qBlue(pixel2));
476
477 values.append(QStringPair("R", QString::number(r)));
478 values.append(QStringPair("G", QString::number(g)));
479 values.append(QStringPair("B", QString::number(b)));
480 }
481 else
482 {
483 // No second item. Return the RGB values of this item.
484 auto val = getPixelVal(pixelPos);
485 values.append(QStringPair("R", QString::number(qRed(val))));
486 values.append(QStringPair("G", QString::number(qGreen(val))));
487 values.append(QStringPair("B", QString::number(qBlue(val))));
488 }
489
490 return values;
491}
492
493bool FrameHandler::setFormatFromString(QString format)
494{

Callers 1

paintZoomBoxMethod · 0.45

Calls 3

appendMethod · 0.80
isFormatValidMethod · 0.45
getPixelValMethod · 0.45

Tested by

no test coverage detected