Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Libpng
提交
f8378311
T
Third Party Libpng
项目概览
OpenHarmony
/
Third Party Libpng
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
f8378311
编写于
3月 31, 2011
作者:
G
Glenn Randers-Pehrson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[devel] Use a mode bit to avoid reopening the zstream except when necessary.
上级
ed8aab4d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
34 deletion
+46
-34
pngpriv.h
pngpriv.h
+1
-0
pngwutil.c
pngwutil.c
+45
-34
未找到文件。
pngpriv.h
浏览文件 @
f8378311
...
@@ -277,6 +277,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
...
@@ -277,6 +277,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
#define PNG_BACKGROUND_IS_GRAY 0x800
#define PNG_BACKGROUND_IS_GRAY 0x800
#define PNG_HAVE_PNG_SIGNATURE 0x1000
#define PNG_HAVE_PNG_SIGNATURE 0x1000
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000
/* Have another chunk after IDAT */
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000
/* Have another chunk after IDAT */
#define PNG_ZLIB_READY_FOR_ZTXT 0x4000
/* 1: ready for ZTXT; 0: for IDAT */
/* Flags for the transformations the PNG library does on the image data */
/* Flags for the transformations the PNG library does on the image data */
#define PNG_BGR 0x0001
#define PNG_BGR 0x0001
...
...
pngwutil.c
浏览文件 @
f8378311
...
@@ -256,26 +256,33 @@ png_text_compress(png_structp png_ptr,
...
@@ -256,26 +256,33 @@ png_text_compress(png_structp png_ptr,
* wouldn't cause a failure, just a slowdown due to swapping).
* wouldn't cause a failure, just a slowdown due to swapping).
*/
*/
/* Initialize the compressor. To do: Why do we need this? */
if
(
!
(
png_ptr
->
mode
&
PNG_ZLIB_READY_FOR_ZTXT
))
ret
=
deflateInit2
(
&
png_ptr
->
zstream
,
png_ptr
->
zlib_text_level
,
{
png_ptr
->
zlib_text_method
,
png_ptr
->
zlib_text_window_bits
,
/* Free memory from previously opened zstream */
png_ptr
->
zlib_text_mem_level
,
png_ptr
->
zlib_text_strategy
);
deflateEnd
(
&
png_ptr
->
zstream
);
if
(
ret
!=
Z_OK
)
/* Initialize the compressor for zTXt compression. */
{
ret
=
deflateInit2
(
&
png_ptr
->
zstream
,
png_ptr
->
zlib_text_level
,
if
(
ret
==
Z_VERSION_ERROR
)
png_ptr
->
zlib_text_method
,
png_ptr
->
zlib_text_window_bits
,
png_error
(
png_ptr
,
png_ptr
->
zlib_text_mem_level
,
png_ptr
->
zlib_text_strategy
);
"zlib failed to initialize compressor for text-- version error"
);
if
(
ret
!=
Z_OK
)
if
(
ret
==
Z_STREAM_ERROR
)
{
png_error
(
png_ptr
,
if
(
ret
==
Z_VERSION_ERROR
)
png_error
(
png_ptr
,
"zlib failed to initialize compressor for text-- version error"
);
if
(
ret
==
Z_STREAM_ERROR
)
png_error
(
png_ptr
,
"zlib failed to initialize compressor for text-- stream error"
);
"zlib failed to initialize compressor for text-- stream error"
);
if
(
ret
==
Z_MEM_ERROR
)
if
(
ret
==
Z_MEM_ERROR
)
png_error
(
png_ptr
,
png_error
(
png_ptr
,
"zlib failed to initialize compressor for text-- mem error"
);
"zlib failed to initialize compressor for text-- mem error"
);
png_error
(
png_ptr
,
"zlib failed to initialize compressor for text"
);
png_error
(
png_ptr
,
"zlib failed to initialize compressor for text"
);
}
png_ptr
->
mode
|=
PNG_ZLIB_READY_FOR_ZTXT
;
}
}
/* Set up the compression buffers */
/* Set up the compression buffers */
...
@@ -685,7 +692,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
...
@@ -685,7 +692,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr
->
zlib_method
,
png_ptr
->
zlib_window_bits
,
png_ptr
->
zlib_method
,
png_ptr
->
zlib_window_bits
,
png_ptr
->
zlib_mem_level
,
png_ptr
->
zlib_strategy
);
png_ptr
->
zlib_mem_level
,
png_ptr
->
zlib_strategy
);
png_ptr
->
mode
=
PNG_HAVE_IHDR
;
png_ptr
->
mode
=
PNG_HAVE_IHDR
;
/* not READY_FOR_ZTXT */
}
}
/* Write the palette. We are careful not to trust png_color to be in the
/* Write the palette. We are careful not to trust png_color to be in the
...
@@ -778,28 +785,32 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
...
@@ -778,28 +785,32 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
int
ret
;
int
ret
;
unsigned
int
z_cmf
;
/* zlib compression method and flags */
unsigned
int
z_cmf
;
/* zlib compression method and flags */
/* Free memory from previously opened zstream */
if
(
png_ptr
->
mode
&
PNG_ZLIB_READY_FOR_ZTXT
)
deflateEnd
(
&
png_ptr
->
zstream
);
{
/* Free memory from previously opened zstream */
deflateEnd
(
&
png_ptr
->
zstream
);
ret
=
deflateInit2
(
&
png_ptr
->
zstream
,
png_ptr
->
zlib_level
,
ret
=
deflateInit2
(
&
png_ptr
->
zstream
,
png_ptr
->
zlib_level
,
png_ptr
->
zlib_method
,
png_ptr
->
zlib_window_bits
,
png_ptr
->
zlib_method
,
png_ptr
->
zlib_window_bits
,
png_ptr
->
zlib_mem_level
,
png_ptr
->
zlib_strategy
);
png_ptr
->
zlib_mem_level
,
png_ptr
->
zlib_strategy
);
if
(
ret
!=
Z_OK
)
if
(
ret
!=
Z_OK
)
{
{
if
(
ret
==
Z_VERSION_ERROR
)
if
(
ret
==
Z_VERSION_ERROR
)
png_error
(
png_ptr
,
png_error
(
png_ptr
,
"zlib failed to initialize compressor -- version error"
);
"zlib failed to initialize compressor -- version error"
);
if
(
ret
==
Z_STREAM_ERROR
)
if
(
ret
==
Z_STREAM_ERROR
)
png_error
(
png_ptr
,
png_error
(
png_ptr
,
"zlib failed to initialize compressor -- stream error"
);
"zlib failed to initialize compressor -- stream error"
);
if
(
ret
==
Z_MEM_ERROR
)
if
(
ret
==
Z_MEM_ERROR
)
png_error
(
png_ptr
,
png_error
(
png_ptr
,
"zlib failed to initialize compressor -- mem error"
);
"zlib failed to initialize compressor -- mem error"
);
png_error
(
png_ptr
,
"zlib failed to initialize compressor"
);
png_error
(
png_ptr
,
"zlib failed to initialize compressor"
);
}
png_ptr
->
mode
&=
~
PNG_ZLIB_READY_FOR_ZTXT
;
/* Ready for IDAT */
}
}
png_ptr
->
zstream
.
next_out
=
png_ptr
->
zbuf
;
png_ptr
->
zstream
.
next_out
=
png_ptr
->
zbuf
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录