/* * SPDX-FileCopyrightText: 1999 Matthias Elter * SPDX-FileCopyrightText: 2002 Patrick Julien * SPDX-FileCopyrightText: 2004 Boudewijn Rempt * * SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef KIS_GBR_BRUSH_ #define KIS_GBR_BRUSH_ #include #include "KisColorfulBrush.h" #include #include #include #include "kritabrush_export.h" class KisQImagemask; typedef KisSharedPtr KisQImagemaskSP; class QString; class QIODevice; class BRUSH_EXPORT KisGbrBrush : public KisColorfulBrush { protected: public: /// Construct brush to load filename later as brush KisGbrBrush(const QString& filename); /// Load brush from the specified data, at position dataPos, and set the filename KisGbrBrush(const QString& filename, const QByteArray & data, qint32 & dataPos); /// Load brush from the specified paint device, in the specified region KisGbrBrush(KisPaintDeviceSP image, int x, int y, int w, int h); /// Load brush as a copy from the specified QImage (handy when you need to copy a brush!) KisGbrBrush(const QImage& image, const QString& name = QString()); ~KisGbrBrush() override; KisGbrBrush(const KisGbrBrush& rhs); KoResourceSP clone() const override; KisGbrBrush &operator=(const KisGbrBrush &rhs); bool loadFromDevice(QIODevice *dev, KisResourcesInterfaceSP resourcesInterface) override; bool saveToDevice(QIODevice* dev) const override; QPair resourceType() const override { return QPair(ResourceType::Brushes, ResourceSubType::GbrBrushes); } /** * Convert the mask to inverted gray scale, so it is alpha mask. * It can be used as MASK brush type. This operates on the data of the brush, * so it destruct the original brush data. * * @param preserveAlpha convert to grayscale, but save as full RGBA format, to allow * preserving lightness option */ virtual void makeMaskImage(bool preserveAlpha); /** * @return default file extension for saving the brush */ QString defaultFileExtension() const override; protected: /** * save the content of this brush to an IO device */ friend class KisImageBrushesPipe; friend class KisBrushExport; void setBrushTipImage(const QImage& image) override; void toXML(QDomDocument& d, QDomElement& e) const override; private: bool init(); bool initFromPaintDev(KisPaintDeviceSP image, int x, int y, int w, int h); struct Private; Private* const d; }; typedef QSharedPointer KisGbrBrushSP; #endif // KIS_GBR_BRUSH_