Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Libpng
提交
363ae65e
T
Third Party Libpng
项目概览
OpenHarmony
/
Third Party Libpng
大约 1 年 前同步成功
通知
4
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Libpng
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
363ae65e
编写于
3月 01, 2012
作者:
G
Glenn Randers-Pehrson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libpng16] Added tests for invalid palette index while reading and writing
(work in progress, the latter isn't finished).
上级
cb129a62
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
126 addition
and
37 deletion
+126
-37
ANNOUNCE
ANNOUNCE
+2
-0
CHANGES
CHANGES
+2
-0
pngrtran.c
pngrtran.c
+98
-26
pngstruct.h
pngstruct.h
+6
-7
pngwrite.c
pngwrite.c
+5
-2
scripts/pnglibconf.dfa
scripts/pnglibconf.dfa
+9
-1
scripts/pnglibconf.h.prebuilt
scripts/pnglibconf.h.prebuilt
+4
-1
未找到文件。
ANNOUNCE
浏览文件 @
363ae65e
...
...
@@ -250,6 +250,8 @@ Version 1.6.0beta15 [March 2, 2012]
allow the error numbers in pngstest to be tuned and checked. makepng
also allows generation of images with extra chunks, although this is
still work-in-progress.
Added tests for invalid palette index while reading and writing (work in
progress, the latter isn't finished).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
...
...
CHANGES
浏览文件 @
363ae65e
...
...
@@ -4002,6 +4002,8 @@ Version 1.6.0beta15 [March 2, 2012]
allow the error numbers in pngstest to be tuned and checked. makepng
also allows generation of images with extra chunks, although this is
still work-in-progress.
Added tests for invalid palette index while reading and writing (work in
progress, the latter isn't finished).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
...
...
pngrtran.c
浏览文件 @
363ae65e
...
...
@@ -2294,29 +2294,101 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
png_do_unpack
(
row_info
,
png_ptr
->
row_buf
+
1
);
#endif
/* Added at libpng-1.6.0 */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* To do: Fix does not check sub-8-bit rows that have not been unpacked. */
if
(
row_info
->
color_type
==
PNG_COLOR_TYPE_PALETTE
&&
row_info
->
bit_depth
==
8
)
if
(
png_ptr
->
num_palette
<
(
1
<<
png_ptr
->
bit_depth
))
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Added at libpng-1.5.10 */
if
(
row_info
->
color_type
==
PNG_COLOR_TYPE_PALETTE
)
{
if
((
png_ptr
->
interlaced
&&
png_ptr
->
pass
==
6
)
||
(
!
png_ptr
->
interlaced
&&
png_ptr
->
pass
==
0
))
if
(
png_ptr
->
num_palette
<
(
1
<<
png_ptr
->
bit_depth
)
&&
((
png_ptr
->
interlaced
&&
png_ptr
->
pass
==
6
)
||
(
!
png_ptr
->
interlaced
&&
png_ptr
->
pass
==
0
)))
{
png_uint_32
i
;
png_bytep
rp
=
png_ptr
->
row_buf
+
1
;
/* +1 to skip the filter byte */
png_bytep
rp
=
png_ptr
->
row_buf
+
1
+
row_info
->
rowbytes
;
int
index
,
padding
;
for
(
i
=
0
;
i
<=
row_info
->
rowbytes
;
i
++
)
switch
(
row_info
->
bit_depth
)
{
case
1
:
{
if
(
*
rp
>=
png_ptr
->
num_palette
)
/* in this case, all bytes must be 0 so we don't need
* to unpack the pixels except for the rightmost one.
*/
padding
=
8
*
row_info
->
rowbytes
-
png_ptr
->
width
;
for
(;
rp
>
png_ptr
->
row_buf
;
rp
--
)
{
/* Should this be a benign error instead of a warning? */
png_warning
(
png_ptr
,
"Found invalid palette index"
);
if
(
*
rp
>>
padding
!=
0
)
png_ptr
->
num_palette_max
=
1
;
padding
=
0
;
}
break
;
}
rp
++
;
case
2
:
{
padding
=
2
*
(
4
*
row_info
->
rowbytes
-
png_ptr
->
width
);
for
(;
rp
>
png_ptr
->
row_buf
;
rp
--
)
{
index
=
((
*
rp
>>
padding
)
&
0x03
);
if
(
index
>
png_ptr
->
num_palette_max
)
png_ptr
->
num_palette_max
=
index
;
index
=
(((
*
rp
>>
padding
)
>>
2
)
&
0x03
);
if
(
index
>
png_ptr
->
num_palette_max
)
png_ptr
->
num_palette_max
=
index
;
index
=
(((
*
rp
>>
padding
)
>>
4
)
&
0x03
);
if
(
index
>
png_ptr
->
num_palette_max
)
png_ptr
->
num_palette_max
=
index
;
index
=
(((
*
rp
>>
padding
)
>>
6
)
&
0x03
);
if
(
index
>
png_ptr
->
num_palette_max
)
png_ptr
->
num_palette_max
=
index
;
padding
=
0
;
}
break
;
}
case
4
:
{
padding
=
4
*
(
2
*
row_info
->
rowbytes
-
png_ptr
->
width
);
for
(;
rp
>
png_ptr
->
row_buf
;
rp
--
)
{
index
=
((
*
rp
>>
padding
)
&
0x0f
);
if
(
index
>
png_ptr
->
num_palette_max
)
png_ptr
->
num_palette_max
=
index
;
index
=
(((
*
rp
>>
padding
)
>>
4
)
&
0x0f
);
if
(
index
>
png_ptr
->
num_palette_max
)
png_ptr
->
num_palette_max
=
index
;
padding
=
0
;
}
break
;
}
case
8
:
{
for
(;
rp
>
png_ptr
->
row_buf
;
rp
--
)
{
if
(
*
rp
>=
png_ptr
->
num_palette_max
)
png_ptr
->
num_palette_max
=
*
rp
;
}
break
;
}
}
}
}
...
...
pngstruct.h
浏览文件 @
363ae65e
...
...
@@ -123,6 +123,12 @@ struct png_struct_def
png_uint_32
crc
;
/* current chunk CRC value */
png_colorp
palette
;
/* palette from the input file */
png_uint_16
num_palette
;
/* number of color entries in palette */
/* Added at libpng-1.5.10 */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
png_uint_16
num_palette_max
;
/* maximum palette index found in IDAT */
#endif
png_uint_16
num_trans
;
/* number of transparency values */
png_byte
compression
;
/* file compression type (always 0) */
png_byte
filter
;
/* file filter type (always 0) */
...
...
@@ -215,13 +221,6 @@ struct png_struct_def
int
process_mode
;
/* what push library is currently doing */
int
cur_palette
;
/* current push library palette index */
# ifdef PNG_TEXT_SUPPORTED
png_size_t
current_text_size
;
/* current size of text input data */
png_size_t
current_text_left
;
/* how much text left to read in input */
png_charp
current_text
;
/* current text chunk buffer */
png_charp
current_text_ptr
;
/* current location in current_text */
# endif
/* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
#endif
/* PNG_PROGRESSIVE_READ_SUPPORTED */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
...
...
pngwrite.c
浏览文件 @
363ae65e
...
...
@@ -731,12 +731,15 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
}
#endif
#if 0 /* To do: implement png_do_check_palette_indexes() */
/* Added at libpng-1.5.10 */
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Check for out-of-range palette index */
#if 0 /* To do: implement png_do_check_palette_indexes() */
if (png_ptr->num_palette < (1 << png_ptr->bit_depth))
png_do_check_palette_indexes(&row_info, png_ptr->row_buf + 1,
png_ptr->num_palette_max);
if (png_ptr->num_palette_max > num_palette + 1)
#endif
if
(
png_ptr
->
num_palette_max
>
png_ptr
->
num_palette
+
1
)
png_warning
(
png_ptr
,
"Palette index exceeded num_palette"
);
#endif
...
...
scripts/pnglibconf.dfa
浏览文件 @
363ae65e
...
...
@@ -586,7 +586,15 @@ option WRITE_COMPRESSED_TEXT enables WRITE_TEXT
option INFO_IMAGE
# Simplified API options
# added at libpng-1.5.10
# Turn this off to disable warning about invalid palette index and
# leave the num_palette_max member out of the png structure.
option CHECK_FOR_INVALID_INDEX
option READ_CHECK_FOR_INVALID_INDEX requires READ CHECK_FOR_INVALID_INDEX
option WRITE_CHECK_FOR_INVALID_INDEX requires WRITE CHECK_FOR_INVALID_INDEX
# Simplified API options (added at libpng-1.6.0)
# Read:
option SIMPLIFIED_READ requires SEQUENTIAL_READ READ_TRANSFORMS SETJMP
option SIMPLIFIED_READ enables READ_EXPAND READ_16BIT READ_EXPAND_16
...
...
scripts/pnglibconf.h.prebuilt
浏览文件 @
363ae65e
...
...
@@ -3,7 +3,7 @@
/* pnglibconf.h - library build configuration */
/* Libpng 1.6.0beta15 -
February 27
, 2012 */
/* Libpng 1.6.0beta15 -
March 1
, 2012 */
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
...
...
@@ -41,6 +41,7 @@
#define PNG_bKGD_SUPPORTED
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
#define PNG_CHECK_cHRM_SUPPORTED
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_cHRM_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
...
...
@@ -72,6 +73,7 @@
#define PNG_READ_BACKGROUND_SUPPORTED
#define PNG_READ_BGR_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
...
...
@@ -149,6 +151,7 @@
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录