Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
70df4966
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
70df4966
编写于
5月 27, 2014
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
various warning fixes, STBI_SIMD compile error, incorrect file-pointer state for one API
上级
ecff8d5d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
39 deletion
+62
-39
stb_image.c
stb_image.c
+58
-37
stb_image_write.h
stb_image_write.h
+4
-2
未找到文件。
stb_image.c
浏览文件 @
70df4966
/* stbi-1.3
3
- public domain JPEG/PNG reader - http://nothings.org/stb_image.c
/* stbi-1.3
5
- public domain JPEG/PNG reader - http://nothings.org/stb_image.c
when you control the images you're loading
when you control the images you're loading
no warranty implied; use at your own risk
no warranty implied; use at your own risk
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
- overridable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD)
- overridable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD)
Latest revisions:
Latest revisions:
1.35 (2014-05-27) warnings, bugfixes, etc
1.34 (unknown ) warning fix
1.34 (unknown ) warning fix
1.33 (2011-07-14) minor fixes suggested by Dave Moore
1.33 (2011-07-14) minor fixes suggested by Dave Moore
1.32 (2011-07-13) info support for all filetypes (SpartanJ)
1.32 (2011-07-13) info support for all filetypes (SpartanJ)
...
@@ -29,9 +30,6 @@
...
@@ -29,9 +30,6 @@
1.30 (2011-06-11) added ability to load files via io callbacks (Ben Wenger)
1.30 (2011-06-11) added ability to load files via io callbacks (Ben Wenger)
1.29 (2010-08-16) various warning fixes from Aurelien Pocheville
1.29 (2010-08-16) various warning fixes from Aurelien Pocheville
1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ)
1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ)
1.27 (2010-08-01) cast-to-stbi__uint8 to fix warnings (Laurent Gomila)
allow trailing 0s at end of image data (Laurent Gomila)
1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ
See end of file for full revision history.
See end of file for full revision history.
...
@@ -41,23 +39,26 @@
...
@@ -41,23 +39,26 @@
============================ Contributors =========================
============================ Contributors =========================
Image formats Optimizations & bugfixes
Image formats Bug fixes & warning fixes
Sean Barrett (jpeg, png, bmp) Fabian "ryg" Giesen
Sean Barrett (jpeg, png, bmp) Marc LeBlanc
Nicolas Schulz (hdr, psd)
Nicolas Schulz (hdr, psd) Christpher Lloyd
Jonathan Dummer (tga) Bug fixes & warning fixes
Jonathan Dummer (tga) Dave Moore
Jean-Marc Lienher (gif) Marc LeBlanc
Jean-Marc Lienher (gif) Won Chun
Tom Seddon (pic) Christpher Lloyd
Tom Seddon (pic) the Horde3D community
Thatcher Ulrich (psd) Dave Moore
Thatcher Ulrich (psd) Janez Zemva
Won Chun
Jonathan Blow
the Horde3D community
Laurent Gomila
Extensions, features Janez Zemva
Extensions, features Aruelien Pocheville
Jetro Lauha (stbi_info) Jonathan Blow
Jetro Lauha (stbi_info) Ryamond Barbiero
James "moose2000" Brown (iPhone PNG) Laurent Gomila
James "moose2000" Brown (iPhone PNG) David Woo
Ben "Disch" Wenger (io callbacks) Aruelien Pocheville
Ben "Disch" Wenger (io callbacks) Roy Eltham
Martin "SpartanJ" Golini Ryamond Barbiero
Martin "SpartanJ" Golini Luke Graham
David Woo
Thomas Ruf
John Bartholomew
Optimizations & bugfixes Ken Hamada
Fabian "ryg" Giesen Cort Stratton
If your name should be here but isn't, let Sean know.
If your name should be here but isn't, let Sean know.
*/
*/
...
@@ -187,12 +188,13 @@
...
@@ -187,12 +188,13 @@
#ifndef STBI_NO_STDIO
#ifndef STBI_NO_STDIO
#if defined(_MSC_VER) && _MSC_VER >= 0x1400
#if defined(_MSC_VER) && _MSC_VER >= 1400
#define _CRT_SECURE_NO_WARNINGS // suppress bogus warnings about fopen()
#define _CRT_SECURE_NO_WARNINGS // suppress warnings about fopen()
#pragma warning(push)
#pragma warning(disable:4996) // suppress even more warnings about fopen()
#endif
#endif
#include <stdio.h>
#include <stdio.h>
#endif
#endif
// STBI_NO_STDIO
#define STBI_VERSION 1
#define STBI_VERSION 1
...
@@ -232,7 +234,7 @@ extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y,
...
@@ -232,7 +234,7 @@ extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y,
typedef
struct
typedef
struct
{
{
int
(
*
read
)
(
void
*
user
,
char
*
data
,
int
size
);
// fill 'data' with 'size' bytes. return number of bytes actually read
int
(
*
read
)
(
void
*
user
,
char
*
data
,
int
size
);
// fill 'data' with 'size' bytes. return number of bytes actually read
void
(
*
skip
)
(
void
*
user
,
unsigned
n
);
// skip the next 'n' bytes
void
(
*
skip
)
(
void
*
user
,
int
n
);
// skip the next 'n' bytes, or 'unget' the last -n bytes if negative
int
(
*
eof
)
(
void
*
user
);
// returns nonzero if we are at end of file/data
int
(
*
eof
)
(
void
*
user
);
// returns nonzero if we are at end of file/data
}
stbi_io_callbacks
;
}
stbi_io_callbacks
;
...
@@ -296,6 +298,7 @@ extern void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
...
@@ -296,6 +298,7 @@ extern void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
// ZLIB client - used by PNG, available for other purposes
// ZLIB client - used by PNG, available for other purposes
extern
char
*
stbi_zlib_decode_malloc_guesssize
(
const
char
*
buffer
,
int
len
,
int
initial_size
,
int
*
outlen
);
extern
char
*
stbi_zlib_decode_malloc_guesssize
(
const
char
*
buffer
,
int
len
,
int
initial_size
,
int
*
outlen
);
extern
char
*
stbi_zlib_decode_malloc_guesssize_headerflag
(
const
char
*
buffer
,
int
len
,
int
initial_size
,
int
*
outlen
,
int
parse_header
);
extern
char
*
stbi_zlib_decode_malloc
(
const
char
*
buffer
,
int
len
,
int
*
outlen
);
extern
char
*
stbi_zlib_decode_malloc
(
const
char
*
buffer
,
int
len
,
int
*
outlen
);
extern
int
stbi_zlib_decode_buffer
(
char
*
obuffer
,
int
olen
,
const
char
*
ibuffer
,
int
ilen
);
extern
int
stbi_zlib_decode_buffer
(
char
*
obuffer
,
int
olen
,
const
char
*
ibuffer
,
int
ilen
);
...
@@ -368,11 +371,11 @@ typedef signed int stbi__int32;
...
@@ -368,11 +371,11 @@ typedef signed int stbi__int32;
// should produce compiler error if size is wrong
// should produce compiler error if size is wrong
typedef
unsigned
char
validate_uint32
[
sizeof
(
stbi__uint32
)
==
4
?
1
:
-
1
];
typedef
unsigned
char
validate_uint32
[
sizeof
(
stbi__uint32
)
==
4
?
1
:
-
1
];
#if defined(STBI_NO_STDIO) && !defined(STBI_NO_WRITE)
#ifdef _MSC_VER
#define STBI_NO_WRITE
#define STBI_NOTUSED(v) (void)(v)
#endif
#else
#define STBI_NOTUSED(v) (void)sizeof(v)
#define STBI_NOTUSED(v) (void)sizeof(v)
#endif
#ifdef _MSC_VER
#ifdef _MSC_VER
#define STBI_HAS_LROTL
#define STBI_HAS_LROTL
...
@@ -436,7 +439,7 @@ static int stdio_read(void *user, char *data, int size)
...
@@ -436,7 +439,7 @@ static int stdio_read(void *user, char *data, int size)
return
(
int
)
fread
(
data
,
1
,
size
,(
FILE
*
)
user
);
return
(
int
)
fread
(
data
,
1
,
size
,(
FILE
*
)
user
);
}
}
static
void
stdio_skip
(
void
*
user
,
unsigned
n
)
static
void
stdio_skip
(
void
*
user
,
int
n
)
{
{
fseek
((
FILE
*
)
user
,
n
,
SEEK_CUR
);
fseek
((
FILE
*
)
user
,
n
,
SEEK_CUR
);
}
}
...
@@ -483,8 +486,10 @@ static stbi_uc *stbi_tga_load(stbi *s, int *x, int *y, int *comp, int req_comp);
...
@@ -483,8 +486,10 @@ static stbi_uc *stbi_tga_load(stbi *s, int *x, int *y, int *comp, int req_comp);
static
int
stbi_tga_info
(
stbi
*
s
,
int
*
x
,
int
*
y
,
int
*
comp
);
static
int
stbi_tga_info
(
stbi
*
s
,
int
*
x
,
int
*
y
,
int
*
comp
);
static
int
stbi_psd_test
(
stbi
*
s
);
static
int
stbi_psd_test
(
stbi
*
s
);
static
stbi_uc
*
stbi_psd_load
(
stbi
*
s
,
int
*
x
,
int
*
y
,
int
*
comp
,
int
req_comp
);
static
stbi_uc
*
stbi_psd_load
(
stbi
*
s
,
int
*
x
,
int
*
y
,
int
*
comp
,
int
req_comp
);
#ifndef STBI_NO_HDR
static
int
stbi_hdr_test
(
stbi
*
s
);
static
int
stbi_hdr_test
(
stbi
*
s
);
static
float
*
stbi_hdr_load
(
stbi
*
s
,
int
*
x
,
int
*
y
,
int
*
comp
,
int
req_comp
);
static
float
*
stbi_hdr_load
(
stbi
*
s
,
int
*
x
,
int
*
y
,
int
*
comp
,
int
req_comp
);
#endif
static
int
stbi_pic_test
(
stbi
*
s
);
static
int
stbi_pic_test
(
stbi
*
s
);
static
stbi_uc
*
stbi_pic_load
(
stbi
*
s
,
int
*
x
,
int
*
y
,
int
*
comp
,
int
req_comp
);
static
stbi_uc
*
stbi_pic_load
(
stbi
*
s
,
int
*
x
,
int
*
y
,
int
*
comp
,
int
req_comp
);
static
int
stbi_gif_test
(
stbi
*
s
);
static
int
stbi_gif_test
(
stbi
*
s
);
...
@@ -566,9 +571,15 @@ unsigned char *stbi_load(char const *filename, int *x, int *y, int *comp, int re
...
@@ -566,9 +571,15 @@ unsigned char *stbi_load(char const *filename, int *x, int *y, int *comp, int re
unsigned
char
*
stbi_load_from_file
(
FILE
*
f
,
int
*
x
,
int
*
y
,
int
*
comp
,
int
req_comp
)
unsigned
char
*
stbi_load_from_file
(
FILE
*
f
,
int
*
x
,
int
*
y
,
int
*
comp
,
int
req_comp
)
{
{
unsigned
char
*
result
;
stbi
s
;
stbi
s
;
start_file
(
&
s
,
f
);
start_file
(
&
s
,
f
);
return
stbi_load_main
(
&
s
,
x
,
y
,
comp
,
req_comp
);
result
=
stbi_load_main
(
&
s
,
x
,
y
,
comp
,
req_comp
);
if
(
result
)
{
// need to 'unget' all the characters in the IO buffer
fseek
(
f
,
-
(
int
)
(
s
.
img_buffer_end
-
s
.
img_buffer
),
SEEK_CUR
);
}
return
result
;
}
}
#endif //!STBI_NO_STDIO
#endif //!STBI_NO_STDIO
...
@@ -716,9 +727,11 @@ static void refill_buffer(stbi *s)
...
@@ -716,9 +727,11 @@ static void refill_buffer(stbi *s)
{
{
int
n
=
(
s
->
io
.
read
)(
s
->
io_user_data
,(
char
*
)
s
->
buffer_start
,
s
->
buflen
);
int
n
=
(
s
->
io
.
read
)(
s
->
io_user_data
,(
char
*
)
s
->
buffer_start
,
s
->
buflen
);
if
(
n
==
0
)
{
if
(
n
==
0
)
{
// at end of file, treat same as if from memory
// at end of file, treat same as if from memory, but need
// to handle case where s->img_buffer isn't pointing to safe memory
s
->
read_from_callbacks
=
0
;
s
->
read_from_callbacks
=
0
;
s
->
img_buffer
=
s
->
img_buffer_end
-
1
;
s
->
img_buffer
=
s
->
buffer_start
;
s
->
img_buffer_end
=
s
->
buffer_start
+
1
;
*
s
->
img_buffer
=
0
;
*
s
->
img_buffer
=
0
;
}
else
{
}
else
{
s
->
img_buffer
=
s
->
buffer_start
;
s
->
img_buffer
=
s
->
buffer_start
;
...
@@ -757,7 +770,7 @@ stbi_inline static stbi__uint8 get8u(stbi *s)
...
@@ -757,7 +770,7 @@ stbi_inline static stbi__uint8 get8u(stbi *s)
static
void
skip
(
stbi
*
s
,
int
n
)
static
void
skip
(
stbi
*
s
,
int
n
)
{
{
if
(
s
->
io
.
read
)
{
if
(
s
->
io
.
read
)
{
int
blen
=
s
->
img_buffer_end
-
s
->
img_buffer
;
int
blen
=
(
int
)
(
s
->
img_buffer_end
-
s
->
img_buffer
)
;
if
(
blen
<
n
)
{
if
(
blen
<
n
)
{
s
->
img_buffer
=
s
->
img_buffer_end
;
s
->
img_buffer
=
s
->
img_buffer_end
;
(
s
->
io
.
skip
)(
s
->
io_user_data
,
n
-
blen
);
(
s
->
io
.
skip
)(
s
->
io_user_data
,
n
-
blen
);
...
@@ -770,7 +783,7 @@ static void skip(stbi *s, int n)
...
@@ -770,7 +783,7 @@ static void skip(stbi *s, int n)
static
int
getn
(
stbi
*
s
,
stbi_uc
*
buffer
,
int
n
)
static
int
getn
(
stbi
*
s
,
stbi_uc
*
buffer
,
int
n
)
{
{
if
(
s
->
io
.
read
)
{
if
(
s
->
io
.
read
)
{
int
blen
=
s
->
img_buffer_end
-
s
->
img_buffer
;
int
blen
=
(
int
)
(
s
->
img_buffer_end
-
s
->
img_buffer
)
;
if
(
blen
<
n
)
{
if
(
blen
<
n
)
{
int
res
,
count
;
int
res
,
count
;
...
@@ -1879,7 +1892,7 @@ static stbi__uint8 *load_jpeg_image(jpeg *z, int *out_x, int *out_y, int *comp,
...
@@ -1879,7 +1892,7 @@ static stbi__uint8 *load_jpeg_image(jpeg *z, int *out_x, int *out_y, int *comp,
stbi__uint8
*
y
=
coutput
[
0
];
stbi__uint8
*
y
=
coutput
[
0
];
if
(
z
->
s
->
img_n
==
3
)
{
if
(
z
->
s
->
img_n
==
3
)
{
#ifdef STBI_SIMD
#ifdef STBI_SIMD
stbi_YCbCr_installed
(
out
,
y
,
coutput
[
1
],
coutput
[
2
],
z
->
s
.
img_x
,
n
);
stbi_YCbCr_installed
(
out
,
y
,
coutput
[
1
],
coutput
[
2
],
z
->
s
->
img_x
,
n
);
#else
#else
YCbCr_to_RGB_row
(
out
,
y
,
coutput
[
1
],
coutput
[
2
],
z
->
s
->
img_x
,
n
);
YCbCr_to_RGB_row
(
out
,
y
,
coutput
[
1
],
coutput
[
2
],
z
->
s
->
img_x
,
n
);
#endif
#endif
...
@@ -4588,9 +4601,17 @@ int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int
...
@@ -4588,9 +4601,17 @@ int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int
#endif // STBI_HEADER_FILE_ONLY
#endif // STBI_HEADER_FILE_ONLY
#if !defined(STBI_NO_STDIO) && defined(_MSC_VER) && _MSC_VER >= 1400
#pragma warning(pop)
#endif
/*
/*
revision history:
revision history:
1.35 (2014-05-27)
1.35 (2014-05-27)
various warnings
fix broken STBI_SIMD path
fix bug where stbi_load_from_file no longer left file pointer in correct place
1.34 (unknown)
1.34 (unknown)
use STBI_NOTUSED in resample_row_generic(), fix one more leak in tga failure case
use STBI_NOTUSED in resample_row_generic(), fix one more leak in tga failure case
1.33 (2011-07-14)
1.33 (2011-07-14)
...
...
stb_image_write.h
浏览文件 @
70df4966
/* stbiw-0.9
2
- public domain - http://nothings.org/stb/stb_image_write.h
/* stbiw-0.9
3
- public domain - http://nothings.org/stb/stb_image_write.h
writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010
writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010
no warranty implied; use at your own risk
no warranty implied; use at your own risk
...
@@ -318,7 +318,7 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l
...
@@ -318,7 +318,7 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l
}
}
if
(
bestloc
)
{
if
(
bestloc
)
{
int
d
=
data
+
i
-
bestloc
;
// distance back
int
d
=
(
int
)
(
data
+
i
-
bestloc
)
;
// distance back
assert
(
d
<=
32767
&&
best
<=
258
);
assert
(
d
<=
32767
&&
best
<=
258
);
for
(
j
=
0
;
best
>
lengthc
[
j
+
1
]
-
1
;
++
j
);
for
(
j
=
0
;
best
>
lengthc
[
j
+
1
]
-
1
;
++
j
);
stbi__zlib_huff
(
j
+
257
);
stbi__zlib_huff
(
j
+
257
);
...
@@ -503,6 +503,8 @@ int stbi_write_png(char const *filename, int x, int y, int comp, const void *dat
...
@@ -503,6 +503,8 @@ int stbi_write_png(char const *filename, int x, int y, int comp, const void *dat
/* Revision history
/* Revision history
0.93 (2014-05-27)
warning fixes
0.92 (2010-08-01)
0.92 (2010-08-01)
casts to unsigned char to fix warnings
casts to unsigned char to fix warnings
0.91 (2010-07-17)
0.91 (2010-07-17)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录