File indexing completed on 2024-05-19 15:01:23
0001 /*************************************************************************** 0002 File : ImageEditor.h 0003 Project : LabPlot 0004 Description : Edit Image on the basis of input color attributes 0005 -------------------------------------------------------------------- 0006 Copyright : (C) 2015 by Ankit Wagadre (wagadre.ankit@gmail.com) 0007 ***************************************************************************/ 0008 /*************************************************************************** 0009 * * 0010 * This program is free software; you can redistribute it and/or modify * 0011 * it under the terms of the GNU General Public License as published by * 0012 * the Free Software Foundation; either version 2 of the License, or * 0013 * (at your option) any later version. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program; if not, write to the Free Software * 0022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0023 * Boston, MA 02110-1301 USA * 0024 * * 0025 ***************************************************************************/ 0026 0027 #ifndef IMAGEEDITOR_H 0028 #define IMAGEEDITOR_H 0029 0030 #include <QList> 0031 0032 #include <backend/datapicker/DatapickerImage.h> 0033 0034 class QColor; 0035 0036 class ImageEditor { 0037 public: 0038 static void discretize(QImage*, QImage*, const DatapickerImage::EditorSettings&, QColor); 0039 static bool processedPixelIsOn(const QImage&, int, int); 0040 static QRgb findBackgroundColor(const QImage*); 0041 static int colorAttributeMax(DatapickerImage::ColorAttributes); 0042 static void uploadHistogram(int*, QImage*, QColor, DatapickerImage::ColorAttributes); 0043 static int discretizeValueForeground(int, int, DatapickerImage::ColorAttributes, const QColor, const QImage*); 0044 static bool pixelIsOn(int, DatapickerImage::ColorAttributes, const DatapickerImage::EditorSettings&); 0045 0046 static int discretizeHue(int, int, const QImage*); 0047 static int discretizeSaturation(int, int, const QImage*); 0048 static int discretizeValue(int, int, const QImage*); 0049 static int discretizeIntensity(int, int, const QImage*); 0050 static int discretizeForeground(int, int, const QColor, const QImage*); 0051 0052 private: 0053 static bool colorCompare(QRgb color1, QRgb color2); 0054 static bool pixelIsOn(int, int, int); 0055 0056 struct ColorEntry { 0057 QColor color; 0058 int count; 0059 }; 0060 typedef QVector<ColorEntry> ColorList; 0061 }; 0062 #endif // IMAGEEDITOR_H