-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexample.cpp
47 lines (34 loc) · 1.29 KB
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#define STB_IMAGE_IMPLEMENTATION
#include "include/stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "include/stb_image_write.h"
#define CONVERTER_IMPLEMENTATION
#include "../src/converter.hpp"
#ifndef CHANNEL_NUM
#define CHANNEL_NUM 4
#endif
int main(int argc, char **argv)
{
Converter::Image img;
Converter::Image faces[Converter::FACE_NUM];
int w, h, bpp;
for (int i = 0; i < Converter::FACE_NUM; ++i)
{
faces[i].img = stbi_load(argv[i + 1], &w, &h, &bpp, CHANNEL_NUM);
faces[i].h = h, faces[i].w = w;
}
Converter::Face face = Converter::Face(faces);
img = face.getFace(Converter::FRONT);
stbi_write_png("out/front.png", img.w, img.h, CHANNEL_NUM, img.img, img.w * CHANNEL_NUM);
Converter::Cube cube = face.toCube();
img = cube.getCubeMap();
stbi_write_png("out/cubemap.png", img.w, img.h, CHANNEL_NUM, img.img, img.w * CHANNEL_NUM);
Converter::Equi equi = face.toEqui();
img = equi.getEqui();
stbi_write_png("out/equi.png", img.w, img.h, CHANNEL_NUM, img.img, img.w * CHANNEL_NUM);
img = equi.toStereo().getStereo();
stbi_write_png("out/stereo.png", img.w, img.h, CHANNEL_NUM, img.img, img.w * CHANNEL_NUM);
img = equi.toStereo(Converter::TOP).toEqui().getEqui();
stbi_write_png("out/equi.png", img.w, img.h, CHANNEL_NUM, img.img, img.w * CHANNEL_NUM);
return 0;
}