Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
816f31e9
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,发现更多精彩内容 >>
提交
816f31e9
编写于
7月 07, 2014
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes and tests
上级
4b590c0a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
197 addition
and
5 deletion
+197
-5
stb_herringbone_wang_tile.h
stb_herringbone_wang_tile.h
+7
-5
tests/herringbone_map.c
tests/herringbone_map.c
+82
-0
tests/herringbone_map.dsp
tests/herringbone_map.dsp
+94
-0
tests/stb.dsw
tests/stb.dsw
+12
-0
tests/test_c_compilation.c
tests/test_c_compilation.c
+2
-0
未找到文件。
stb_herringbone_wang_tile.h
浏览文件 @
816f31e9
/* stbhw-v0.
01
- public domain - http://nothings.org/stb/stb_herringbone_wang_tile.h
/* stbhw-v0.
5
- public domain - http://nothings.org/stb/stb_herringbone_wang_tile.h
Herringbone Wang Tile Generator - Sean Barrett 2014
This file is in the public domain. In case that declaration is ineffective,
...
...
@@ -442,11 +442,10 @@ static void stbhw__get_template_info(stbhw_config *c, int *w, int *h, int *h_cou
size_x
=
horz_x
>
vert_x
?
horz_x
:
vert_x
;
size_y
=
2
+
horz_y
+
2
+
vert_y
;
}
else
{
// @TODO: non-corner-tile
int
horz_w
=
c
->
num_color
[
0
]
*
c
->
num_color
[
1
]
*
c
->
num_color
[
2
]
*
c
->
num_vary_x
;
int
horz_h
=
c
->
num_color
[
3
]
*
c
->
num_color
[
4
]
*
c
->
num_color
[
2
]
*
c
->
num_vary_y
;
int
vert_w
=
c
->
num_color
[
0
]
*
c
->
num_color
[
5
]
*
c
->
num_color
[
2
]
*
c
->
num_vary_y
;
int
vert_w
=
c
->
num_color
[
0
]
*
c
->
num_color
[
5
]
*
c
->
num_color
[
1
]
*
c
->
num_vary_y
;
int
vert_h
=
c
->
num_color
[
3
]
*
c
->
num_color
[
4
]
*
c
->
num_color
[
5
]
*
c
->
num_vary_x
;
int
horz_x
=
horz_w
*
(
2
*
c
->
short_side_len
+
3
);
...
...
@@ -485,6 +484,9 @@ static int stbhw__process_template(stbhw__process *p)
return
0
;
}
for
(
j
=
0
;
j
<
p
->
h
;
++
j
)
memset
(
p
->
data
+
j
*
p
->
stride
,
255
,
3
*
p
->
w
);
if
(
c
->
is_corner
)
{
ypos
=
2
;
for
(
k
=
0
;
k
<
c
->
num_color
[
2
];
++
k
)
{
...
...
@@ -922,6 +924,7 @@ STBHW_EXTERN int stbhw_build_tileset_from_image(stbhw_tileset *ts, unsigned char
p
.
process_v_rect
=
stbhw__parse_v_rect
;
p
.
w
=
w
;
p
.
h
=
h
;
p
.
c
=
&
c
;
// load all the tiles out of the image
return
stbhw__process_template
(
&
p
);
...
...
@@ -1160,8 +1163,6 @@ static void stbhw__corner_process_v_rect(stbhw__process *p, int xpos, int ypos,
stbhw__set_pixel
(
p
->
data
,
p
->
stride
,
xpos
+
len
+
1
,
ypos
+
2
*
len
+
1
,
stbhw__corner_colors
[
3
][
f
]);
}
#endif // STB_HBWANG_IMPLEMENTATION
// generates a template image, assuming data is 3*w*h bytes long, RGB format
STBHW_EXTERN
int
stbhw_make_template
(
stbhw_config
*
c
,
unsigned
char
*
data
,
int
w
,
int
h
,
int
stride_in_bytes
)
{
...
...
@@ -1208,3 +1209,4 @@ STBHW_EXTERN int stbhw_make_template(stbhw_config *c, unsigned char *data, int w
return
1
;
}
#endif // STB_HBWANG_IMPLEMENTATION
tests/herringbone_map.c
0 → 100644
浏览文件 @
816f31e9
#include <stdio.h>
#define STB_HBWANG_MAX_X 500
#define STB_HBWANG_MAX_Y 500
#define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION
#include "stb_herringbone_wang_tile.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
5
)
{
fprintf
(
stderr
,
"Usage: herringbone_map {inputfile} {output-width} {output-height} {outputfile}
\n
"
);
return
1
;
}
else
{
char
*
filename
=
argv
[
1
];
int
out_w
=
atoi
(
argv
[
2
]);
int
out_h
=
atoi
(
argv
[
3
]);
char
*
outfile
=
argv
[
4
];
unsigned
char
*
pixels
,
*
out_pixels
;
stbhw_tileset
ts
;
int
w
,
h
;
pixels
=
stbi_load
(
filename
,
&
w
,
&
h
,
0
,
3
);
if
(
pixels
==
0
)
{
fprintf
(
stderr
,
"Could open input file '%s'
\n
"
,
filename
);
}
if
(
!
stbhw_build_tileset_from_image
(
&
ts
,
pixels
,
w
*
3
,
w
,
h
))
{
fprintf
(
stderr
,
"Error: %s
\n
"
,
stbhw_get_last_error
());
return
1
;
}
free
(
pixels
);
#ifdef DEBUG_OUTPUT
{
int
i
,
j
,
k
;
// add blue borders to top-left edges of the tiles
int
hstride
=
(
ts
.
short_side_len
*
2
)
*
3
;
int
vstride
=
(
ts
.
short_side_len
)
*
3
;
for
(
i
=
0
;
i
<
ts
.
num_h_tiles
;
++
i
)
{
unsigned
char
*
pix
=
ts
.
h_tiles
[
i
]
->
pixels
;
for
(
j
=
0
;
j
<
ts
.
short_side_len
*
2
;
++
j
)
for
(
k
=
0
;
k
<
3
;
++
k
)
pix
[
j
*
3
+
k
]
=
(
pix
[
j
*
3
+
k
]
*
0
.
5
+
100
+
k
*
75
)
/
1
.
5
;
for
(
j
=
1
;
j
<
ts
.
short_side_len
;
++
j
)
for
(
k
=
0
;
k
<
3
;
++
k
)
pix
[
j
*
hstride
+
k
]
=
(
pix
[
j
*
hstride
+
k
]
*
0
.
5
+
100
+
k
*
75
)
/
1
.
5
;
}
for
(
i
=
0
;
i
<
ts
.
num_v_tiles
;
++
i
)
{
unsigned
char
*
pix
=
ts
.
v_tiles
[
i
]
->
pixels
;
for
(
j
=
0
;
j
<
ts
.
short_side_len
;
++
j
)
for
(
k
=
0
;
k
<
3
;
++
k
)
pix
[
j
*
3
+
k
]
=
(
pix
[
j
*
3
+
k
]
*
0
.
5
+
100
+
k
*
75
)
/
1
.
5
;
for
(
j
=
1
;
j
<
ts
.
short_side_len
*
2
;
++
j
)
for
(
k
=
0
;
k
<
3
;
++
k
)
pix
[
j
*
vstride
+
k
]
=
(
pix
[
j
*
vstride
+
k
]
*
0
.
5
+
100
+
k
*
75
)
/
1
.
5
;
}
}
#endif
out_pixels
=
malloc
(
out_w
*
out_h
*
3
);
if
(
!
stbhw_generate_image
(
&
ts
,
NULL
,
out_pixels
,
out_w
*
3
,
out_w
,
out_h
))
{
fprintf
(
stderr
,
"Error: %s
\n
"
,
stbhw_get_last_error
());
return
1
;
}
stbi_write_png
(
argv
[
4
],
out_w
,
out_h
,
3
,
out_pixels
,
out_w
*
3
);
free
(
out_pixels
);
stbhw_free_tileset
(
&
ts
);
return
0
;
}
}
\ No newline at end of file
tests/herringbone_map.dsp
0 → 100644
浏览文件 @
816f31e9
# Microsoft Developer Studio Project File - Name="herringbone_map" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=herringbone_map - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "herringbone_map.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "herringbone_map.mak" CFG="herringbone_map - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "herringbone_map - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "herringbone_map - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "herringbone_map - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# 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 /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
# ADD BASE BSC32 /nologo
# 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
!ELSEIF "$(CFG)" == "herringbone_map - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "herringbone_map___Win32_Debug"
# PROP BASE Intermediate_Dir "herringbone_map___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# 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 /debug /machine:I386 /pdbtype:sept
# 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 /pdbtype:sept
!ENDIF
# Begin Target
# Name "herringbone_map - Win32 Release"
# Name "herringbone_map - Win32 Debug"
# Begin Source File
SOURCE=.\herringbone_map.c
# End Source File
# Begin Source File
SOURCE=..\stb_herringbone_wang_tile.h
# End Source File
# End Target
# End Project
tests/stb.dsw
浏览文件 @
816f31e9
...
...
@@ -27,6 +27,18 @@ Package=<4>
###############################################################################
Project: "herringbone_map"=.\herringbone_map.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "image_test"=.\image_test.dsp - Package Owner=<4>
Package=<5>
...
...
tests/test_c_compilation.c
浏览文件 @
816f31e9
...
...
@@ -4,7 +4,9 @@
#define STB_C_LEXER_IMPLEMENTATIOn
#define STB_DIVIDE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_HERRINGBONE_WANG_TILE_IMEPLEMENTATIOn
#include "stb_herringbone_wang_tile.h"
#include "stb_image.h"
#include "stb_image_write.h"
#include "stb_perlin.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录