Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
c15924fa
Commit
c15924fa
authored
Jan 25, 2017
by
Daniel Crispell
Committed by
Davis E. King
Jan 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for loading of RGBA JPEG images (#409)
parent
0f60ba36
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
jpeg_loader.cpp
dlib/image_loader/jpeg_loader.cpp
+9
-1
jpeg_loader.h
dlib/image_loader/jpeg_loader.h
+9
-1
No files found.
dlib/image_loader/jpeg_loader.cpp
View file @
c15924fa
...
...
@@ -60,6 +60,13 @@ namespace dlib
return
(
output_components_
==
3
);
}
// ----------------------------------------------------------------------------------------
bool
jpeg_loader
::
is_rgba
()
const
{
return
(
output_components_
==
4
);
}
// ----------------------------------------------------------------------------------------
struct
jpeg_loader_error_mgr
...
...
@@ -123,7 +130,8 @@ namespace dlib
output_components_
=
cinfo
.
output_components
;
if
(
output_components_
!=
1
&&
output_components_
!=
3
)
output_components_
!=
3
&&
output_components_
!=
4
)
{
fclose
(
fp
);
jpeg_destroy_decompress
(
&
cinfo
);
...
...
dlib/image_loader/jpeg_loader.h
View file @
c15924fa
...
...
@@ -23,6 +23,7 @@ namespace dlib
bool
is_gray
()
const
;
bool
is_rgb
()
const
;
bool
is_rgba
()
const
;
template
<
typename
T
>
void
get_image
(
T
&
t_
)
const
...
...
@@ -37,7 +38,6 @@ namespace dlib
COMPILE_TIME_ASSERT
(
sizeof
(
T
)
==
0
);
#endif
image_view
<
T
>
t
(
t_
);
t
.
set_size
(
height_
,
width_
);
for
(
unsigned
n
=
0
;
n
<
height_
;
n
++
)
{
...
...
@@ -49,6 +49,14 @@ namespace dlib
unsigned
char
p
=
v
[
m
];
assign_pixel
(
t
[
n
][
m
],
p
);
}
else
if
(
is_rgba
()
)
{
rgb_alpha_pixel
p
;
p
.
red
=
v
[
m
*
4
];
p
.
green
=
v
[
m
*
4
+
1
];
p
.
blue
=
v
[
m
*
4
+
2
];
p
.
alpha
=
v
[
m
*
4
+
3
];
assign_pixel
(
t
[
n
][
m
],
p
);
}
else
// if ( is_rgb() )
{
rgb_pixel
p
;
...
...
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