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
288b4f97
Commit
288b4f97
authored
8 years ago
by
Manuel Günther
Browse files
Options
Downloads
Patches
Plain Diff
Added way of reading and writing 16-bit png images; still no tests
parent
9fffd374
Branches
Branches containing commit
No related tags found
1 merge request
!21
Resolve "16 bit PNG images are stored as big endian"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/io/image/cpp/png.cpp
+28
-0
28 additions, 0 deletions
bob/io/image/cpp/png.cpp
bob/io/image/include/bob.io.image/png.h
+1
-1
1 addition, 1 deletion
bob/io/image/include/bob.io.image/png.h
with
29 additions
and
1 deletion
bob/io/image/cpp/png.cpp
+
28
−
0
View file @
288b4f97
...
@@ -159,6 +159,22 @@ void imbuffer_to_rgb(const size_t size, const T* im, T* r, T* g, T* b)
...
@@ -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
template
<
typename
T
>
static
void
im_load_color
(
png_structp
png_ptr
,
bob
::
io
::
base
::
array
::
interface
&
b
)
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
...
@@ -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
>
template
<
typename
T
>
static
void
im_save_color
(
const
bob
::
io
::
base
::
array
::
interface
&
b
,
png_structp
png_ptr
)
static
void
im_save_color
(
const
bob
::
io
::
base
::
array
::
interface
&
b
,
png_structp
png_ptr
)
{
{
...
...
This diff is collapsed.
Click to expand it.
bob/io/image/include/bob.io.image/png.h
+
1
−
1
View file @
288b4f97
...
@@ -96,7 +96,7 @@ namespace bob { namespace io { namespace image {
...
@@ -96,7 +96,7 @@ namespace bob { namespace io { namespace image {
template
<
class
T
,
int
N
>
template
<
class
T
,
int
N
>
blitz
::
Array
<
T
,
N
>
read_png
(
const
std
::
string
&
filename
){
blitz
::
Array
<
T
,
N
>
read_png
(
const
std
::
string
&
filename
){
PNGFile
png
(
filename
.
c_str
(),
'r'
);
PNGFile
png
(
filename
.
c_str
(),
'r'
);
return
png
.
read
<
T
,
N
>
(
0
);
return
png
.
cast
<
T
,
N
>
(
0
);
}
}
template
<
class
T
,
int
N
>
template
<
class
T
,
int
N
>
...
...
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