Warning, file /office/calligra/libs/pigment/KoColorConversionTransformationFactory.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) 2007 Cyrille Berger <cberger@cberger.net>
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 "KoColorConversionTransformationFactory.h"
0021 
0022 #include <QString>
0023 
0024 #include "KoColorProfile.h"
0025 #include "KoColorSpace.h"
0026 #include "DebugPigment.h"
0027 #include "KoColorSpaceRegistry.h"
0028 
0029 struct Q_DECL_HIDDEN KoColorConversionTransformationFactory::Private {
0030     QString srcModelId;
0031     QString srcDepthId;
0032     QString dstModelId;
0033     QString dstDepthId;
0034     QString srcProfile;
0035     QString dstProfile;
0036 };
0037 
0038 KoColorConversionTransformationFactory::KoColorConversionTransformationFactory(const QString &_srcModelId, const QString &_srcDepthId, const QString &_srcProfile, const QString &_dstModelId, const QString &_dstDepthId, const QString &_dstProfile) : d(new Private)
0039 {
0040     d->srcModelId = _srcModelId;
0041     d->srcDepthId = _srcDepthId;
0042     d->dstModelId = _dstModelId;
0043     d->dstDepthId = _dstDepthId;
0044     d->srcProfile = KoColorSpaceRegistry::instance()->profileAlias(_srcProfile);
0045     d->dstProfile = KoColorSpaceRegistry::instance()->profileAlias(_dstProfile);
0046 }
0047 
0048 KoColorConversionTransformationFactory::~KoColorConversionTransformationFactory()
0049 {
0050     delete d;
0051 }
0052 
0053 bool KoColorConversionTransformationFactory::canBeSource(const KoColorSpace* srcCS) const
0054 {
0055     return ((srcCS->colorModelId().id() == d->srcModelId)
0056             && (srcCS->colorDepthId().id() == d->srcDepthId)
0057             && (d->srcProfile == "" || srcCS->profile()->name() == d->srcProfile));
0058 }
0059 
0060 bool KoColorConversionTransformationFactory::canBeDestination(const KoColorSpace* dstCS) const
0061 {
0062     dbgPigment << dstCS->colorModelId().id() << " " << d->dstModelId << " " << dstCS->colorDepthId().id() << " " <<  d->dstDepthId << " " << d->dstProfile << " " << (dstCS->profile() ? dstCS->profile()->name() : "noprofile")  << " " << d->dstProfile;
0063     return ((dstCS->colorModelId().id() == d->dstModelId)
0064             && (dstCS->colorDepthId().id() == d->dstDepthId)
0065             && (d->dstProfile == "" || dstCS->profile()->name() == d->dstProfile));
0066 }
0067 
0068 QString KoColorConversionTransformationFactory::srcColorModelId() const
0069 {
0070     return d->srcModelId;
0071 }
0072 QString KoColorConversionTransformationFactory::srcColorDepthId() const
0073 {
0074     return d->srcDepthId;
0075 }
0076 
0077 QString KoColorConversionTransformationFactory::srcProfile() const
0078 {
0079     return d->srcProfile;
0080 }
0081 
0082 QString KoColorConversionTransformationFactory::dstColorModelId() const
0083 {
0084     return d->dstModelId;
0085 }
0086 QString KoColorConversionTransformationFactory::dstColorDepthId() const
0087 {
0088     return d->dstDepthId;
0089 }
0090 
0091 QString KoColorConversionTransformationFactory::dstProfile() const
0092 {
0093     return d->dstProfile;
0094 }
0095