1 /* 2 * Copyright (c) 2016 Dmitry Kazakov <dimula73@gmail.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __KIS_LAZY_FILL_TOOLS_H 20 #define __KIS_LAZY_FILL_TOOLS_H 21 22 #include "kis_types.h" 23 #include "kritaimage_export.h" 24 #include <KoColor.h> 25 26 #include <boost/operators.hpp> 27 28 29 30 class KoColor; 31 32 namespace KisLazyFillTools 33 { 34 KRITAIMAGE_EXPORT 35 void normalizeAndInvertAlpha8Device(KisPaintDeviceSP dev, const QRect &rect); 36 37 KRITAIMAGE_EXPORT 38 void normalizeAlpha8Device(KisPaintDeviceSP dev, const QRect &rect); 39 40 /** 41 * Uses Boykov-Kolmogorov Max-Flow/Min-Cut algorithm to split the 42 * device \p src into two parts. The first part is defined by \p 43 * colorScribble and the second part --- by \p 44 * backgroundScribble. In the result of the split the area defined 45 * by \p colorScribble in \p resultDevice is filled with \p 46 * color. Also the same area in \p maskDevice is filled with a 47 * non-null scribble index. 48 * 49 * \p maskDevice is used for limiting the area used for filling 50 * the color. 51 */ 52 KRITAIMAGE_EXPORT 53 void cutOneWay(const KoColor &color, 54 KisPaintDeviceSP src, 55 KisPaintDeviceSP colorScribble, 56 KisPaintDeviceSP backgroundScribble, 57 KisPaintDeviceSP resultDevice, 58 KisPaintDeviceSP maskDevice, 59 const QRect &boundingRect); 60 61 /** 62 * Returns one pixel from each connected component of \p src. 63 * 64 * WARNING: \p src is used as a temporary device, so it will be 65 * cleared(!) after the execution of the algorithm 66 */ 67 68 KRITAIMAGE_EXPORT 69 QVector<QPoint> splitIntoConnectedComponents(KisPaintDeviceSP src, const QRect &boundingRect); 70 71 struct KRITAIMAGE_EXPORT KeyStroke : public boost::equality_comparable<KeyStroke> 72 { 73 KeyStroke(); 74 KeyStroke(KisPaintDeviceSP _dev, const KoColor &_color, bool isTransparent = false); 75 76 friend bool operator==(const KeyStroke& t1, const KeyStroke&t2); 77 78 KisPaintDeviceSP dev; 79 KoColor color; 80 bool isTransparent; 81 }; 82 83 struct KRITAIMAGE_EXPORT FilteringOptions : public boost::equality_comparable<FilteringOptions> 84 { 85 FilteringOptions() = default; 86 FilteringOptions(bool _useEdgeDetection, qreal _edgeDetectionSize, qreal _fuzzyRadius, qreal _cleanUpAmount); 87 88 friend bool operator==(const FilteringOptions &t1, const FilteringOptions &t2); 89 90 // default values for filtering: disabled 91 bool useEdgeDetection = false; 92 qreal edgeDetectionSize = 4; 93 qreal fuzzyRadius = 0; 94 qreal cleanUpAmount = 0.0; 95 }; 96 } 97 98 #endif /* __KIS_LAZY_FILL_TOOLS_H */ 99