Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
a31d50ab
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,发现更多精彩内容 >>
提交
a31d50ab
编写于
5月 27, 2014
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more warnings, use stdint.h if possible
上级
70df4966
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
16 deletion
+28
-16
stb_image.c
stb_image.c
+28
-16
未找到文件。
stb_image.c
浏览文件 @
a31d50ab
...
...
@@ -57,9 +57,10 @@
John Bartholomew
Optimizations & bugfixes Ken Hamada
Fabian "ryg" Giesen Cort Stratton
If your name should be here but isn't, let Sean know.
Blazej Dariusz Roszkowski
Thibault Reuille
If your name should be here but Paul Du Bois
isn't let Sean know. Guillaume George
*/
...
...
@@ -349,6 +350,7 @@ extern void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func);
#include <memory.h>
#include <assert.h>
#include <stdarg.h>
#include <stddef.h> // ptrdiff_t on osx
#ifndef _MSC_VER
#ifdef __cplusplus
...
...
@@ -361,12 +363,20 @@ extern void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func);
#endif
// implementation:
#ifdef _MSC_VER
typedef
unsigned
char
stbi__uint8
;
typedef
unsigned
short
stbi__uint16
;
typedef
signed
short
stbi__int16
;
typedef
signed
short
stbi__int16
;
typedef
unsigned
int
stbi__uint32
;
typedef
signed
int
stbi__int32
;
typedef
signed
int
stbi__int32
;
#else
#include <stdint.h>
typedef
uint8_t
stbi__uint8
;
typedef
uint16_t
stbi__uint16
;
typedef
int16_t
stbi__int16
;
typedef
uint32_t
stbi__uint32
;
typedef
int32_t
stbi__int32
;
#endif
// should produce compiler error if size is wrong
typedef
unsigned
char
validate_uint32
[
sizeof
(
stbi__uint32
)
==
4
?
1
:
-
1
];
...
...
@@ -727,8 +737,8 @@ static void refill_buffer(stbi *s)
{
int
n
=
(
s
->
io
.
read
)(
s
->
io_user_data
,(
char
*
)
s
->
buffer_start
,
s
->
buflen
);
if
(
n
==
0
)
{
// 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
// 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, e.g. 0-byte file
s
->
read_from_callbacks
=
0
;
s
->
img_buffer
=
s
->
buffer_start
;
s
->
img_buffer_end
=
s
->
buffer_start
+
1
;
...
...
@@ -3014,6 +3024,7 @@ static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
mb
=
0xffu
<<
0
;
ma
=
0xffu
<<
24
;
fake_a
=
1
;
// @TODO: check for cases like alpha value is all 0 and switch it to 255
STBI_UNUSED
(
fake_a
);
}
else
{
mr
=
31u
<<
10
;
mg
=
31u
<<
5
;
...
...
@@ -3105,9 +3116,9 @@ static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
if
(
!
mr
||
!
mg
||
!
mb
)
{
free
(
out
);
return
epuc
(
"bad masks"
,
"Corrupt BMP"
);
}
// right shift amt to put high bit in position #7
rshift
=
high_bit
(
mr
)
-
7
;
rcount
=
bitcount
(
mr
);
gshift
=
high_bit
(
mg
)
-
7
;
gcount
=
bitcount
(
m
r
);
bshift
=
high_bit
(
mb
)
-
7
;
bcount
=
bitcount
(
m
r
);
ashift
=
high_bit
(
ma
)
-
7
;
acount
=
bitcount
(
m
r
);
gshift
=
high_bit
(
mg
)
-
7
;
gcount
=
bitcount
(
m
g
);
bshift
=
high_bit
(
mb
)
-
7
;
bcount
=
bitcount
(
m
b
);
ashift
=
high_bit
(
ma
)
-
7
;
acount
=
bitcount
(
m
a
);
}
for
(
j
=
0
;
j
<
(
int
)
s
->
img_y
;
++
j
)
{
if
(
easy
)
{
...
...
@@ -3122,7 +3133,7 @@ static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp)
}
}
else
{
for
(
i
=
0
;
i
<
(
int
)
s
->
img_x
;
++
i
)
{
stbi__uint32
v
=
(
bpp
==
16
?
get16le
(
s
)
:
get32le
(
s
));
stbi__uint32
v
=
(
stbi_uint32
)
(
bpp
==
16
?
get16le
(
s
)
:
get32le
(
s
));
int
a
;
out
[
z
++
]
=
(
stbi__uint8
)
shiftsigned
(
v
&
mr
,
rshift
,
rcount
);
out
[
z
++
]
=
(
stbi__uint8
)
shiftsigned
(
v
&
mg
,
gshift
,
gcount
);
...
...
@@ -4309,11 +4320,11 @@ static float *hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp)
token
=
hdr_gettoken
(
s
,
buffer
);
if
(
strncmp
(
token
,
"-Y "
,
3
))
return
epf
(
"unsupported data layout"
,
"Unsupported HDR format"
);
token
+=
3
;
height
=
strtol
(
token
,
&
token
,
10
);
height
=
(
int
)
strtol
(
token
,
&
token
,
10
);
while
(
*
token
==
' '
)
++
token
;
if
(
strncmp
(
token
,
"+X "
,
3
))
return
epf
(
"unsupported data layout"
,
"Unsupported HDR format"
);
token
+=
3
;
width
=
strtol
(
token
,
NULL
,
10
);
width
=
(
int
)
strtol
(
token
,
NULL
,
10
);
*
x
=
width
;
*
y
=
height
;
...
...
@@ -4421,14 +4432,14 @@ static int stbi_hdr_info(stbi *s, int *x, int *y, int *comp)
return
0
;
}
token
+=
3
;
*
y
=
strtol
(
token
,
&
token
,
10
);
*
y
=
(
int
)
strtol
(
token
,
&
token
,
10
);
while
(
*
token
==
' '
)
++
token
;
if
(
strncmp
(
token
,
"+X "
,
3
))
{
stbi_rewind
(
s
);
return
0
;
}
token
+=
3
;
*
x
=
strtol
(
token
,
NULL
,
10
);
*
x
=
(
int
)
strtol
(
token
,
NULL
,
10
);
*
comp
=
3
;
return
1
;
}
...
...
@@ -4612,6 +4623,7 @@ int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int
various warnings
fix broken STBI_SIMD path
fix bug where stbi_load_from_file no longer left file pointer in correct place
fix broken non-easy path for 32-bit BMP (possibly never used)
1.34 (unknown)
use STBI_NOTUSED in resample_row_generic(), fix one more leak in tga failure case
1.33 (2011-07-14)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录