21#include "kis_colorspace.h"
22#include "kis_iterators_pixel.h"
23#include "kis_paint_device.h"
24#include "kis_boundary.h"
28 m_fuzzyness = 255 / 2;
31bool KisBoundary::isDark(TQ_UINT8 val) {
32 return val < m_fuzzyness;
35void KisBoundary::generateBoundary(
int w,
int h) {
39 KisColorSpace* cs = m_device->colorSpace();
42 for (
int currentY = - 1; currentY < h; currentY++) {
43 KisHLineIteratorPixel topIt = m_device->createHLineIterator(0, currentY, w,
false);
44 KisHLineIteratorPixel botIt = m_device->createHLineIterator(0, currentY + 1, w,
false);
48 m_horSegments.append(TQValueList<PointPair>());
50 while (!topIt.isDone()) {
51 darkTop = cs->
getAlpha(topIt.rawData());
52 darkBot = cs->
getAlpha(botIt.rawData());
53 if (darkTop != darkBot) {
55 m_horSegments.back().append(qMakePair(KisPoint(botIt.x(), botIt.y()), 1));
63 for (
int currentX = - 1; currentX < w; currentX++) {
64 KisVLineIteratorPixel leftIt = m_device->createVLineIterator(currentX, 0, h,
false);
65 KisVLineIteratorPixel rightIt = m_device->createVLineIterator(currentX + 1, 0, h,
false);
69 m_vertSegments.append(TQValueList<PointPair>());
71 while (!leftIt.isDone()) {
72 darkLeft = cs->
getAlpha(leftIt.rawData());
73 darkRight = cs->
getAlpha(rightIt.rawData());
74 if (darkLeft != darkRight) {
76 m_vertSegments.back().append(qMakePair(KisPoint(rightIt.x(), rightIt.y()), 1));
virtual TQ_UINT8 getAlpha(const TQ_UINT8 *pixel) const =0
Get the alpha value of the given pixel, downscaled to an 8-bit value.
A paint device contains the actual pixel data and offers methods to read and write pixels.