Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Blackbeard (alberto flores)
Krita
Commits
ebdd8f8c
Commit
ebdd8f8c
authored
Aug 20, 2019
by
Blackbeard (alberto flores)
🚢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert brushTip to MaskImage
parent
0b2ef645
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
2 deletions
+65
-2
libs/brush/KisVectorShapeObject.cpp
libs/brush/KisVectorShapeObject.cpp
+45
-1
libs/brush/KisVectorShapeObject.h
libs/brush/KisVectorShapeObject.h
+6
-0
libs/brush/kis_vectoranimated_brush.cpp
libs/brush/kis_vectoranimated_brush.cpp
+13
-1
libs/brush/kis_vectoranimated_brush.h
libs/brush/kis_vectoranimated_brush.h
+1
-0
No files found.
libs/brush/KisVectorShapeObject.cpp
View file @
ebdd8f8c
...
...
@@ -25,7 +25,7 @@
#include <KoShapePainter.h>
#define DEFAULT_SPACING
5
.0
#define DEFAULT_SPACING
1
.0
KisVectorShapeObject
::
KisVectorShapeObject
(
const
QString
&
filename
)
:
KisScalingSizeBrush
(
filename
)
...
...
@@ -84,6 +84,50 @@ void KisVectorShapeObject::renderImage(int width, int height)
// m_image = theImage;
}
void
KisVectorShapeObject
::
makeMaskImage
()
{
if
(
!
hasColor
())
{
return
;
}
QImage
brushTip
=
brushTipImage
();
if
(
brushTip
.
width
()
==
width
()
&&
brushTip
.
height
()
==
height
())
{
int
imageWidth
=
width
();
int
imageHeight
=
height
();
QImage
image
(
imageWidth
,
imageHeight
,
QImage
::
Format_Indexed8
);
QVector
<
QRgb
>
table
;
for
(
int
i
=
0
;
i
<
256
;
++
i
)
{
table
.
append
(
qRgb
(
i
,
i
,
i
));
}
image
.
setColorTable
(
table
);
for
(
int
y
=
0
;
y
<
imageHeight
;
y
++
)
{
QRgb
*
pixel
=
reinterpret_cast
<
QRgb
*>
(
brushTip
.
scanLine
(
y
));
uchar
*
dstPixel
=
image
.
scanLine
(
y
);
for
(
int
x
=
0
;
x
<
imageWidth
;
x
++
)
{
QRgb
c
=
pixel
[
x
];
float
alpha
=
qAlpha
(
c
)
/
255.0
f
;
// linear interpolation with maximum gray value which is transparent in the mask
//int a = (qGray(c) * alpha) + ((1.0 - alpha) * 255);
// single multiplication version
int
a
=
255
+
alpha
*
(
qGray
(
c
)
-
255
);
dstPixel
[
x
]
=
(
uchar
)
a
;
}
}
setBrushTipImage
(
image
);
}
setHasColor
(
false
);
// setUseColorAsMask(false);
resetBoundary
();
clearBrushPyramid
();
}
enumBrushType
KisVectorShapeObject
::
brushType
()
const
{
return
MASK
;
...
...
libs/brush/KisVectorShapeObject.h
View file @
ebdd8f8c
...
...
@@ -65,6 +65,12 @@ public:
/**
* Convert the mask to inverted gray scale, so it is alpha mask.
* It can be used as MASK brush type. This operates on the date of the brush,
* so it destruct the original brush data
*/
virtual
void
makeMaskImage
();
/**
* @return a preview of the brush
...
...
libs/brush/kis_vectoranimated_brush.cpp
View file @
ebdd8f8c
...
...
@@ -81,6 +81,13 @@ public:
addBrush
(
brush
);
}
void
makeMaskImage
()
{
Q_FOREACH
(
KisVectorShapeObject
*
brush
,
m_brushes
)
{
brush
->
makeMaskImage
();
}
}
private:
int
m_currentIndex
;
KisVectorBrushParasite
m_parasite
;
...
...
@@ -117,7 +124,7 @@ KisVectorAnimatedBrush::~KisVectorAnimatedBrush()
enumBrushType
KisVectorAnimatedBrush
::
brushType
()
const
{
return
PIPE_IMAGE
;
return
MASK
;
}
KisBrush
*
KisVectorAnimatedBrush
::
clone
()
const
...
...
@@ -305,3 +312,8 @@ KisFixedPaintDeviceSP KisVectorAnimatedBrush::paintDevice(
return
m_d
->
brushesPipe
.
paintDevice
(
colorSpace
,
shape
,
info
,
subPixelX
,
subPixelY
);
}
void
KisVectorAnimatedBrush
::
makeMaskImage
()
{
m_d
->
brushesPipe
.
makeMaskImage
();
// setUseColorAsMask(false);
}
libs/brush/kis_vectoranimated_brush.h
View file @
ebdd8f8c
...
...
@@ -74,6 +74,7 @@ public:
const
KisPaintInformation
&
info
,
double
subPixelX
=
0
,
double
subPixelY
=
0
)
const
override
;
void
makeMaskImage
()
override
;
private:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment