Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
What's new
2
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
sane-project
backends
Commits
a907b61b
Commit
a907b61b
authored
Apr 17, 2017
by
Aaron Muir Hamilton
Committed by
Olaf Meeuwissen
Apr 30, 2017
Browse files
Add ICC profile embedding for PNG output.
parent
2c653a92
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/scanimage.c
View file @
a907b61b
...
...
@@ -56,6 +56,7 @@
#include
"../include/sane/sanei.h"
#include
"../include/sane/saneopts.h"
#include
"sicc.h"
#include
"stiff.h"
#include
"../include/md5.h"
...
...
@@ -1165,9 +1166,11 @@ write_pnm_header (SANE_Frame format, int width, int height, int depth, FILE *ofp
#ifdef HAVE_LIBPNG
static
void
write_png_header
(
SANE_Frame
format
,
int
width
,
int
height
,
int
depth
,
FILE
*
ofp
,
png_structp
*
png_ptr
,
png_infop
*
info_ptr
)
write_png_header
(
SANE_Frame
format
,
int
width
,
int
height
,
int
depth
,
const
char
*
icc_profile
,
FILE
*
ofp
,
png_structp
*
png_ptr
,
png_infop
*
info_ptr
)
{
int
color_type
;
size_t
icc_size
=
0
;
void
*
icc_buffer
;
*
png_ptr
=
png_create_write_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
...
...
@@ -1200,6 +1203,16 @@ write_png_header (SANE_Frame format, int width, int height, int depth, FILE *ofp
depth
,
color_type
,
PNG_INTERLACE_NONE
,
PNG_COMPRESSION_TYPE_BASE
,
PNG_FILTER_TYPE_BASE
);
if
(
icc_profile
)
{
icc_buffer
=
sanei_load_icc_profile
(
icc_profile
,
&
icc_size
);
if
(
icc_size
>
0
)
{
png_set_iCCP
(
*
png_ptr
,
*
info_ptr
,
basename
(
icc_profile
),
PNG_COMPRESSION_TYPE_BASE
,
icc_buffer
,
icc_size
);
free
(
icc_buffer
);
}
}
png_write_info
(
*
png_ptr
,
*
info_ptr
);
}
#endif
...
...
@@ -1379,7 +1392,8 @@ scan_it (FILE *ofp)
#ifdef HAVE_LIBPNG
case
OUTPUT_PNG
:
write_png_header
(
parm
.
format
,
parm
.
pixels_per_line
,
parm
.
lines
,
parm
.
depth
,
ofp
,
&
png_ptr
,
&
info_ptr
);
parm
.
lines
,
parm
.
depth
,
icc_profile
,
ofp
,
&
png_ptr
,
&
info_ptr
);
break
;
#endif
#ifdef HAVE_LIBJPEG
...
...
@@ -1635,7 +1649,8 @@ scan_it (FILE *ofp)
#ifdef HAVE_LIBPNG
case
OUTPUT_PNG
:
write_png_header
(
parm
.
format
,
parm
.
pixels_per_line
,
image
.
height
,
parm
.
depth
,
ofp
,
&
png_ptr
,
&
info_ptr
);
image
.
height
,
parm
.
depth
,
icc_profile
,
ofp
,
&
png_ptr
,
&
info_ptr
);
break
;
#endif
#ifdef HAVE_LIBJPEG
...
...
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