Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.io.image
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.io.image
Commits
53a52d1f
Commit
53a52d1f
authored
8 years ago
by
Manuel Günther
Browse files
Options
Downloads
Patches
Plain Diff
Handled tRNS color palette for PNG images (was crashing before)
parent
10a67d72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/io/image/cpp/png.cpp
+7
-0
7 additions, 0 deletions
bob/io/image/cpp/png.cpp
with
7 additions
and
0 deletions
bob/io/image/cpp/png.cpp
+
7
−
0
View file @
53a52d1f
...
...
@@ -256,6 +256,7 @@ static void im_load(const std::string& filename, bob::io::base::array::interface
png_set_expand_gray_1_2_4_to_8
(
png_ptr
);
else
if
(
color_type
==
PNG_COLOR_TYPE_PALETTE
)
png_set_palette_to_rgb
(
png_ptr
);
// We currently only support grayscale and rgb images
if
(
color_type
!=
PNG_COLOR_TYPE_GRAY
&&
color_type
!=
PNG_COLOR_TYPE_RGB
&&
...
...
@@ -267,6 +268,12 @@ static void im_load(const std::string& filename, bob::io::base::array::interface
// 7. Read content
const
bob
::
io
::
base
::
array
::
typeinfo
&
info
=
b
.
type
();
bool
has_alpha
=
(
color_type
&
PNG_COLOR_MASK_ALPHA
)
==
PNG_COLOR_MASK_ALPHA
;
// Handle tRNS color type
if
(
png_get_valid
(
png_ptr
,
info_ptr
,
PNG_INFO_tRNS
)){
// old tRNS structure, with 8 bit palette including alpha channel
png_set_tRNS_to_alpha
(
png_ptr
);
has_alpha
=
true
;
}
if
(
info
.
dtype
==
bob
::
io
::
base
::
array
::
t_uint8
)
{
if
(
info
.
nd
==
2
)
im_load_gray
<
uint8_t
>
(
png_ptr
,
b
);
else
if
(
info
.
nd
==
3
)
im_load_color
<
uint8_t
>
(
png_ptr
,
b
,
has_alpha
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment