Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update the cICP implementation yet more #631

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pngread.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* pngread.c - read a PNG file
*
* Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
Expand Down Expand Up @@ -182,6 +182,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
else if (chunk_name == png_cHRM)
png_handle_cHRM(png_ptr, info_ptr, length);
#endif

#ifdef PNG_READ_cICP_SUPPORTED
else if (chunk_name == png_cICP)
png_handle_cICP(png_ptr, info_ptr, length);
Expand Down Expand Up @@ -864,6 +865,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_handle_cHRM(png_ptr, info_ptr, length);
#endif

#ifdef PNG_READ_cICP_SUPPORTED
else if (chunk_name == png_cICP)
png_handle_cICP(png_ptr, info_ptr, length);
#endif

#ifdef PNG_READ_eXIf_SUPPORTED
else if (chunk_name == png_eXIf)
png_handle_eXIf(png_ptr, info_ptr, length);
Expand Down
3 changes: 2 additions & 1 deletion pngset.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* pngset.c - storage of image information into info struct
*
* Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
Expand Down Expand Up @@ -1411,6 +1411,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
static const png_byte chunks_to_ignore[] = {
98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */
99, 73, 67, 80, '\0', /* cICP */
101, 88, 73, 102, '\0', /* eXIf */
103, 65, 77, 65, '\0', /* gAMA */
104, 73, 83, 84, '\0', /* hIST */
Expand Down
32 changes: 16 additions & 16 deletions pngtest.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* pngtest.c - a test program for libpng
*
* Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
Expand Down Expand Up @@ -1168,6 +1168,21 @@ test_one_file(const char *inname, const char *outname)
#endif
#endif /* Floating point */
#endif /* Fixed point */
#ifdef PNG_cICP_SUPPORTED
{
png_byte colour_primaries;
png_byte transfer_function;
png_byte matrix_coefficients;
png_byte video_full_range_flag;

if (png_get_cICP(read_ptr, read_info_ptr,
&colour_primaries, &transfer_function,
&matrix_coefficients, &video_full_range_flag) != 0)
png_set_cICP(write_ptr, write_info_ptr,
colour_primaries, transfer_function,
matrix_coefficients, video_full_range_flag);
}
#endif
#ifdef PNG_iCCP_SUPPORTED
{
png_charp name;
Expand Down Expand Up @@ -1206,21 +1221,6 @@ test_one_file(const char *inname, const char *outname)
png_set_bKGD(write_ptr, write_info_ptr, background);
}
#endif
#ifdef PNG_cICP_SUPPORTED
{
png_byte colour_primaries;
png_byte transfer_function;
png_byte matrix_coefficients;
png_byte video_full_range_flag;

if (png_get_cICP(read_ptr, read_info_ptr,
&colour_primaries, &transfer_function,
&matrix_coefficients, &video_full_range_flag) != 0)
png_set_cICP(write_ptr, write_info_ptr,
colour_primaries, transfer_function,
matrix_coefficients, video_full_range_flag);
}
#endif
#ifdef PNG_READ_eXIf_SUPPORTED
{
png_bytep exif = NULL;
Expand Down
Loading