Changeset View
Changeset View
Standalone View
Standalone View
plugins/color/lcms2engine/colorspaces/rgb_u8/RgbU8ColorSpace.cpp
Show All 28 Lines | |||||
29 | #include <KoColorConversions.h> | 29 | #include <KoColorConversions.h> | ||
30 | #include "compositeops/KoCompositeOps.h" | 30 | #include "compositeops/KoCompositeOps.h" | ||
31 | #include "compositeops/RgbCompositeOps.h" | 31 | #include "compositeops/RgbCompositeOps.h" | ||
32 | #include <kis_dom_utils.h> | 32 | #include <kis_dom_utils.h> | ||
33 | 33 | | |||
34 | #define downscale(quantum) (quantum) //((unsigned char) ((quantum)/257UL)) | 34 | #define downscale(quantum) (quantum) //((unsigned char) ((quantum)/257UL)) | ||
35 | #define upscale(value) (value) // ((quint8) (257UL*(value))) | 35 | #define upscale(value) (value) // ((quint8) (257UL*(value))) | ||
36 | 36 | | |||
37 | class KoRgbU8InvertColorTransformation : public KoColorTransformation | | |||
38 | { | | |||
39 | | ||||
40 | public: | | |||
41 | | ||||
42 | KoRgbU8InvertColorTransformation(const KoColorSpace *cs) : m_psize(cs->pixelSize()) | | |||
43 | { | | |||
44 | } | | |||
45 | | ||||
46 | void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const override | | |||
47 | { | | |||
48 | while (nPixels--) { | | |||
49 | dst[0] = KoColorSpaceMathsTraits<quint8>::max - src[0]; | | |||
50 | dst[1] = KoColorSpaceMathsTraits<quint8>::max - src[1]; | | |||
51 | dst[2] = KoColorSpaceMathsTraits<quint8>::max - src[2]; | | |||
52 | dst[3] = src[3]; | | |||
53 | | ||||
54 | src += m_psize; | | |||
55 | dst += m_psize; | | |||
56 | } | | |||
57 | | ||||
58 | } | | |||
59 | | ||||
60 | private: | | |||
61 | quint32 m_psize; | | |||
62 | }; | | |||
63 | | ||||
64 | RgbU8ColorSpace::RgbU8ColorSpace(const QString &name, KoColorProfile *p) : | 37 | RgbU8ColorSpace::RgbU8ColorSpace(const QString &name, KoColorProfile *p) : | ||
65 | LcmsColorSpace<KoBgrU8Traits>(colorSpaceId(), name, TYPE_BGRA_8, cmsSigRgbData, p) | 38 | LcmsColorSpace<KoBgrU8Traits>(colorSpaceId(), name, TYPE_BGRA_8, cmsSigRgbData, p) | ||
66 | { | 39 | { | ||
67 | addChannel(new KoChannelInfo(i18n("Blue"), 0, 2, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(0, 0, 255))); | 40 | addChannel(new KoChannelInfo(i18n("Blue"), 0, 2, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(0, 0, 255))); | ||
68 | addChannel(new KoChannelInfo(i18n("Green"), 1, 1, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(0, 255, 0))); | 41 | addChannel(new KoChannelInfo(i18n("Green"), 1, 1, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(0, 255, 0))); | ||
69 | addChannel(new KoChannelInfo(i18n("Red"), 2, 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(255, 0, 0))); | 42 | addChannel(new KoChannelInfo(i18n("Red"), 2, 0, KoChannelInfo::COLOR, KoChannelInfo::UINT8, 1, QColor(255, 0, 0))); | ||
70 | addChannel(new KoChannelInfo(i18n("Alpha"), 3, 3, KoChannelInfo::ALPHA, KoChannelInfo::UINT8)); | 43 | addChannel(new KoChannelInfo(i18n("Alpha"), 3, 3, KoChannelInfo::ALPHA, KoChannelInfo::UINT8)); | ||
71 | 44 | | |||
72 | init(); | 45 | init(); | ||
73 | 46 | | |||
74 | addStandardCompositeOps<KoBgrU8Traits>(this); | 47 | addStandardCompositeOps<KoBgrU8Traits>(this); | ||
75 | 48 | | |||
76 | addCompositeOp(new RgbCompositeOpIn<KoBgrU8Traits>(this)); | 49 | addCompositeOp(new RgbCompositeOpIn<KoBgrU8Traits>(this)); | ||
77 | addCompositeOp(new RgbCompositeOpOut<KoBgrU8Traits>(this)); | 50 | addCompositeOp(new RgbCompositeOpOut<KoBgrU8Traits>(this)); | ||
78 | addCompositeOp(new RgbCompositeOpBumpmap<KoBgrU8Traits>(this)); | 51 | addCompositeOp(new RgbCompositeOpBumpmap<KoBgrU8Traits>(this)); | ||
79 | } | 52 | } | ||
80 | 53 | | |||
81 | KoColorTransformation *RgbU8ColorSpace::createInvertTransformation() const | | |||
82 | { | | |||
83 | return new KoRgbU8InvertColorTransformation(this); | | |||
84 | } | | |||
85 | | ||||
86 | KoColorSpace *RgbU8ColorSpace::clone() const | 54 | KoColorSpace *RgbU8ColorSpace::clone() const | ||
87 | { | 55 | { | ||
88 | return new RgbU8ColorSpace(name(), profile()->clone()); | 56 | return new RgbU8ColorSpace(name(), profile()->clone()); | ||
89 | } | 57 | } | ||
90 | 58 | | |||
91 | void RgbU8ColorSpace::colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const | 59 | void RgbU8ColorSpace::colorToXML(const quint8 *pixel, QDomDocument &doc, QDomElement &colorElt) const | ||
92 | { | 60 | { | ||
93 | const KoBgrU8Traits::Pixel *p = reinterpret_cast<const KoBgrU8Traits::Pixel *>(pixel); | 61 | const KoBgrU8Traits::Pixel *p = reinterpret_cast<const KoBgrU8Traits::Pixel *>(pixel); | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |