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_rgb_u16_colorspace.h 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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_RGB_U16_H_
  20. #define KIS_STRATEGY_COLORSPACE_RGB_U16_H_
  21. #include <tdelocale.h>
  22. #include <koffice_export.h>
  23. #include "kis_global.h"
  24. #include "kis_u16_base_colorspace.h"
  25. #include "kis_integer_maths.h"
  26. class KRITATOOL_EXPORT KisRgbU16ColorSpace : public KisU16BaseColorSpace {
  27. public:
  28. struct Pixel {
  29. TQ_UINT16 blue;
  30. TQ_UINT16 green;
  31. TQ_UINT16 red;
  32. TQ_UINT16 alpha;
  33. };
  34. public:
  35. KisRgbU16ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
  36. virtual ~KisRgbU16ColorSpace();
  37. virtual bool willDegrade(ColorSpaceIndependence independence)
  38. {
  39. if (independence == TO_RGBA8)
  40. return true;
  41. else
  42. return false;
  43. };
  44. public:
  45. void setPixel(TQ_UINT8 *pixel, TQ_UINT16 red, TQ_UINT16 green, TQ_UINT16 blue, TQ_UINT16 alpha) const;
  46. void getPixel(const TQ_UINT8 *pixel, TQ_UINT16 *red, TQ_UINT16 *green, TQ_UINT16 *blue, TQ_UINT16 *alpha) const;
  47. virtual void mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const;
  48. 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;
  49. virtual void invertColor(TQ_UINT8 * src, TQ_INT32 nPixels);
  50. virtual TQ_UINT8 intensity8(const TQ_UINT8 * src) const;
  51. virtual TQValueVector<KisChannelInfo *> channels() const;
  52. virtual TQ_UINT32 nChannels() const;
  53. virtual TQ_UINT32 nColorChannels() const;
  54. virtual TQ_UINT32 pixelSize() const;
  55. virtual KisCompositeOpList userVisiblecompositeOps() const;
  56. protected:
  57. virtual void bitBlt(TQ_UINT8 *dst,
  58. TQ_INT32 dstRowStride,
  59. const TQ_UINT8 *src,
  60. TQ_INT32 srcRowStride,
  61. const TQ_UINT8 *srcAlphaMask,
  62. TQ_INT32 maskRowStride,
  63. TQ_UINT8 opacity,
  64. TQ_INT32 rows,
  65. TQ_INT32 cols,
  66. const KisCompositeOp& op);
  67. 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);
  68. 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);
  69. 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);
  70. 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);
  71. 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);
  72. 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);
  73. 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);
  74. 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);
  75. 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);
  76. 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);
  77. 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);
  78. 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);
  79. 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);
  80. 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);
  81. private:
  82. friend class KisRgbU16ColorSpaceTester;
  83. static const TQ_UINT8 PIXEL_BLUE = 0;
  84. static const TQ_UINT8 PIXEL_GREEN = 1;
  85. static const TQ_UINT8 PIXEL_RED = 2;
  86. static const TQ_UINT8 PIXEL_ALPHA = 3;
  87. };
  88. class KisRgbU16ColorSpaceFactory : public KisColorSpaceFactory
  89. {
  90. public:
  91. /**
  92. * Chalk definition for use in .kra files and internally: unchanging name +
  93. * i18n'able description.
  94. */
  95. virtual KisID id() const { return KisID("RGBA16", i18n("RGB (16-bit integer/channel)")); };
  96. /**
  97. * lcms colorspace type definition.
  98. */
  99. virtual TQ_UINT32 colorSpaceType() { return TYPE_BGRA_16; };
  100. virtual icColorSpaceSignature colorSpaceSignature() { return icSigRgbData; };
  101. virtual KisColorSpace *createColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) { return new KisRgbU16ColorSpace(parent, p); };
  102. virtual TQString defaultProfile() { return "sRGB built-in - (lcms internal)"; };
  103. };
  104. #endif // KIS_STRATEGY_COLORSPACE_RGB_U16_H_