Warning, file /office/calligra/libs/pigment/KoColorDisplayRendererInterface.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2014 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "KoColorDisplayRendererInterface.h" 0021 0022 #include <QGlobalStatic> 0023 0024 #include <KoColorSpaceRegistry.h> 0025 #include <KoChannelInfo.h> 0026 0027 Q_GLOBAL_STATIC(KoDumbColorDisplayRenderer, s_instance) 0028 0029 KoColorDisplayRendererInterface::KoColorDisplayRendererInterface() 0030 { 0031 } 0032 0033 KoColorDisplayRendererInterface::~KoColorDisplayRendererInterface() 0034 { 0035 } 0036 0037 QColor KoDumbColorDisplayRenderer::toQColor(const KoColor &c) const 0038 { 0039 return c.toQColor(); 0040 } 0041 0042 KoColor KoDumbColorDisplayRenderer::approximateFromRenderedQColor(const QColor &c) const 0043 { 0044 KoColor color; 0045 color.fromQColor(c); 0046 return color; 0047 } 0048 0049 KoColor KoDumbColorDisplayRenderer::fromHsv(int h, int s, int v, int a) const 0050 { 0051 h = qBound(0, h, 359); 0052 s = qBound(0, s, 255); 0053 v = qBound(0, v, 255); 0054 a = qBound(0, a, 255); 0055 QColor qcolor(QColor::fromHsv(h, s, v, a)); 0056 return KoColor(qcolor, KoColorSpaceRegistry::instance()->rgb8()); 0057 } 0058 0059 void KoDumbColorDisplayRenderer::getHsv(const KoColor &srcColor, int *h, int *s, int *v, int *a) const 0060 { 0061 QColor qcolor = toQColor(srcColor); 0062 qcolor.getHsv(h, s, v, a); 0063 } 0064 0065 KoColorDisplayRendererInterface* KoDumbColorDisplayRenderer::instance() 0066 { 0067 return s_instance; 0068 } 0069 0070 qreal KoDumbColorDisplayRenderer::minVisibleFloatValue(const KoChannelInfo *chaninfo) const 0071 { 0072 Q_ASSERT(chaninfo); 0073 return chaninfo->getUIMin(); 0074 } 0075 0076 qreal KoDumbColorDisplayRenderer::maxVisibleFloatValue(const KoChannelInfo *chaninfo) const 0077 { 0078 Q_ASSERT(chaninfo); 0079 return chaninfo->getUIMax(); 0080 }