Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.io.image
Commits
288b4f97
Commit
288b4f97
authored
Sep 29, 2016
by
Manuel Günther
Browse files
Added way of reading and writing 16-bit png images; still no tests
parent
9fffd374
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/io/image/cpp/png.cpp
View file @
288b4f97
...
...
@@ -159,6 +159,22 @@ void imbuffer_to_rgb(const size_t size, const T* im, T* r, T* g, T* b)
}
}
static
uint16_t
switch_endianess
(
const
uint16_t
p
){
return
p
/
256
+
p
%
256
*
256
;
}
template
<
>
void
imbuffer_to_rgb
(
const
size_t
size
,
const
uint16_t
*
im
,
uint16_t
*
r
,
uint16_t
*
g
,
uint16_t
*
b
)
{
for
(
size_t
k
=
0
;
k
<
size
;
++
k
)
{
*
r
++
=
switch_endianess
(
*
im
++
);
*
g
++
=
switch_endianess
(
*
im
++
);
*
b
++
=
switch_endianess
(
*
im
++
);
}
}
template
<
typename
T
>
static
void
im_load_color
(
png_structp
png_ptr
,
bob
::
io
::
base
::
array
::
interface
&
b
)
{
...
...
@@ -330,6 +346,18 @@ void rgb_to_imbuffer(const size_t size, const T* r, const T* g, const T* b, T* i
}
}
template
<
>
void
rgb_to_imbuffer
(
const
size_t
size
,
const
uint16_t
*
r
,
const
uint16_t
*
g
,
const
uint16_t
*
b
,
uint16_t
*
im
)
{
for
(
size_t
k
=
0
;
k
<
size
;
++
k
)
{
*
im
++
=
switch_endianess
(
*
r
++
);
*
im
++
=
switch_endianess
(
*
g
++
);
*
im
++
=
switch_endianess
(
*
b
++
);
}
}
template
<
typename
T
>
static
void
im_save_color
(
const
bob
::
io
::
base
::
array
::
interface
&
b
,
png_structp
png_ptr
)
{
...
...
bob/io/image/include/bob.io.image/png.h
View file @
288b4f97
...
...
@@ -96,7 +96,7 @@ namespace bob { namespace io { namespace image {
template
<
class
T
,
int
N
>
blitz
::
Array
<
T
,
N
>
read_png
(
const
std
::
string
&
filename
){
PNGFile
png
(
filename
.
c_str
(),
'r'
);
return
png
.
read
<
T
,
N
>
(
0
);
return
png
.
cast
<
T
,
N
>
(
0
);
}
template
<
class
T
,
int
N
>
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment