Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
a0d4f790
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,发现更多精彩内容 >>
提交
a0d4f790
编写于
9月 13, 2014
作者:
J
Jorge Rodriguez
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7 from nothings/resample
Resample
上级
29b36b3d
385d7a41
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
1783 addition
and
1540 deletion
+1783
-1540
stb_image_resize.h
stb_image_resize.h
+1715
-1509
tests/resample_test.cpp
tests/resample_test.cpp
+48
-17
tests/resize.dsp
tests/resize.dsp
+3
-2
tools/README.list
tools/README.list
+13
-12
tools/make_readme.dsp
tools/make_readme.dsp
+4
-0
未找到文件。
stb_image_resize.h
浏览文件 @
a0d4f790
此差异已折叠。
点击以展开。
tests/resample_test.cpp
浏览文件 @
a0d4f790
...
...
@@ -141,6 +141,34 @@ static void resizer(int argc, char **argv)
exit
(
0
);
}
static
void
performance
(
int
argc
,
char
**
argv
)
{
unsigned
char
*
input_pixels
;
unsigned
char
*
output_pixels
;
int
w
,
h
,
count
;
int
n
,
i
;
int
out_w
,
out_h
,
srgb
=
1
;
input_pixels
=
stbi_load
(
argv
[
1
],
&
w
,
&
h
,
&
n
,
0
);
#if 1
out_w
=
w
/
4
;
out_h
h
/
4
;
count
=
100
;
// 1
#elif 0
out_w
=
w
*
2
;
out_h
=
h
/
4
;
count
=
20
;
// 2 // note this is structured pessimily, would be much faster to downsample vertically first
#elif 0
out_w
=
w
/
4
;
out_h
=
h
*
2
;
count
=
50
;
// 3
#elif 0
out_w
=
w
*
3
;
out_h
=
h
*
3
;
count
=
5
;
srgb
=
0
;
// 4
#else
out_w
=
w
*
3
;
out_h
=
h
*
3
;
count
=
3
;
// 5 // this is dominated by linear->sRGB conversion
#endif
output_pixels
=
(
unsigned
char
*
)
malloc
(
out_w
*
out_h
*
n
);
for
(
i
=
0
;
i
<
count
;
++
i
)
if
(
srgb
)
stbir_resize_uint8_srgb
(
input_pixels
,
w
,
h
,
0
,
output_pixels
,
out_w
,
out_h
,
0
,
n
,
-
1
,
0
);
else
stbir_resize_uint8
(
input_pixels
,
w
,
h
,
0
,
output_pixels
,
out_w
,
out_h
,
0
,
n
);
exit
(
0
);
}
void
test_suite
(
int
argc
,
char
**
argv
);
...
...
@@ -153,6 +181,7 @@ int main(int argc, char** argv)
int
out_w
,
out_h
,
out_stride
;
//resizer(argc, argv);
//performance(argc, argv);
#if 1
test_suite
(
argc
,
argv
);
...
...
@@ -619,10 +648,10 @@ void verify_box(void)
+
image88
[
j
*
2
+
0
][
i
*
2
+
1
]
+
image88
[
j
*
2
+
1
][
i
*
2
+
0
]
+
image88
[
j
*
2
+
1
][
i
*
2
+
1
];
STBIR_ASSERT
(
output44
[
j
][
i
]
==
((
n
+
2
)
>>
2
)
);
STBIR_ASSERT
(
output44
[
j
][
i
]
==
((
n
+
2
)
>>
2
)
||
output44
[
j
][
i
]
==
((
n
+
1
)
>>
2
));
// can't guarantee exact rounding due to numerical precision
t
+=
n
;
}
STBIR_ASSERT
(
output11
[
0
][
0
]
==
((
t
+
32
)
>>
6
)
);
STBIR_ASSERT
(
output11
[
0
][
0
]
==
((
t
+
32
)
>>
6
)
||
output11
[
0
][
0
]
==
((
t
+
31
)
>>
6
));
// can't guarantee exact rounding due to numerical precision
}
void
verify_filter_normalized
(
stbir_filter
filter
,
int
output_size
,
unsigned
int
value
)
...
...
@@ -646,6 +675,8 @@ void test_filters(void)
{
int
i
,
j
;
mtsrand
(
0
);
for
(
i
=
0
;
i
<
sizeof
(
image88
);
++
i
)
image88
[
0
][
i
]
=
mtrand
()
&
255
;
verify_box
();
...
...
@@ -673,25 +704,25 @@ void test_filters(void)
verify_filter_normalized
(
STBIR_FILTER_BOX
,
8
,
value
);
verify_filter_normalized
(
STBIR_FILTER_TRIANGLE
,
8
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CUBIC
,
8
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CUBIC
BSPLINE
,
8
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CATMULLROM
,
8
,
value
);
verify_filter_normalized
(
STBIR_FILTER_MITCHELL
,
8
,
value
);
verify_filter_normalized
(
STBIR_FILTER_BOX
,
4
,
value
);
verify_filter_normalized
(
STBIR_FILTER_TRIANGLE
,
4
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CUBIC
,
4
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CUBIC
BSPLINE
,
4
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CATMULLROM
,
4
,
value
);
verify_filter_normalized
(
STBIR_FILTER_MITCHELL
,
4
,
value
);
verify_filter_normalized
(
STBIR_FILTER_BOX
,
2
,
value
);
verify_filter_normalized
(
STBIR_FILTER_TRIANGLE
,
2
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CUBIC
,
2
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CUBIC
BSPLINE
,
2
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CATMULLROM
,
2
,
value
);
verify_filter_normalized
(
STBIR_FILTER_MITCHELL
,
2
,
value
);
verify_filter_normalized
(
STBIR_FILTER_BOX
,
1
,
value
);
verify_filter_normalized
(
STBIR_FILTER_TRIANGLE
,
1
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CUBIC
,
1
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CUBIC
BSPLINE
,
1
,
value
);
verify_filter_normalized
(
STBIR_FILTER_CATMULLROM
,
1
,
value
);
verify_filter_normalized
(
STBIR_FILTER_MITCHELL
,
1
,
value
);
...
...
@@ -915,17 +946,17 @@ void test_suite(int argc, char **argv)
test_channels
(
barbara
,
2
,
2
,
4
);
// filter tests
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_BOX
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-nearest.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_TRIANGLE
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-bilinear.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_CUBIC
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-bicubic.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_CATMULLROM
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-catmullrom.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_MITCHELL
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-mitchell.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_BOX
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-nearest.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_TRIANGLE
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-bilinear.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_CUBIC
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-bicubic.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_CATMULLROM
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-catmullrom.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_MITCHELL
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-mitchell.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_BOX
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-nearest.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_TRIANGLE
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-bilinear.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_CUBIC
BSPLINE
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-bicubic.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_CATMULLROM
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-catmullrom.png"
);
resize_image
(
barbara
,
2
,
2
,
STBIR_FILTER_MITCHELL
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-upsample-mitchell.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_BOX
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-nearest.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_TRIANGLE
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-bilinear.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_CUBIC
BSPLINE
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-bicubic.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_CATMULLROM
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-catmullrom.png"
);
resize_image
(
barbara
,
0.5
f
,
0.5
f
,
STBIR_FILTER_MITCHELL
,
STBIR_EDGE_CLAMP
,
STBIR_COLORSPACE_SRGB
,
"test-output/barbara-downsample-mitchell.png"
);
for
(
i
=
10
;
i
<
100
;
i
++
)
{
...
...
tests/resize.dsp
浏览文件 @
a0d4f790
...
...
@@ -39,9 +39,10 @@ RSC=rc.exe
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /
W3 /GX /O2
/D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /
G6 /W3 /GX /Z7 /O2 /I ".."
/D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
...
...
@@ -49,7 +50,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /
debug /
machine:I386
!ELSEIF "$(CFG)" == "resize - Win32 Debug"
...
...
tools/README.list
浏览文件 @
a0d4f790
stb_vorbis.c | audio | decode ogg vorbis files from file/memory to float/16-bit signed output
stb_image.h | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
stb_truetype.h | graphics | parse, decode, and rasterize characters from truetype fonts
stb_image_write.h | graphics | image writing to disk: PNG, TGA, BMP
stretchy_buffer.h | utility | typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++
stb_textedit.h | UI | guts of a text editor for games etc implementing them from scratch
stb_dxt.h | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor
stb_herringbone_wang_tile.h | games | herringbone Wang tile map generator
stb_perlin.h | 3D graphics | revised Perlin noise (3D input, 1D output)
stb_c_lexer.h | parsing | simplify writing parsers for C-like languages
stb_divide.h | math | more useful 32-bit modulus e.g. "euclidean divide"
stb.h | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff
stb_vorbis.c | audio | decode ogg vorbis files from file/memory to float/16-bit signed output
stb_image.h | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
stb_truetype.h | graphics | parse, decode, and rasterize characters from truetype fonts
stb_image_write.h | graphics | image writing to disk: PNG, TGA, BMP
stb_image_resize.h | graphics | resize images larger/smaller with good quality
stretchy_buffer.h | utility | typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++
stb_textedit.h | UI | guts of a text editor for games etc implementing them from scratch
stb_dxt.h | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor
stb_perlin.h | 3D graphics | revised Perlin noise (3D input, 1D output)
stb_herringbone_wang_tile.h | games | herringbone Wang tile map generator
stb_c_lexer.h | parsing | simplify writing parsers for C-like languages
stb_divide.h | math | more useful 32-bit modulus e.g. "euclidean divide"
stb.h | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff
tools/make_readme.dsp
浏览文件 @
a0d4f790
...
...
@@ -84,5 +84,9 @@ LINK32=link.exe
SOURCE=.\make_readme.c
# End Source File
# Begin Source File
SOURCE=.\README.list
# End Source File
# End Target
# End Project
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录