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
MPI-Dortmund
sphire
eman2mirror
Commits
8bdadce9
Commit
8bdadce9
authored
Jun 04, 2022
by
shadow_walker
Browse files
new scaling in png
parent
a73d9bb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
libEM/io/pngio.cpp
View file @
8bdadce9
...
...
@@ -390,20 +390,12 @@ int PngIO::write_data(float *data, int image_index, const Region*,
/**Flip the image vertically, since EMAN use top-left corner as image origin
* But PNG use bottom-left corner as image origin */
if
(
depth_type
==
PNG_CHAR_DEPTH
)
{
auto
[
rendered_data
,
count
]
=
getRenderedDataAndRendertrunc
<
unsigned
char
>
(
data
,
nx
*
ny
);
unsigned
char
*
cdata
=
new
unsigned
char
[
nx
];
for
(
int
y
=
(
int
)
ny
-
1
;
y
>=
0
;
y
--
)
{
for
(
int
x
=
0
;
x
<
(
int
)
nx
;
x
++
)
{
if
(
data
[
y
*
nx
+
x
]
<=
rendermin
){
cdata
[
x
]
=
0
;
}
else
if
(
data
[
y
*
nx
+
x
]
>=
rendermax
)
{
cdata
[
x
]
=
UCHAR_MAX
;
}
else
{
cdata
[
x
]
=
(
unsigned
char
)((
data
[
y
*
nx
+
x
]
-
rendermin
)
/
(
rendermax
-
rendermin
)
*
256
);
}
cdata
[
x
]
=
(
unsigned
char
)
rendered_data
[
y
*
nx
+
x
];
}
png_write_row
(
png_ptr
,
(
png_byte
*
)
cdata
);
}
...
...
@@ -415,20 +407,12 @@ int PngIO::write_data(float *data, int image_index, const Region*,
}
}
else
if
(
depth_type
==
PNG_SHORT_DEPTH
)
{
auto
[
rendered_data
,
count
]
=
getRenderedDataAndRendertrunc
<
unsigned
short
>
(
data
,
nx
*
ny
);
unsigned
short
*
sdata
=
new
unsigned
short
[
nx
];
for
(
int
y
=
(
int
)
ny
-
1
;
y
>=
0
;
y
--
)
{
for
(
int
x
=
0
;
x
<
(
int
)
nx
;
x
++
)
{
if
(
data
[
y
*
nx
+
x
]
<=
rendermin
){
sdata
[
x
]
=
0
;
}
else
if
(
data
[
y
*
nx
+
x
]
>=
rendermax
)
{
sdata
[
x
]
=
USHRT_MAX
;
}
else
{
sdata
[
x
]
=
(
unsigned
short
)((
data
[
y
*
nx
+
x
]
-
rendermin
)
/
(
rendermax
-
rendermin
)
*
65536
);
}
sdata
[
x
]
=
(
unsigned
short
)
rendered_data
[
y
*
nx
+
x
];
}
png_write_row
(
png_ptr
,
(
png_byte
*
)
sdata
);
...
...
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