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.

59 lines
1.7KB

  1. This is a working document. It list the places where pixels are mangled and requested functions to do it in an colorstrategy independent way
  2. The purpose is to find out which functions an API in colorstrategy must have to support pixelmangling in a colorstretegy independent manner.
  3. Requested function: apply an alpha mask to pixels
  4. Problem: alpha is hard-coded 8-bit in KisPixel, when it should be free
  5. void KisPaintDevice::clearSelection()
  6. {
  7. if (!hasSelection()) return;
  8. QRect r = m_selection -> selectedRect();
  9. r = r.normalize();
  10. for (Q_INT32 y = 0; y < r.height(); y++) {
  11. KisHLineIterator devIt = createHLineIterator(r.x(), r.y() + y, r.width(), true);
  12. KisHLineIterator selectionIt = m_selection -> createHLineIterator(r.x(), r.y() + y, r.width(), false);
  13. while (!devIt.isDone()) {
  14. KisPixel p = toPixel(devIt.rawData());
  15. KisPixel s = m_selection -> toPixel(selectionIt.rawData());
  16. // XXX: Why Q_UIN16 here? Doesn't that clash with UINT8_MULT later on?
  17. Q_UINT16 p_alpha, s_alpha;
  18. p_alpha = p.alpha();
  19. s_alpha = MAX_SELECTED - s.alpha();
  20. p.alpha() = UINT8_MULT(p_alpha, s_alpha);
  21. ++devIt;
  22. ++selectionIt;
  23. }
  24. }
  25. }
  26. void KisPaintDevice::applySelectionMask(KisSelectionSP mask)
  27. {
  28. QRect r = mask -> extent();
  29. crop(r);
  30. for (Q_INT32 y = r.top(); y <= r.bottom(); ++y) {
  31. KisHLineIterator pixelIt = createHLineIterator(r.x(), y, r.width(), true);
  32. KisHLineIterator maskIt = mask -> createHLineIterator(r.x(), y, r.width(), false);
  33. while (!pixelIt.isDone()) {
  34. KisPixel pixel = toPixel(pixelIt.rawData());
  35. KisPixel maskValue = mask -> toPixel(maskIt.rawData());
  36. pixel.alpha() = (pixel.alpha() * maskValue.alpha()) / MAX_SELECTED;
  37. ++pixelIt;
  38. ++maskIt;
  39. }
  40. }
  41. }