KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kis_lab_colorspace.h 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
  3. * Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef KIS_STRATEGY_COLORSPACE_LAB_H_
  20. #define KIS_STRATEGY_COLORSPACE_LAB_H_
  21. #include <tqcolor.h>
  22. #include <tdelocale.h>
  23. #include "kis_global.h"
  24. #include "kis_integer_maths.h"
  25. #include "kis_u16_base_colorspace.h"
  26. class KisLabColorSpace : public KisU16BaseColorSpace {
  27. public:
  28. KisLabColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
  29. virtual ~KisLabColorSpace();
  30. public:
  31. /**
  32. * Return a COPY of the provided data. This method is provided to provide consistency,
  33. * but you really don't want to be calling it.
  34. */
  35. virtual TQ_UINT8 * toLabA16(const TQ_UINT8 * data, const TQ_UINT32 nPixels) const;
  36. /**
  37. * Return a COPY of the provided data. This method is provided for consistency,
  38. * but you really don't want to call it.
  39. */
  40. virtual TQ_UINT8 * fromLabA16(const TQ_UINT8 * labData, const TQ_UINT32 nPixels) const;
  41. virtual bool willDegrade(ColorSpaceIndependence independence)
  42. {
  43. if (independence == TO_RGBA8)
  44. return true;
  45. else
  46. return false;
  47. };
  48. virtual TQValueVector<KisChannelInfo *> channels() const;
  49. virtual TQ_UINT32 nChannels() const;
  50. virtual TQ_UINT32 nColorChannels() const;
  51. virtual TQ_UINT32 pixelSize() const;
  52. virtual TQString channelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
  53. virtual TQString normalisedChannelValueText(const TQ_UINT8 *pixel, TQ_UINT32 channelIndex) const;
  54. virtual void getSingleChannelPixel(TQ_UINT8 *dstPixel, const TQ_UINT8 *srcPixel, TQ_UINT32 channelIndex);
  55. virtual TQ_UINT8 difference(const TQ_UINT8 *src1, const TQ_UINT8 *src2);
  56. virtual void mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const;
  57. virtual void invertColor(TQ_UINT8 * src, TQ_INT32 nPixels);
  58. virtual void convolveColors(TQ_UINT8** colors, TQ_INT32 * kernelValues, KisChannelInfo::enumChannelFlags channelFlags, TQ_UINT8 *dst, TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const;
  59. virtual void darken(const TQ_UINT8 * src, TQ_UINT8 * dst, TQ_INT32 shade, bool compensate, double compensation, TQ_INT32 nPixels) const;
  60. virtual KisCompositeOpList userVisiblecompositeOps() const;
  61. protected:
  62. virtual void bitBlt(TQ_UINT8 *dst,
  63. TQ_INT32 dstRowStride,
  64. const TQ_UINT8 *src,
  65. TQ_INT32 srcRowStride,
  66. const TQ_UINT8 *srcAlphaMask,
  67. TQ_INT32 maskRowStride,
  68. TQ_UINT8 opacity,
  69. TQ_INT32 rows,
  70. TQ_INT32 cols,
  71. const KisCompositeOp& op);
  72. void compositeOver(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  73. /*
  74. void compositeMultiply(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  75. void compositeDivide(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  76. void compositeScreen(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  77. void compositeOverlay(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  78. void compositeDodge(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  79. void compositeBurn(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  80. void compositeDarken(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  81. void compositeLighten(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  82. void compositeHue(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  83. void compositeSaturation(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  84. void compositeValue(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  85. void compositeColor(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  86. */
  87. void compositeErase(TQ_UINT8 *dst, TQ_INT32 dstRowStride, const TQ_UINT8 *src, TQ_INT32 srcRowStride, const TQ_UINT8 *mask, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 columns, TQ_UINT16 opacity);
  88. private:
  89. struct Pixel {
  90. TQ_UINT16 lightness;
  91. TQ_UINT16 a;
  92. TQ_UINT16 b;
  93. TQ_UINT16 alpha;
  94. };
  95. static const TQ_UINT16 U16_OPACITY_OPAQUE = UINT16_MAX;
  96. static const TQ_UINT16 U16_OPACITY_TRANSPARENT = UINT16_MIN;
  97. static const TQ_UINT32 NUM_CHANNELS = 4;
  98. static const TQ_UINT32 NUM_COLOR_CHANNELS = 3;
  99. static const TQ_UINT32 CHANNEL_L = 0;
  100. static const TQ_UINT32 CHANNEL_A = 1;
  101. static const TQ_UINT32 CHANNEL_B = 2;
  102. static const TQ_UINT32 CHANNEL_ALPHA = 3;
  103. static const TQ_UINT32 MAX_CHANNEL_L = 0xff00;
  104. static const TQ_UINT32 MAX_CHANNEL_AB = 0xffff;
  105. static const TQ_UINT32 CHANNEL_AB_ZERO_OFFSET = 0x8000;
  106. friend class KisLabColorSpaceTester;
  107. };
  108. class KisLabColorSpaceFactory : public KisColorSpaceFactory
  109. {
  110. public:
  111. /**
  112. * Chalk definition for use in .kra files and internally: unchanging name +
  113. * i18n'able description.
  114. */
  115. virtual KisID id() const { return KisID("LABA", i18n("L*a*b* (16-bit integer/channel)")); };
  116. /**
  117. * lcms colorspace type definition.
  118. */
  119. virtual TQ_UINT32 colorSpaceType() { return (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)); };
  120. virtual icColorSpaceSignature colorSpaceSignature() { return icSigLabData; };
  121. virtual KisColorSpace *createColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) { return new KisLabColorSpace(parent, p); };
  122. virtual TQString defaultProfile() { return "Lab built-in - (lcms internal)"; };
  123. };
  124. #endif // KIS_STRATEGY_COLORSPACE_LAB_H_