Skip to content
This repository was archived by the owner on Mar 15, 2023. It is now read-only.

Commit 3ce3cf9

Browse files
committed
Initial version
1 parent 3ab318a commit 3ce3cf9

File tree

9 files changed

+9304
-0
lines changed

9 files changed

+9304
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@
3131
# Debug files
3232
*.dSYM/
3333
*.su
34+
35+
# CMake
36+
cmake-build-*/
37+
38+
# IDE
39+
.idea/

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required(VERSION 3.6)
2+
project(normalmap)
3+
4+
set(CMAKE_C_STANDARD 11)
5+
set(CMAKE_CXX_STANDARD 11)
6+
7+
include_directories(include)
8+
9+
set(SOURCE_FILES
10+
include/stb_image.h
11+
src/main.c
12+
src/stb_image.c
13+
src/normalmap.c
14+
include/normalmap.h include/stb_image_write.h src/stb_image_write.c)
15+
16+
add_executable(normalmap ${SOURCE_FILES})

include/normalmap.h

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
Copyright (C) 2002-2008 Shawn Kirst <skirst@insightbb.com>
3+
4+
This program is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU General Public
6+
License as published by the Free Software Foundation; either
7+
version 2 of the License, or (at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program; see the file COPYING. If not, write to
16+
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17+
Boston, MA 02111-1307, USA.
18+
*/
19+
#ifndef NORMAL_MAP
20+
#define NORMAL_MAP
21+
22+
#include <stdint.h>
23+
24+
#define ENUM_EACH(PARAM) PARAM,
25+
#define STR_EACH(PARAM) #PARAM,
26+
#define STR_EACH_SEP_WS(PARAM) #PARAM " "
27+
28+
#define EACH_FILTER_TYPE(DO) \
29+
DO(FILTER_NONE) \
30+
DO(FILTER_SOBEL_3x3) \
31+
DO(FILTER_SOBEL_5x5) \
32+
DO(FILTER_PREWITT_3x3) \
33+
DO(FILTER_PREWITT_5x5) \
34+
DO(FILTER_3x3) \
35+
DO(FILTER_5x5) \
36+
DO(FILTER_7x7) \
37+
DO(FILTER_9x9) \
38+
DO(MAX_FILTER_TYPE)
39+
#define FILTER_TYPE_COUNT (10)
40+
41+
enum FILTER_TYPE { EACH_FILTER_TYPE(ENUM_EACH) };
42+
43+
static char * FILTER_TYPE_NAMES[] = {
44+
EACH_FILTER_TYPE(STR_EACH)
45+
};
46+
47+
enum ALPHA_TYPE
48+
{
49+
ALPHA_NONE, ALPHA_HEIGHT, ALPHA_INVERSE_HEIGHT, ALPHA_ZERO, ALPHA_ONE,
50+
ALPHA_INVERT, ALPHA_MAP, MAX_ALPHA_TYPE
51+
};
52+
53+
enum CONVERSION_TYPE
54+
{
55+
CONVERT_NONE, CONVERT_BIASED_RGB, CONVERT_RED, CONVERT_GREEN,
56+
CONVERT_BLUE, CONVERT_MAX_RGB, CONVERT_MIN_RGB, CONVERT_COLORSPACE,
57+
CONVERT_NORMALIZE_ONLY, CONVERT_DUDV_TO_NORMAL, CONVERT_HEIGHTMAP,
58+
CONVERT_KEY_RGB,
59+
MAX_CONVERSION_TYPE
60+
};
61+
62+
enum DUDV_TYPE
63+
{
64+
DUDV_NONE, DUDV_8BIT_SIGNED, DUDV_8BIT_UNSIGNED, DUDV_16BIT_SIGNED,
65+
DUDV_16BIT_UNSIGNED,
66+
MAX_DUDV_TYPE
67+
};
68+
69+
typedef struct
70+
{
71+
int filter;
72+
double minz;
73+
double scale;
74+
int wrap;
75+
int height_source;
76+
int alpha;
77+
int conversion;
78+
int dudv;
79+
int xinvert;
80+
int yinvert;
81+
int swapRGB;
82+
double contrast;
83+
int32_t alphamap_id;
84+
} NormalmapVals;
85+
86+
int32_t normalmap(uint8_t * img, uint8_t * nm_img, size_t dx, size_t dy, NormalmapVals nmapvals);
87+
88+
89+
#endif

0 commit comments

Comments
 (0)