1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2004-12-01 7 * Description : image curves manipulation methods. 8 * 9 * Copyright (C) 2004-2021 by Gilles Caulier <caulier dot gilles at gmail dot com> 10 * Copyright (C) 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 11 * 12 * This program is free software; you can redistribute it 13 * and/or modify it under the terms of the GNU General 14 * Public License as published by the Free Software Foundation; 15 * either version 2, or (at your option) 16 * any later version. 17 * 18 * This program is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * ============================================================ */ 24 25 #ifndef DIGIKAM_CURVES_CONTAINER_H 26 #define DIGIKAM_CURVES_CONTAINER_H 27 28 // Qt includes 29 30 #include <QPolygon> 31 #include <QString> 32 33 // Local includes 34 35 #include "digikam_globals.h" 36 #include "digikam_export.h" 37 38 namespace Digikam 39 { 40 41 class FilterAction; 42 43 class DIGIKAM_EXPORT CurvesContainer 44 { 45 46 public: 47 48 /** 49 * Provides a convenient storage for a curve. 50 * Initially, the values are empty. 51 * Call initialize() before adjusting values manually. 52 */ 53 CurvesContainer(); 54 CurvesContainer(int type, bool sixteenBit); 55 56 /** 57 * Fills the values with a linear curve suitable for type and sixteenBit parameters. 58 */ 59 void initialize(); 60 61 /** 62 * An empty container is interpreted as a linear curve. 63 * A non-empty container can also be linear; test for isLinear() 64 * of the resulting ImageCurves. 65 * Note: If an ImageCurves is linear, it will return an empty container. 66 */ 67 bool isEmpty() const; 68 69 bool operator==(const CurvesContainer& other) const; 70 71 /** 72 * Serialize from and to FilterAction. 73 * isStoredLosslessly returns false if the curve cannot be losslessly stored 74 * in XML because it would be too large (free 16 bit). It is then lossily compressed. 75 */ 76 bool isStoredLosslessly() const; 77 void writeToFilterAction(FilterAction& action, const QString& prefix = QString()) const; 78 static CurvesContainer fromFilterAction(const FilterAction& action, const QString& prefix = QString()); 79 80 public: 81 82 /** 83 * Smooth : QPolygon have size of 18 points. 84 * Free : QPolygon have size of 255 or 65535 values. 85 */ 86 int curvesType; 87 QPolygon values[ColorChannels]; 88 89 bool sixteenBit; 90 }; 91 92 } // namespace Digikam 93 94 #endif // DIGIKAM_CURVES_CONTAINER_H 95