13#include <libmypaint/mypaint-brush.h>
38 d->
brush = mypaint_brush_new();
39 mypaint_brush_from_defaults(
d->
brush);
46 d->
brush = mypaint_brush_new();
48 if (
d->
json.isEmpty()) {
49 mypaint_brush_from_defaults(
d->
brush);
57 mypaint_brush_unref(
d->
brush);
68 float hue, saturation,
value;
69#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
70 qreal r = 0, g = 0, b = 0;
72 float r = 0, g = 0, b = 0;
78 dstColor.getRgbF(&r, &g, &b);
83 mypaint_brush_set_base_value(
d->
brush, MYPAINT_BRUSH_SETTING_COLOR_H, (hue)/360);
84 mypaint_brush_set_base_value(
d->
brush, MYPAINT_BRUSH_SETTING_COLOR_S, (saturation));
85 mypaint_brush_set_base_value(
d->
brush, MYPAINT_BRUSH_SETTING_COLOR_V, (
value));
91 mypaint_brush_from_defaults(
d->
brush);
95 mypaint_brush_from_string(
d->
brush, ba);
98 mypaint_brush_new_stroke(
d->
brush);
108 if (!dev->isSequential())
112 dev->peek(
reinterpret_cast<char*
>(
signature.data()), 8);
114#if PNG_LIBPNG_VER < 10400
117 if (png_sig_cmp(
signature.data(), 0, 8) == 0) {
124 if (f.endsWith(
".myb", Qt::CaseInsensitive)) {
129 warnPlugins <<
"Failed loading MyPaint preset from KoResource serialization";
134 const QByteArray ba(dev->readAll());
139 bool success = mypaint_brush_from_string(
d->
brush, ba);
140 const float isEraser = mypaint_brush_get_base_value(
d->
brush, MYPAINT_BRUSH_SETTING_ERASER);
143 s->setProperty(
"paintop",
"mypaintbrush");
144 s->setProperty(
"filename", this->
filename());
146 s->setProperty(
"EraserMode", qRound(isEraser));
169 if (!
metadata().contains(
"paintopid")) {
187 return QFileInfo(
filename()).baseName() +
"_prev.png";
float value(const T *src, size_t ch)
void RGBToHSV(float r, float g, float b, float *h, float *s, float *v)
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
const QString MYPAINT_JSON
void apply(KisPaintOpSettingsSP settings)
bool loadFromDevice(QIODevice *dev, KisResourcesInterfaceSP resourcesInterface) override
void updateThumbnail() override
updateThumbnail updates the thumbnail for this resource. Reimplement if your thumbnail is something e...
KoResourceSP clone() const override
void setColor(const KoColor color, const KoColorSpace *colorSpace)
virtual ~KisMyPaintPaintOpPreset()
KisMyPaintPaintOpPreset(const QString &fileName="")
QString thumbnailPath() const override
thumbnailPath returns the path to a separate thumbnail image, outside the actual resource file itself...
virtual void toQColor(const quint8 *src, QColor *c) const =0
virtual KoID colorModelId() const =0
QSharedPointer< T > toQShared(T *ptr)
KisResourcesInterfaceSP resourcesInterface() const
QString defaultFileExtension() const override
bool loadFromDevice(QIODevice *dev, KisResourcesInterfaceSP resourcesInterface) override
void setSettings(KisPaintOpSettingsSP settings)
replace the current settings object with the specified settings
KisPaintOpSettingsSP settings
void setValid(bool valid)
void setName(const QString &name)
void addMetaData(QString key, QVariant value)
store the given key, value pair in the resource
void setFilename(const QString &filename)
QMap< QString, QVariant > metadata
KoResourceSignature signature() const
virtual QImage thumbnail() const
thumbnail the thumbnail image to use in resource selectors