1 /* 2 * Copyright (c) 2004-2006 Cyrille Berger <cberger@cberger.net> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 #ifndef COLORSPACE_GRAYSCALE_F16_H_ 19 #define COLORSPACE_GRAYSCALE_F16_H_ 20 21 #include <klocalizedstring.h> 22 #include <KoColorModelStandardIds.h> 23 #include "LcmsColorSpace.h" 24 25 #define TYPE_GRAYA_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)) 26 27 struct KoGrayF16Traits; 28 29 class GrayF16ColorSpace : public LcmsColorSpace<KoGrayF16Traits> 30 { 31 public: 32 GrayF16ColorSpace(const QString &name, KoColorProfile *p); 33 willDegrade(ColorSpaceIndependence)34 virtual bool willDegrade(ColorSpaceIndependence) const 35 { 36 return false; 37 } 38 colorModelId()39 virtual KoID colorModelId() const 40 { 41 return GrayAColorModelID; 42 } 43 colorDepthId()44 virtual KoID colorDepthId() const 45 { 46 return Float16BitsColorDepthID; 47 } 48 49 virtual KoColorSpace *clone() const; 50 51 virtual void colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const; 52 53 virtual void colorFromXML(quint8* pixel, const QDomElement& elt) const; 54 55 virtual void toHSY(const QVector<double> &channelValues, qreal *hue, qreal *sat, qreal *luma) const; 56 virtual QVector <double> fromHSY(qreal *hue, qreal *sat, qreal *luma) const; 57 virtual void toYUV(const QVector<double> &channelValues, qreal *y, qreal *u, qreal *v) const; 58 virtual QVector <double> fromYUV(qreal *y, qreal *u, qreal *v) const; 59 colorSpaceId()60 static QString colorSpaceId() 61 { 62 return "GRAYAF16"; 63 } 64 hasHighDynamicRange()65 virtual bool hasHighDynamicRange() const 66 { 67 return true; 68 } 69 }; 70 71 class GrayF16ColorSpaceFactory : public LcmsColorSpaceFactory 72 { 73 public: GrayF16ColorSpaceFactory()74 GrayF16ColorSpaceFactory() 75 : LcmsColorSpaceFactory(TYPE_GRAYA_HALF_FLT, cmsSigGrayData) 76 { 77 } 78 id()79 virtual QString id() const 80 { 81 return GrayF16ColorSpace::colorSpaceId(); 82 } 83 name()84 virtual QString name() const 85 { 86 return i18n("Grayscale/Alpha (16-bit float/channel)"); 87 } 88 colorModelId()89 virtual KoID colorModelId() const 90 { 91 return GrayAColorModelID; 92 } 93 colorDepthId()94 virtual KoID colorDepthId() const 95 { 96 return Float16BitsColorDepthID; 97 } 98 referenceDepth()99 virtual int referenceDepth() const 100 { 101 return 16; 102 } 103 userVisible()104 virtual bool userVisible() const 105 { 106 return true; 107 } 108 createColorSpace(const KoColorProfile * p)109 virtual KoColorSpace *createColorSpace(const KoColorProfile *p) const 110 { 111 return new GrayF16ColorSpace(name(), p->clone()); 112 } 113 defaultProfile()114 virtual QString defaultProfile() const 115 { 116 return "gray built-in"; 117 } 118 isHdr()119 virtual bool isHdr() const 120 { 121 return true; 122 } 123 }; 124 125 #endif // KIS_STRATEGY_COLORSPACE_GRAYSCALE_H_ 126