File indexing completed on 2024-04-28 04:52:22

0001 /*
0002     SPDX-FileCopyrightText: 2010 Simon Andreas Eugster <simon.eu@gmail.com>
0003     This file is part of kdenlive. See www.kdenlive.org.
0004 
0005 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QObject>
0011 #include "colorconstants.h"
0012 
0013 class QColor;
0014 class QImage;
0015 class QPainter;
0016 class QRect;
0017 class QSize;
0018 
0019 class HistogramGenerator : public QObject
0020 {
0021     Q_OBJECT
0022 public:
0023     explicit HistogramGenerator();
0024 
0025     /**
0026      * Calculates a histogram display from the input image.
0027      * @param paradeSize
0028      * @param image
0029      * @param components OR-ed HistogramGenerator::Components flags and decide with components (Y, R, G, B) to paint.
0030      * @param rec
0031      * @param unscaled unscaled = true leaves the width at 256 if the widget is wider (to avoid scaling).
0032      * @param logScale Use a logarithmic instead of linear scale.
0033      * @param accelFactor
0034      * @return
0035      */
0036     QImage calculateHistogram(const QSize &paradeSize, const QImage &image, const int &components, const ITURec rec, bool unscaled,
0037                               bool logScale,
0038                               uint accelFactor = 1) const;
0039 
0040     /**
0041      * Draws the histogram of a single component.
0042      *
0043      * @param y Bins containing the number of samples per value
0044      * @param size Desired box size of the histogram
0045      * @param scaling Use this scaling factor to scale the y values to the box height
0046      * @param color Color to use for drawing
0047      * @param unscaled Do not scale the width but take the number of bins instead (usually 256)
0048      * @param logScale Use logarithmic scale instead of linear
0049      * @param max Number of bins, usually 256
0050      */
0051     static QImage drawComponent(const int *y, const QSize &size, const float &scaling, const QColor &color, bool unscaled, bool logScale, int max) ;
0052 
0053     static void drawComponentFull(QPainter *davinci, const int *y, const float &scaling, const QRect &rect, const QColor &color, int textSpace,
0054             bool unscaled, bool logScale, int max) ;
0055 
0056     enum Components { ComponentY = 1 << 0, ComponentR = 1 << 1, ComponentG = 1 << 2, ComponentB = 1 << 3, ComponentSum = 1 << 4 };
0057 };