summaryrefslogtreecommitdiffstats
path: root/chalk/doc/colorstrategyAPI
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
commit698569f8428ca088f764d704034a1330517b98c0 (patch)
treebf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /chalk/doc/colorstrategyAPI
parent2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff)
downloadkoffice-698569f8428ca088f764d704034a1330517b98c0.tar.gz
koffice-698569f8428ca088f764d704034a1330517b98c0.zip
Finish rebranding of Krita as Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'chalk/doc/colorstrategyAPI')
-rw-r--r--chalk/doc/colorstrategyAPI58
1 files changed, 58 insertions, 0 deletions
diff --git a/chalk/doc/colorstrategyAPI b/chalk/doc/colorstrategyAPI
new file mode 100644
index 00000000..07c95ae9
--- /dev/null
+++ b/chalk/doc/colorstrategyAPI
@@ -0,0 +1,58 @@
+This is a working document. It list the places where pixels are mangled and requested functions to do it in an colorstrategy independent way
+
+The purpose is to find out which functions an API in colorstrategy must have to support pixelmangling in a colorstretegy independent manner.
+
+
+Requested function: apply an alpha tqmask to pixels
+Problem: alpha is hard-coded 8-bit in KisPixel, when it should be free
+
+void KisPaintDevice::clearSelection()
+{
+ if (!hasSelection()) return;
+
+ QRect r = m_selection -> selectedRect();
+ r = r.normalize();
+
+ for (Q_INT32 y = 0; y < r.height(); y++) {
+ KisHLineIterator devIt = createHLineIterator(r.x(), r.y() + y, r.width(), true);
+ KisHLineIterator selectionIt = m_selection -> createHLineIterator(r.x(), r.y() + y, r.width(), false);
+
+ while (!devIt.isDone()) {
+ KisPixel p = toPixel(devIt.rawData());
+ KisPixel s = m_selection -> toPixel(selectionIt.rawData());
+ // XXX: Why Q_UIN16 here? Doesn't that clash with UINT8_MULT later on?
+ Q_UINT16 p_alpha, s_alpha;
+ p_alpha = p.alpha();
+ s_alpha = MAX_SELECTED - s.alpha();
+
+ p.alpha() = UINT8_MULT(p_alpha, s_alpha);
+
+ ++devIt;
+ ++selectionIt;
+ }
+ }
+}
+
+void KisPaintDevice::applySelectionMask(KisSelectionSP tqmask)
+{
+ QRect r = tqmask -> extent();
+ crop(r);
+
+ for (Q_INT32 y = r.top(); y <= r.bottom(); ++y) {
+
+ KisHLineIterator pixelIt = createHLineIterator(r.x(), y, r.width(), true);
+ KisHLineIterator tqmaskIt = tqmask -> createHLineIterator(r.x(), y, r.width(), false);
+
+ while (!pixelIt.isDone()) {
+
+ KisPixel pixel = toPixel(pixelIt.rawData());
+ KisPixel tqmaskValue = tqmask -> toPixel(tqmaskIt.rawData());
+
+ pixel.alpha() = (pixel.alpha() * tqmaskValue.alpha()) / MAX_SELECTED;
+
+ ++pixelIt;
+ ++tqmaskIt;
+ }
+ }
+}
+