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
d30340bd
Commit
d30340bd
authored
Dec 24, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hack to fix completely transparent images
parent
85eae645
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
21 deletions
+25
-21
src/gfx/resample_image.cpp
src/gfx/resample_image.cpp
+4
-21
src/gui/value/choice.cpp
src/gui/value/choice.cpp
+21
-0
No files found.
src/gfx/resample_image.cpp
View file @
d30340bd
...
@@ -141,28 +141,10 @@ void resample_and_clip(const Image& img_in, Image& img_out, wxRect rect) {
...
@@ -141,28 +141,10 @@ void resample_and_clip(const Image& img_in, Image& img_out, wxRect rect) {
// ----------------------------------------------------------------------------- : Aspect ratio preserving
// ----------------------------------------------------------------------------- : Aspect ratio preserving
// fill an image with 100% transparent
, except for the given rectangle
// fill an image with 100% transparent
void
fill_transparent
(
Image
&
img
,
int
dx
,
int
dy
,
int
w
,
int
h
)
{
void
fill_transparent
(
Image
&
img
)
{
if
(
!
img
.
HasAlpha
())
img
.
InitAlpha
();
if
(
!
img
.
HasAlpha
())
img
.
InitAlpha
();
memset
(
img
.
GetAlpha
(),
0
,
img
.
GetWidth
()
*
img
.
GetHeight
());
memset
(
img
.
GetAlpha
(),
0
,
img
.
GetWidth
()
*
img
.
GetHeight
());
/*/?
int iw = img.GetWidth(), ih = img.GetHeight();
Byte* data = img.GetAlpha();
// fill
int y = 0;
for (; y < dy ; ++y) {
for (int x = 0 ; x < iw ; ++x) *data++ = 0;
}
for (; y < dy + h ; ++y) {
int x = 0;
for (; x < dx ; ++x) *data++ = 0;
for (; x < dx + w ; ++x) *data++ = 255;
for (; x < iw ; ++x) *data++ = 0;
}
for (; y < ih ; ++y) {
for (int x = 0 ; x < iw ; ++x) *data++ = 0;
}
*/
}
}
void
resample_preserve_aspect
(
const
Image
&
img_in
,
Image
&
img_out
)
{
void
resample_preserve_aspect
(
const
Image
&
img_in
,
Image
&
img_out
)
{
...
@@ -175,10 +157,11 @@ void resample_preserve_aspect(const Image& img_in, Image& img_out) {
...
@@ -175,10 +157,11 @@ void resample_preserve_aspect(const Image& img_in, Image& img_out) {
int
dx
=
(
img_out
.
GetWidth
()
-
rwidth
)
/
2
;
int
dx
=
(
img_out
.
GetWidth
()
-
rwidth
)
/
2
;
int
dy
=
(
img_out
.
GetHeight
()
-
rheight
)
/
2
;
int
dy
=
(
img_out
.
GetHeight
()
-
rheight
)
/
2
;
// transparent background
// transparent background
fill_transparent
(
img_out
,
dx
,
dy
,
rwidth
,
rheight
);
fill_transparent
(
img_out
);
// resample
// resample
int
offset_out
=
dx
+
img_out
.
GetWidth
()
*
dy
;
int
offset_out
=
dx
+
img_out
.
GetWidth
()
*
dy
;
Image
img_temp
(
rwidth
,
img_in
.
GetHeight
(),
false
);
Image
img_temp
(
rwidth
,
img_in
.
GetHeight
(),
false
);
img_temp
.
InitAlpha
();
resample_pass
(
img_in
,
img_temp
,
0
,
0
,
img_in
.
GetWidth
(),
1
,
rwidth
,
1
,
img_in
.
GetHeight
(),
img_in
.
GetWidth
(),
img_temp
.
GetWidth
());
resample_pass
(
img_in
,
img_temp
,
0
,
0
,
img_in
.
GetWidth
(),
1
,
rwidth
,
1
,
img_in
.
GetHeight
(),
img_in
.
GetWidth
(),
img_temp
.
GetWidth
());
resample_pass
(
img_temp
,
img_out
,
0
,
offset_out
,
img_in
.
GetHeight
(),
img_temp
.
GetWidth
(),
rheight
,
img_out
.
GetWidth
(),
rwidth
,
1
,
1
);
resample_pass
(
img_temp
,
img_out
,
0
,
offset_out
,
img_in
.
GetHeight
(),
img_temp
.
GetWidth
(),
rheight
,
img_out
.
GetWidth
(),
rwidth
,
1
,
1
);
}
}
src/gui/value/choice.cpp
View file @
d30340bd
...
@@ -51,6 +51,27 @@ void ChoiceThumbnailRequest::store(const Image& img) {
...
@@ -51,6 +51,27 @@ void ChoiceThumbnailRequest::store(const Image& img) {
il
->
Add
(
wxBitmap
(
16
,
16
),
*
wxBLACK
);
il
->
Add
(
wxBitmap
(
16
,
16
),
*
wxBLACK
);
}
}
if
(
img
.
Ok
())
{
if
(
img
.
Ok
())
{
#ifdef __WXMSW__
// for some reason windows doesn't like completely transparent images if they do not have a mask
// HACK:
if
(
img
.
GetWidth
()
==
16
&&
img
.
GetHeight
()
==
16
)
{
// is the image empty?
bool
empty
=
true
;
int
*
b
=
(
int
*
)
img
.
GetAlpha
();
int
*
e
=
b
+
16
*
16
/
sizeof
(
int
);
while
(
b
!=
e
)
{
if
(
*
b
++
)
{
empty
=
false
;
break
;
}
}
// if so, use a mask instead
if
(
empty
)
{
const_cast
<
Image
&>
(
img
).
ConvertAlphaToMask
();
}
}
// Hack ends here
#endif
if
(
id
==
il
->
GetImageCount
())
{
if
(
id
==
il
->
GetImageCount
())
{
il
->
Add
(
img
);
il
->
Add
(
img
);
}
else
{
}
else
{
...
...
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