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

Method drawPixelValues

YUViewLib/src/video/FrameHandler.cpp:280–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void FrameHandler::drawPixelValues(QPainter *painter,
281 const int,
282 const QRect & videoRect,
283 const double zoomFactor,
284 FrameHandler *item2,
285 const bool markDifference,
286 const int)
287{
288 // Draw the pixel values onto the pixels
289
290 // TODO: Does this also work for sequences with width/height non divisible by 2? Not sure about
291 // that.
292
293 // First determine which pixels from this item are actually visible, because we only have to draw
294 // the pixel values of the pixels that are actually visible
295 auto viewport = painter->viewport();
296 auto worldTransform = painter->worldTransform();
297
298 int xMin = (videoRect.width() / 2 - worldTransform.dx()) / zoomFactor;
299 int yMin = (videoRect.height() / 2 - worldTransform.dy()) / zoomFactor;
300 int xMax = (videoRect.width() / 2 - (worldTransform.dx() - viewport.width())) / zoomFactor;
301 int yMax = (videoRect.height() / 2 - (worldTransform.dy() - viewport.height())) / zoomFactor;
302
303 // functions::clip the min/max visible pixel values to the size of the item (no pixels outside of
304 // the item have to be labeled)
305 xMin = functions::clip(xMin, 0, int(frameSize.width) - 1);
306 yMin = functions::clip(yMin, 0, int(frameSize.height) - 1);
307 xMax = functions::clip(xMax, 0, int(frameSize.width) - 1);
308 yMax = functions::clip(yMax, 0, int(frameSize.height) - 1);
309
310 // The center point of the pixel (0,0).
311 auto centerPointZero = (QPoint(-(int(frameSize.width)), -(int(frameSize.height))) * zoomFactor +
312 QPoint(zoomFactor, zoomFactor)) /
313 2;
314 // This QRect has the size of one pixel and is moved on top of each pixel to draw the text
315 QRect pixelRect;
316 pixelRect.setSize(QSize(zoomFactor, zoomFactor));
317 for (int x = xMin; x <= xMax; x++)
318 {
319 for (int y = yMin; y <= yMax; y++)
320 {
321 // Calculate the center point of the pixel. (Each pixel is of size (zoomFactor,zoomFactor))
322 // and move the pixelRect to that point.
323 QPoint pixCenter = centerPointZero + QPoint(x * zoomFactor, y * zoomFactor);
324 pixelRect.moveCenter(pixCenter);
325
326 // Get the text to show
327 bool drawWhite = false;
328 QRgb pixVal;
329 QString valText;
330 const int formatBase = settings.value("ShowPixelValuesHex").toBool() ? 16 : 10;
331 if (item2 != nullptr)
332 {
333 auto pixel1 = getPixelVal(x, y);
334 auto pixel2 = item2->getPixelVal(x, y);
335
336 int dR = int(qRed(pixel1)) - int(qRed(pixel2));
337 int dG = int(qGreen(pixel1)) - int(qGreen(pixel2));

Callers 1

drawDifferenceFrameMethod · 0.45

Calls 3

clipFunction · 0.85
setSizeMethod · 0.80
getPixelValMethod · 0.45

Tested by

no test coverage detected