kis_lazy_fill_tools.h 3.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 *  Copyright (c) 2016 Dmitry Kazakov <dimula73@gmail.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef __KIS_LAZY_FILL_TOOLS_H
#define __KIS_LAZY_FILL_TOOLS_H

#include "kis_types.h"
#include "kritaimage_export.h"
24
#include <KoColor.h>
25

26 27 28
#include <boost/operators.hpp>


29

30
class KoColor;
31 32 33

namespace KisLazyFillTools
{
34 35 36
    KRITAIMAGE_EXPORT
    void normalizeAndInvertAlpha8Device(KisPaintDeviceSP dev, const QRect &rect);

37 38 39
    KRITAIMAGE_EXPORT
    void normalizeAlpha8Device(KisPaintDeviceSP dev, const QRect &rect);

40 41
    /**
     * Uses Boykov-Kolmogorov Max-Flow/Min-Cut algorithm to split the
Yuri Chornoivan's avatar
Yuri Chornoivan committed
42
     * device \p src into two parts. The first part is defined by \p
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
     * colorScribble and the second part --- by \p
     * backgroundScribble. In the result of the split the area defined
     * by \p colorScribble in \p resultDevice is filled with \p
     * color. Also the same area in \p maskDevice is filled with a
     * non-null scribble index.
     *
     * \p maskDevice is used for limiting the area used for filling
     *               the color.
     */
    KRITAIMAGE_EXPORT
    void cutOneWay(const KoColor &color,
                   KisPaintDeviceSP src,
                   KisPaintDeviceSP colorScribble,
                   KisPaintDeviceSP backgroundScribble,
                   KisPaintDeviceSP resultDevice,
58 59
                   KisPaintDeviceSP maskDevice,
                   const QRect &boundingRect);
60 61 62 63 64 65 66 67 68

    /**
     * Returns one pixel from each connected component of \p src.
     *
     * WARNING: \p src is used as a temporary device, so it will be
     *          cleared(!) after the execution of the algorithm
     */

    KRITAIMAGE_EXPORT
69
    QVector<QPoint> splitIntoConnectedComponents(KisPaintDeviceSP src, const QRect &boundingRect);
70

71 72
    struct KRITAIMAGE_EXPORT KeyStroke : public boost::equality_comparable<KeyStroke>
    {
73
        KeyStroke();
74
        KeyStroke(KisPaintDeviceSP _dev, const KoColor &_color, bool isTransparent = false);
75

76 77
        friend bool operator==(const KeyStroke& t1, const KeyStroke&t2);

78 79
        KisPaintDeviceSP dev;
        KoColor color;
80
        bool isTransparent;
81
    };
82 83 84 85 86 87 88 89 90 91 92 93 94 95

    struct KRITAIMAGE_EXPORT FilteringOptions : public boost::equality_comparable<FilteringOptions>
    {
        FilteringOptions() = default;
        FilteringOptions(bool _useEdgeDetection, qreal _edgeDetectionSize, qreal _fuzzyRadius, qreal _cleanUpAmount);

        friend bool operator==(const FilteringOptions &t1, const FilteringOptions &t2);

        // default values for filtering: disabled
        bool useEdgeDetection = false;
        qreal edgeDetectionSize = 4;
        qreal fuzzyRadius = 0;
        qreal cleanUpAmount = 0.0;
    };
Boudewijn Rempt's avatar
Boudewijn Rempt committed
96
}
97 98

#endif /* __KIS_LAZY_FILL_TOOLS_H */