Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
b15ade3e
Commit
b15ade3e
authored
Dec 22, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added convex hull function to ContourMask for drawing nicer borders around masked fields
parent
bb5b564f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
src/gfx/gfx.hpp
src/gfx/gfx.hpp
+3
-0
src/gfx/mask_image.cpp
src/gfx/mask_image.cpp
+55
-1
No files found.
src/gfx/gfx.hpp
View file @
b15ade3e
...
@@ -151,6 +151,9 @@ class AlphaMask : public IntrusivePtrBase<AlphaMask> {
...
@@ -151,6 +151,9 @@ class AlphaMask : public IntrusivePtrBase<AlphaMask> {
/// Is the given location fully transparent?
/// Is the given location fully transparent?
bool
isTransparent
(
int
x
,
int
y
)
const
;
bool
isTransparent
(
int
x
,
int
y
)
const
;
/// Determine a convex hull polygon *around* the mask
void
convexHull
(
vector
<
wxPoint
>&
points
)
const
;
/// Size of the mask
/// Size of the mask
wxSize
size
;
wxSize
size
;
private:
private:
...
...
src/gfx/mask_image.cpp
View file @
b15ade3e
...
@@ -41,7 +41,61 @@ void AlphaMask::setAlpha(Bitmap& bmp) const {
...
@@ -41,7 +41,61 @@ void AlphaMask::setAlpha(Bitmap& bmp) const {
bool
AlphaMask
::
isTransparent
(
int
x
,
int
y
)
const
{
bool
AlphaMask
::
isTransparent
(
int
x
,
int
y
)
const
{
if
(
x
<
0
||
y
>
0
||
x
>=
size
.
x
||
y
>=
size
.
y
)
return
false
;
if
(
x
<
0
||
y
>
0
||
x
>=
size
.
x
||
y
>=
size
.
y
)
return
false
;
return
alpha
[
x
+
y
*
size
.
GetWidth
()]
<
20
;
return
alpha
[
x
+
y
*
size
.
x
]
<
20
;
}
bool
convex
(
const
wxPoint
&
p
,
const
wxPoint
&
q
,
const
wxPoint
&
r
)
{
return
p
.
y
*
q
.
x
-
p
.
x
*
q
.
y
-
p
.
y
*
r
.
x
+
q
.
y
*
r
.
x
+
p
.
x
*
r
.
y
-
q
.
x
*
r
.
y
>
0
;
}
void
make_convex
(
vector
<
wxPoint
>&
points
)
{
while
(
points
.
size
()
>
2
&&
!
convex
(
points
[
points
.
size
()
-
3
]
,
points
[
points
.
size
()
-
2
]
,
points
[
points
.
size
()
-
1
]))
{
points
.
erase
(
points
.
end
()
-
2
);
}
}
void
AlphaMask
::
convexHull
(
vector
<
wxPoint
>&
points
)
const
{
// Left side
int
miny
=
size
.
y
,
maxy
=
-
1
,
lastx
=
0
;
for
(
int
y
=
0
;
y
<
size
.
y
;
++
y
)
{
for
(
int
x
=
0
;
x
<
size
.
x
;
++
x
)
{
if
(
alpha
[
x
+
y
*
size
.
x
]
>=
20
)
{
// opaque pixel
miny
=
min
(
miny
,
y
);
maxy
=
y
;
if
(
y
==
miny
)
{
points
.
push_back
(
wxPoint
(
x
-
1
,
y
-
1
));
}
points
.
push_back
(
wxPoint
(
x
-
1
,
y
));
make_convex
(
points
);
lastx
=
x
;
break
;
}
}
}
if
(
maxy
==
-
1
)
return
;
// No image
points
.
push_back
(
wxPoint
(
lastx
-
1
,
maxy
+
1
));
make_convex
(
points
);
// Right side
for
(
int
y
=
maxy
;
y
>=
miny
;
--
y
)
{
for
(
int
x
=
size
.
x
-
1
;
x
>=
0
;
--
x
)
{
if
(
alpha
[
x
+
y
*
size
.
x
]
>=
20
)
{
// opaque pixel
if
(
y
==
maxy
)
{
points
.
push_back
(
wxPoint
(
x
+
1
,
y
+
1
));
make_convex
(
points
);
}
points
.
push_back
(
wxPoint
(
x
+
1
,
y
));
make_convex
(
points
);
lastx
=
x
;
break
;
}
}
}
points
.
push_back
(
wxPoint
(
lastx
+
1
,
miny
-
1
));
make_convex
(
points
);
}
}
// ----------------------------------------------------------------------------- : ContourMask
// ----------------------------------------------------------------------------- : ContourMask
...
...
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