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_gray_u16_colorspace.cc 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. * Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
  3. * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
  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. #include <config.h>
  20. #include <limits.h>
  21. #include <stdlib.h>
  22. #include LCMS_HEADER
  23. #include <tqimage.h>
  24. #include <kdebug.h>
  25. #include <tdelocale.h>
  26. #include <tdeglobal.h>
  27. #include "kis_gray_u16_colorspace.h"
  28. #include "kis_u16_base_colorspace.h"
  29. #include "kis_color_conversions.h"
  30. #include "kis_integer_maths.h"
  31. #include "kis_colorspace_factory_registry.h"
  32. namespace {
  33. const TQ_INT32 MAX_CHANNEL_GRAY = 1;
  34. const TQ_INT32 MAX_CHANNEL_GRAYA = 2;
  35. }
  36. KisGrayU16ColorSpace::KisGrayU16ColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p) :
  37. KisU16BaseColorSpace(KisID("GRAYA16", i18n("Grayscale (16-bit integer/channel)")), TYPE_GRAYA_16, icSigGrayData, parent, p)
  38. {
  39. m_channels.push_back(new KisChannelInfo(i18n("Gray"), i18n("G"), PIXEL_GRAY * sizeof(TQ_UINT16), KisChannelInfo::COLOR, KisChannelInfo::UINT16, sizeof(TQ_UINT16)));
  40. m_channels.push_back(new KisChannelInfo(i18n("Alpha"), i18n("A"), PIXEL_ALPHA * sizeof(TQ_UINT16), KisChannelInfo::ALPHA, KisChannelInfo::UINT16, sizeof(TQ_UINT16)));
  41. /* LPGAMMATABLE Gamma = cmsBuildGamma(256, 2.2);
  42. cmsHPROFILE hProfile = cmsCreateGrayProfile(cmsD50_xyY(), Gamma);
  43. cmsFreeGamma(Gamma);
  44. */
  45. m_alphaPos = PIXEL_ALPHA * sizeof(TQ_UINT16);
  46. init();
  47. }
  48. KisGrayU16ColorSpace::~KisGrayU16ColorSpace()
  49. {
  50. }
  51. void KisGrayU16ColorSpace::mixColors(const TQ_UINT8 **colors, const TQ_UINT8 *weights, TQ_UINT32 nColors, TQ_UINT8 *dst) const
  52. {
  53. TQ_UINT32 totalGray = 0, newAlpha = 0;
  54. while (nColors--)
  55. {
  56. const Pixel *pixel = reinterpret_cast<const Pixel *>(*colors);
  57. TQ_UINT32 alpha = pixel->alpha;
  58. TQ_UINT32 alphaTimesWeight = UINT16_MULT(alpha, UINT8_TO_UINT16(*weights));
  59. totalGray += UINT16_MULT(pixel->gray, alphaTimesWeight);
  60. newAlpha += alphaTimesWeight;
  61. weights++;
  62. colors++;
  63. }
  64. Q_ASSERT(newAlpha <= U16_OPACITY_OPAQUE);
  65. Pixel *dstPixel = reinterpret_cast<Pixel *>(dst);
  66. dstPixel->alpha = newAlpha;
  67. if (newAlpha > 0) {
  68. totalGray = UINT16_DIVIDE(totalGray, newAlpha);
  69. }
  70. dstPixel->gray = totalGray;
  71. }
  72. void KisGrayU16ColorSpace::convolveColors(TQ_UINT8** colors, TQ_INT32* kernelValues, KisChannelInfo::enumChannelFlags channelFlags, TQ_UINT8 *dst,
  73. TQ_INT32 factor, TQ_INT32 offset, TQ_INT32 nColors) const
  74. {
  75. TQ_INT32 totalGray = 0, totalAlpha = 0;
  76. while (nColors--)
  77. {
  78. const Pixel * pixel = reinterpret_cast<const Pixel *>( *colors );
  79. TQ_INT32 weight = *kernelValues;
  80. if (weight != 0) {
  81. totalGray += pixel->gray * weight;
  82. totalAlpha += pixel->alpha * weight;
  83. }
  84. colors++;
  85. kernelValues++;
  86. }
  87. Pixel * p = reinterpret_cast< Pixel *>( dst );
  88. if (channelFlags & KisChannelInfo::FLAG_COLOR) {
  89. p->gray = CLAMP( ( totalGray / factor) + offset, 0, TQ_UINT16_MAX);
  90. }
  91. if (channelFlags & KisChannelInfo::FLAG_ALPHA) {
  92. p->alpha = CLAMP((totalAlpha/ factor) + offset, 0, TQ_UINT16_MAX);
  93. }
  94. }
  95. void KisGrayU16ColorSpace::invertColor(TQ_UINT8 * src, TQ_INT32 nPixels)
  96. {
  97. TQ_UINT32 psize = pixelSize();
  98. while (nPixels--)
  99. {
  100. Pixel * p = reinterpret_cast< Pixel *>( src );
  101. p->gray = TQ_UINT16_MAX - p->gray;
  102. src += psize;
  103. }
  104. }
  105. TQ_UINT8 KisGrayU16ColorSpace::intensity8(const TQ_UINT8 * src) const
  106. {
  107. const Pixel * p = reinterpret_cast<const Pixel *>( src );
  108. return UINT16_TO_UINT8(p->gray);
  109. }
  110. TQValueVector<KisChannelInfo *> KisGrayU16ColorSpace::channels() const
  111. {
  112. return m_channels;
  113. }
  114. TQ_UINT32 KisGrayU16ColorSpace::nChannels() const
  115. {
  116. return MAX_CHANNEL_GRAYA;
  117. }
  118. TQ_UINT32 KisGrayU16ColorSpace::nColorChannels() const
  119. {
  120. return MAX_CHANNEL_GRAY;
  121. }
  122. TQ_UINT32 KisGrayU16ColorSpace::pixelSize() const
  123. {
  124. return MAX_CHANNEL_GRAYA * sizeof(TQ_UINT16);
  125. }
  126. void KisGrayU16ColorSpace::compositeOver(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  127. {
  128. while (rows > 0) {
  129. const TQ_UINT16 *src = reinterpret_cast<const TQ_UINT16 *>(srcRowStart);
  130. TQ_UINT16 *dst = reinterpret_cast<TQ_UINT16 *>(dstRowStart);
  131. const TQ_UINT8 *mask = maskRowStart;
  132. TQ_INT32 columns = numColumns;
  133. while (columns > 0) {
  134. TQ_UINT16 srcAlpha = src[PIXEL_ALPHA];
  135. // apply the alphamask
  136. if (mask != 0) {
  137. TQ_UINT8 U8_mask = *mask;
  138. if (U8_mask != OPACITY_OPAQUE) {
  139. srcAlpha = UINT16_MULT(srcAlpha, UINT8_TO_UINT16(U8_mask));
  140. }
  141. mask++;
  142. }
  143. if (srcAlpha != U16_OPACITY_TRANSPARENT) {
  144. if (opacity != U16_OPACITY_OPAQUE) {
  145. srcAlpha = UINT16_MULT(srcAlpha, opacity);
  146. }
  147. if (srcAlpha == U16_OPACITY_OPAQUE) {
  148. memcpy(dst, src, MAX_CHANNEL_GRAYA * sizeof(TQ_UINT16));
  149. } else {
  150. TQ_UINT16 dstAlpha = dst[PIXEL_ALPHA];
  151. TQ_UINT16 srcBlend;
  152. if (dstAlpha == U16_OPACITY_OPAQUE) {
  153. srcBlend = srcAlpha;
  154. } else {
  155. TQ_UINT16 newAlpha = dstAlpha + UINT16_MULT(U16_OPACITY_OPAQUE - dstAlpha, srcAlpha);
  156. dst[PIXEL_ALPHA] = newAlpha;
  157. if (newAlpha != 0) {
  158. srcBlend = UINT16_DIVIDE(srcAlpha, newAlpha);
  159. } else {
  160. srcBlend = srcAlpha;
  161. }
  162. }
  163. if (srcBlend == U16_OPACITY_OPAQUE) {
  164. memcpy(dst, src, MAX_CHANNEL_GRAY * sizeof(TQ_UINT16));
  165. } else {
  166. dst[PIXEL_GRAY] = UINT16_BLEND(src[PIXEL_GRAY], dst[PIXEL_GRAY], srcBlend);
  167. }
  168. }
  169. }
  170. columns--;
  171. src += MAX_CHANNEL_GRAYA;
  172. dst += MAX_CHANNEL_GRAYA;
  173. }
  174. rows--;
  175. srcRowStart += srcRowStride;
  176. dstRowStart += dstRowStride;
  177. if(maskRowStart) {
  178. maskRowStart += maskRowStride;
  179. }
  180. }
  181. }
  182. #define COMMON_COMPOSITE_OP_PROLOG() \
  183. while (rows > 0) { \
  184. \
  185. const TQ_UINT16 *src = reinterpret_cast<const TQ_UINT16 *>(srcRowStart); \
  186. TQ_UINT16 *dst = reinterpret_cast<TQ_UINT16 *>(dstRowStart); \
  187. TQ_INT32 columns = numColumns; \
  188. const TQ_UINT8 *mask = maskRowStart; \
  189. \
  190. while (columns > 0) { \
  191. \
  192. TQ_UINT16 srcAlpha = src[PIXEL_ALPHA]; \
  193. TQ_UINT16 dstAlpha = dst[PIXEL_ALPHA]; \
  194. \
  195. srcAlpha = TQMIN(srcAlpha, dstAlpha); \
  196. \
  197. if (mask != 0) { \
  198. TQ_UINT8 U8_mask = *mask; \
  199. \
  200. if (U8_mask != OPACITY_OPAQUE) { \
  201. srcAlpha = UINT16_MULT(srcAlpha, UINT8_TO_UINT16(U8_mask)); \
  202. } \
  203. mask++; \
  204. } \
  205. \
  206. if (srcAlpha != U16_OPACITY_TRANSPARENT) { \
  207. \
  208. if (opacity != U16_OPACITY_OPAQUE) { \
  209. srcAlpha = UINT16_MULT(srcAlpha, opacity); \
  210. } \
  211. \
  212. TQ_UINT16 srcBlend; \
  213. \
  214. if (dstAlpha == U16_OPACITY_OPAQUE) { \
  215. srcBlend = srcAlpha; \
  216. } else { \
  217. TQ_UINT16 newAlpha = dstAlpha + UINT16_MULT(U16_OPACITY_OPAQUE - dstAlpha, srcAlpha); \
  218. dst[PIXEL_ALPHA] = newAlpha; \
  219. \
  220. if (newAlpha != 0) { \
  221. srcBlend = UINT16_DIVIDE(srcAlpha, newAlpha); \
  222. } else { \
  223. srcBlend = srcAlpha; \
  224. } \
  225. }
  226. #define COMMON_COMPOSITE_OP_EPILOG() \
  227. } \
  228. \
  229. columns--; \
  230. src += MAX_CHANNEL_GRAYA; \
  231. dst += MAX_CHANNEL_GRAYA; \
  232. } \
  233. \
  234. rows--; \
  235. srcRowStart += srcRowStride; \
  236. dstRowStart += dstRowStride; \
  237. if(maskRowStart) { \
  238. maskRowStart += maskRowStride; \
  239. } \
  240. }
  241. void KisGrayU16ColorSpace::compositeMultiply(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  242. {
  243. COMMON_COMPOSITE_OP_PROLOG();
  244. {
  245. TQ_UINT16 srcColor = src[PIXEL_GRAY];
  246. TQ_UINT16 dstColor = dst[PIXEL_GRAY];
  247. srcColor = UINT16_MULT(srcColor, dstColor);
  248. dst[PIXEL_GRAY] = UINT16_BLEND(srcColor, dstColor, srcBlend);
  249. }
  250. COMMON_COMPOSITE_OP_EPILOG();
  251. }
  252. void KisGrayU16ColorSpace::compositeDivide(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  253. {
  254. COMMON_COMPOSITE_OP_PROLOG();
  255. {
  256. for (int channel = 0; channel < MAX_CHANNEL_GRAY; channel++) {
  257. TQ_UINT16 srcColor = src[channel];
  258. TQ_UINT16 dstColor = dst[channel];
  259. srcColor = TQMIN((dstColor * (UINT16_MAX + 1u) + (srcColor / 2u)) / (1u + srcColor), UINT16_MAX);
  260. TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
  261. dst[channel] = newColor;
  262. }
  263. }
  264. COMMON_COMPOSITE_OP_EPILOG();
  265. }
  266. void KisGrayU16ColorSpace::compositeScreen(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  267. {
  268. COMMON_COMPOSITE_OP_PROLOG();
  269. {
  270. for (int channel = 0; channel < MAX_CHANNEL_GRAY; channel++) {
  271. TQ_UINT16 srcColor = src[channel];
  272. TQ_UINT16 dstColor = dst[channel];
  273. srcColor = UINT16_MAX - UINT16_MULT(UINT16_MAX - dstColor, UINT16_MAX - srcColor);
  274. TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
  275. dst[channel] = newColor;
  276. }
  277. }
  278. COMMON_COMPOSITE_OP_EPILOG();
  279. }
  280. void KisGrayU16ColorSpace::compositeOverlay(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  281. {
  282. COMMON_COMPOSITE_OP_PROLOG();
  283. {
  284. for (int channel = 0; channel < MAX_CHANNEL_GRAY; channel++) {
  285. TQ_UINT16 srcColor = src[channel];
  286. TQ_UINT16 dstColor = dst[channel];
  287. srcColor = UINT16_MULT(dstColor, dstColor + 2u * UINT16_MULT(srcColor, UINT16_MAX - dstColor));
  288. TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
  289. dst[channel] = newColor;
  290. }
  291. }
  292. COMMON_COMPOSITE_OP_EPILOG();
  293. }
  294. void KisGrayU16ColorSpace::compositeDodge(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  295. {
  296. COMMON_COMPOSITE_OP_PROLOG();
  297. {
  298. for (int channel = 0; channel < MAX_CHANNEL_GRAY; channel++) {
  299. TQ_UINT16 srcColor = src[channel];
  300. TQ_UINT16 dstColor = dst[channel];
  301. srcColor = TQMIN((dstColor * (UINT16_MAX + 1u)) / (UINT16_MAX + 1u - srcColor), UINT16_MAX);
  302. TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
  303. dst[channel] = newColor;
  304. }
  305. }
  306. COMMON_COMPOSITE_OP_EPILOG();
  307. }
  308. void KisGrayU16ColorSpace::compositeBurn(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  309. {
  310. COMMON_COMPOSITE_OP_PROLOG();
  311. {
  312. for (int channel = 0; channel < MAX_CHANNEL_GRAY; channel++) {
  313. TQ_UINT16 srcColor = src[channel];
  314. TQ_UINT16 dstColor = dst[channel];
  315. srcColor = kMin(((UINT16_MAX - dstColor) * (UINT16_MAX + 1u)) / (srcColor + 1u), UINT16_MAX);
  316. srcColor = kClamp(UINT16_MAX - srcColor, 0u, UINT16_MAX);
  317. TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
  318. dst[channel] = newColor;
  319. }
  320. }
  321. COMMON_COMPOSITE_OP_EPILOG();
  322. }
  323. void KisGrayU16ColorSpace::compositeDarken(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  324. {
  325. COMMON_COMPOSITE_OP_PROLOG();
  326. {
  327. for (int channel = 0; channel < MAX_CHANNEL_GRAY; channel++) {
  328. TQ_UINT16 srcColor = src[channel];
  329. TQ_UINT16 dstColor = dst[channel];
  330. srcColor = TQMIN(srcColor, dstColor);
  331. TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
  332. dst[channel] = newColor;
  333. }
  334. }
  335. COMMON_COMPOSITE_OP_EPILOG();
  336. }
  337. void KisGrayU16ColorSpace::compositeLighten(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStride, const TQ_UINT8 *srcRowStart, TQ_INT32 srcRowStride, const TQ_UINT8 *maskRowStart, TQ_INT32 maskRowStride, TQ_INT32 rows, TQ_INT32 numColumns, TQ_UINT16 opacity)
  338. {
  339. COMMON_COMPOSITE_OP_PROLOG();
  340. {
  341. for (int channel = 0; channel < MAX_CHANNEL_GRAY; channel++) {
  342. TQ_UINT16 srcColor = src[channel];
  343. TQ_UINT16 dstColor = dst[channel];
  344. srcColor = TQMAX(srcColor, dstColor);
  345. TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend);
  346. dst[channel] = newColor;
  347. }
  348. }
  349. COMMON_COMPOSITE_OP_EPILOG();
  350. }
  351. void KisGrayU16ColorSpace::compositeErase(TQ_UINT8 *dst,
  352. TQ_INT32 dstRowSize,
  353. const TQ_UINT8 *src,
  354. TQ_INT32 srcRowSize,
  355. const TQ_UINT8 *srcAlphaMask,
  356. TQ_INT32 maskRowStride,
  357. TQ_INT32 rows,
  358. TQ_INT32 cols,
  359. TQ_UINT16 /*opacity*/)
  360. {
  361. while (rows-- > 0)
  362. {
  363. const Pixel *s = reinterpret_cast<const Pixel *>(src);
  364. Pixel *d = reinterpret_cast<Pixel *>(dst);
  365. const TQ_UINT8 *mask = srcAlphaMask;
  366. for (TQ_INT32 i = cols; i > 0; i--, s++, d++)
  367. {
  368. TQ_UINT16 srcAlpha = s->alpha;
  369. // apply the alphamask
  370. if (mask != 0) {
  371. TQ_UINT8 U8_mask = *mask;
  372. if (U8_mask != OPACITY_OPAQUE) {
  373. srcAlpha = UINT16_BLEND(srcAlpha, U16_OPACITY_OPAQUE, UINT8_TO_UINT16(U8_mask));
  374. }
  375. mask++;
  376. }
  377. d->alpha = UINT16_MULT(srcAlpha, d->alpha);
  378. }
  379. dst += dstRowSize;
  380. src += srcRowSize;
  381. if(srcAlphaMask) {
  382. srcAlphaMask += maskRowStride;
  383. }
  384. }
  385. }
  386. void KisGrayU16ColorSpace::bitBlt(TQ_UINT8 *dst,
  387. TQ_INT32 dstRowStride,
  388. const TQ_UINT8 *src,
  389. TQ_INT32 srcRowStride,
  390. const TQ_UINT8 *mask,
  391. TQ_INT32 maskRowStride,
  392. TQ_UINT8 U8_opacity,
  393. TQ_INT32 rows,
  394. TQ_INT32 cols,
  395. const KisCompositeOp& op)
  396. {
  397. TQ_UINT16 opacity = UINT8_TO_UINT16(U8_opacity);
  398. switch (op.op()) {
  399. case COMPOSITE_UNDEF:
  400. // Undefined == no composition
  401. break;
  402. case COMPOSITE_OVER:
  403. compositeOver(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  404. break;
  405. case COMPOSITE_IN:
  406. //compositeIn(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  407. case COMPOSITE_OUT:
  408. //compositeOut(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  409. break;
  410. case COMPOSITE_ATOP:
  411. //compositeAtop(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  412. break;
  413. case COMPOSITE_XOR:
  414. //compositeXor(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  415. break;
  416. case COMPOSITE_PLUS:
  417. //compositePlus(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  418. break;
  419. case COMPOSITE_MINUS:
  420. //compositeMinus(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  421. break;
  422. case COMPOSITE_ADD:
  423. //compositeAdd(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  424. break;
  425. case COMPOSITE_SUBTRACT:
  426. //compositeSubtract(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  427. break;
  428. case COMPOSITE_DIFF:
  429. //compositeDiff(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  430. break;
  431. case COMPOSITE_MULT:
  432. compositeMultiply(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  433. break;
  434. case COMPOSITE_DIVIDE:
  435. compositeDivide(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  436. break;
  437. case COMPOSITE_BUMPMAP:
  438. //compositeBumpmap(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  439. break;
  440. case COMPOSITE_COPY:
  441. compositeCopy(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, U8_opacity);
  442. break;
  443. case COMPOSITE_COPY_RED:
  444. //compositeCopyRed(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  445. break;
  446. case COMPOSITE_COPY_GREEN:
  447. //compositeCopyGreen(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  448. break;
  449. case COMPOSITE_COPY_BLUE:
  450. //compositeCopyBlue(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  451. break;
  452. case COMPOSITE_COPY_OPACITY:
  453. //compositeCopyOpacity(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  454. break;
  455. case COMPOSITE_CLEAR:
  456. //compositeClear(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  457. break;
  458. case COMPOSITE_DISSOLVE:
  459. //compositeDissolve(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  460. break;
  461. case COMPOSITE_DISPLACE:
  462. //compositeDisplace(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  463. break;
  464. #if 0
  465. case COMPOSITE_MODULATE:
  466. compositeModulate(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  467. break;
  468. case COMPOSITE_THRESHOLD:
  469. compositeThreshold(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  470. break;
  471. #endif
  472. case COMPOSITE_NO:
  473. // No composition.
  474. break;
  475. case COMPOSITE_DARKEN:
  476. compositeDarken(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  477. break;
  478. case COMPOSITE_LIGHTEN:
  479. compositeLighten(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  480. break;
  481. case COMPOSITE_HUE:
  482. //compositeHue(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  483. break;
  484. case COMPOSITE_SATURATION:
  485. //compositeSaturation(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  486. break;
  487. case COMPOSITE_VALUE:
  488. //compositeValue(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  489. break;
  490. case COMPOSITE_COLOR:
  491. //compositeColor(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  492. break;
  493. case COMPOSITE_COLORIZE:
  494. //compositeColorize(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  495. break;
  496. case COMPOSITE_LUMINIZE:
  497. //compositeLuminize(pixelSize(), dst, dstRowStride, src, srcRowStride, rows, cols, opacity);
  498. break;
  499. case COMPOSITE_SCREEN:
  500. compositeScreen(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  501. break;
  502. case COMPOSITE_OVERLAY:
  503. compositeOverlay(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  504. break;
  505. case COMPOSITE_ERASE:
  506. compositeErase(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  507. break;
  508. case COMPOSITE_DODGE:
  509. compositeDodge(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  510. break;
  511. case COMPOSITE_BURN:
  512. compositeBurn(dst, dstRowStride, src, srcRowStride, mask, maskRowStride, rows, cols, opacity);
  513. break;
  514. case COMPOSITE_ALPHA_DARKEN:
  515. abstractCompositeAlphaDarken<TQ_UINT16, U16Mult, Uint8ToU16, U16OpacityTest,
  516. PIXEL_ALPHA, MAX_CHANNEL_GRAY, MAX_CHANNEL_GRAYA>(
  517. dst, dstRowStride, src, srcRowStride, mask, maskRowStride,
  518. rows, cols, opacity, U16Mult(), Uint8ToU16(), U16OpacityTest());
  519. break;
  520. default:
  521. break;
  522. }
  523. }
  524. KisCompositeOpList KisGrayU16ColorSpace::userVisiblecompositeOps() const
  525. {
  526. KisCompositeOpList list;
  527. list.append(KisCompositeOp(COMPOSITE_OVER));
  528. list.append(KisCompositeOp(COMPOSITE_ALPHA_DARKEN));
  529. list.append(KisCompositeOp(COMPOSITE_MULT));
  530. list.append(KisCompositeOp(COMPOSITE_BURN));
  531. list.append(KisCompositeOp(COMPOSITE_DODGE));
  532. list.append(KisCompositeOp(COMPOSITE_DIVIDE));
  533. list.append(KisCompositeOp(COMPOSITE_SCREEN));
  534. list.append(KisCompositeOp(COMPOSITE_OVERLAY));
  535. list.append(KisCompositeOp(COMPOSITE_DARKEN));
  536. list.append(KisCompositeOp(COMPOSITE_LIGHTEN));
  537. return list;
  538. }