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
161efd59
Commit
161efd59
authored
Dec 20, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AlphaMask combines alphas instead of overwriting
parent
68aac879
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
5 deletions
+25
-5
src/gfx/blend_image.cpp
src/gfx/blend_image.cpp
+18
-0
src/gfx/gfx.hpp
src/gfx/gfx.hpp
+2
-0
src/gfx/mask_image.cpp
src/gfx/mask_image.cpp
+1
-5
src/gfx/resample_image.cpp
src/gfx/resample_image.cpp
+4
-0
No files found.
src/gfx/blend_image.cpp
View file @
161efd59
...
@@ -87,6 +87,24 @@ void set_alpha(Image& img, const Image& img_alpha) {
...
@@ -87,6 +87,24 @@ void set_alpha(Image& img, const Image& img_alpha) {
}
}
}
}
void
set_alpha
(
Image
&
img
,
Byte
*
al
,
const
wxSize
&
alpha_size
)
{
if
(
img
.
GetWidth
()
!=
alpha_size
.
GetWidth
()
||
img
.
GetHeight
()
!=
alpha_size
.
GetHeight
())
{
throw
Error
(
_
(
"Image must have same size as mask"
));
}
if
(
!
img
.
HasAlpha
())
{
// copy
img
.
InitAlpha
();
memcpy
(
img
.
GetAlpha
(),
al
,
img
.
GetWidth
()
*
img
.
GetHeight
());
}
else
{
// merge
Byte
*
im
=
img
.
GetAlpha
();
size_t
size
=
img
.
GetWidth
()
*
img
.
GetHeight
();
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
im
[
i
]
=
(
im
[
i
]
*
al
[
i
])
/
255
;
}
}
}
void
set_alpha
(
Image
&
img
,
double
alpha
)
{
void
set_alpha
(
Image
&
img
,
double
alpha
)
{
Byte
b_alpha
=
alpha
*
255
;
Byte
b_alpha
=
alpha
*
255
;
if
(
!
img
.
HasAlpha
())
{
if
(
!
img
.
HasAlpha
())
{
...
...
src/gfx/gfx.hpp
View file @
161efd59
...
@@ -130,6 +130,8 @@ void draw_combine_image(DC& dc, UInt x, UInt y, const Image& img, ImageCombine c
...
@@ -130,6 +130,8 @@ void draw_combine_image(DC& dc, UInt x, UInt y, const Image& img, ImageCombine c
/// Use the red channel of img_alpha as alpha channel for img
/// Use the red channel of img_alpha as alpha channel for img
void
set_alpha
(
Image
&
img
,
const
Image
&
img_alpha
);
void
set_alpha
(
Image
&
img
,
const
Image
&
img_alpha
);
/// Use the given bytes as alpha channel for img
void
set_alpha
(
Image
&
img
,
Byte
*
alphas
,
const
wxSize
&
alphas_size
);
/// Set the transparency of img
/// Set the transparency of img
void
set_alpha
(
Image
&
img
,
double
alpha
);
void
set_alpha
(
Image
&
img
,
double
alpha
);
...
...
src/gfx/mask_image.cpp
View file @
161efd59
...
@@ -30,11 +30,7 @@ AlphaMask::~AlphaMask() {
...
@@ -30,11 +30,7 @@ AlphaMask::~AlphaMask() {
}
}
void
AlphaMask
::
setAlpha
(
Image
&
img
)
const
{
void
AlphaMask
::
setAlpha
(
Image
&
img
)
const
{
if
(
img
.
GetWidth
()
!=
size
.
GetWidth
()
||
img
.
GetHeight
()
!=
size
.
GetHeight
())
{
set_alpha
(
img
,
alpha
,
size
);
throw
InternalError
(
_
(
"Image used with maks must have same size as mask"
));
}
if
(
!
img
.
HasAlpha
())
img
.
InitAlpha
();
memcpy
(
img
.
GetAlpha
(),
alpha
,
size
.
GetWidth
()
*
size
.
GetHeight
());
}
}
void
AlphaMask
::
setAlpha
(
Bitmap
&
bmp
)
const
{
void
AlphaMask
::
setAlpha
(
Bitmap
&
bmp
)
const
{
...
...
src/gfx/resample_image.cpp
View file @
161efd59
...
@@ -126,6 +126,10 @@ void resample(const Image& img_in, Image& img_out) {
...
@@ -126,6 +126,10 @@ void resample(const Image& img_in, Image& img_out) {
}
}
void
resample_and_clip
(
const
Image
&
img_in
,
Image
&
img_out
,
wxRect
rect
)
{
void
resample_and_clip
(
const
Image
&
img_in
,
Image
&
img_out
,
wxRect
rect
)
{
// mask to alpha
if
(
img_in
.
HasMask
()
&&
!
img_in
.
HasAlpha
())
{
const_cast
<
Image
&>
(
img_in
).
InitAlpha
();
}
// starting position in data
// starting position in data
int
offset_in
=
(
rect
.
x
+
img_in
.
GetWidth
()
*
rect
.
y
);
int
offset_in
=
(
rect
.
x
+
img_in
.
GetWidth
()
*
rect
.
y
);
if
(
img_out
.
GetHeight
()
==
rect
.
height
)
{
if
(
img_out
.
GetHeight
()
==
rect
.
height
)
{
...
...
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