-
Notifications
You must be signed in to change notification settings - Fork 0
/
TileExtractor.cpp
527 lines (400 loc) · 30.7 KB
/
TileExtractor.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
// TileExtractor.cpp : Defines the entry point for the application.
#include "TileExtractor.h"
int main(int argc, char** argv)
{
/*if (argc != 2)
{
printf("usage: TileExtractor.out <Image_Path>\n");
return -1;
}*/
cv::Mat base, edge, overlay;
base = cv::imread("D:\\source\\repos\\Assets\\Sprites\\MT_Terrains_Lite_1.0\\EXTRAS\\Skins.png", cv::IMREAD_UNCHANGED);
edge = cv::imread(/*argv[1]*/ "D:\\source\\repos\\Assets\\Sprites\\MT_Terrains_Lite_1.0\\EXTRAS\\Autotiles A4 Transparent.png", cv::IMREAD_UNCHANGED);
overlay = cv::imread("D:\\source\\repos\\Assets\\Sprites\\MT_Terrains_Lite_1.0\\EXTRAS\\Skins.png", cv::IMREAD_UNCHANGED);
if (!base.data)
{
printf("No image data \n");
return -1;
}
TileExtractor tileExtractor(base, edge, overlay);
return 0;
}
TileExtractor::TileExtractor(cv::Mat Base, cv::Mat Edge, cv::Mat Overlay)
{
bool useOverlay = true;
base = Base;
if (useOverlay) {
edge = Overlay;
} else {
edge = Edge;
}
// Final output image (pixels)
cv::Mat outputTileset = cv::Mat(7 * 4 * tileSize, 7 * 4 * tileSize, CV_8UC4);
unsigned int x1 = 5, y1 = 2, x2 = 6, y2 = 2;
// Top left corner of biome tileset (tiles)
baseOffset = cv::Point(baseTilesetWidth * x1, baseTilesetHeight * y1);
if (useOverlay) {
edgeOffset = cv::Point(baseTilesetWidth * x2, baseTilesetHeight * y2);
} else {
edgeOffset = cv::Point(edgeTilesetWidth * x2, edgeTilesetHeight * y2);
}
// ROI encapsulating one biome of the tileset (pixels)
cv::Rect baseTilesetROI = cv::Rect(baseOffset.x * tileSize, baseOffset.y * tileSize, tileSize * 3, tileSize * 3);
cv::Rect edgeTilesetROI;
if (useOverlay) {
edgeTilesetROI = cv::Rect(edgeOffset.x * tileSize, edgeOffset.y * tileSize, baseTilesetWidth * tileSize, baseTilesetHeight * tileSize);
} else {
edgeTilesetROI = cv::Rect(edgeOffset.x * tileSize, edgeOffset.y * tileSize, edgeTilesetWidth * tileSize, edgeTilesetHeight * tileSize);
}
cv::Mat baseTileset = base(baseTilesetROI);
cv::Mat edgeTileset = edge(edgeTilesetROI);
/*for (unsigned int u = 0; u < 7 * 2; u++)
{
for (unsigned int v = 0; v < 7 * 2; v++)
{
innerTileset.copyTo(outputTileset(cv::Rect(u * tileSize * 2, v * tileSize * 2, tileSize * 2, tileSize * 2)));
}
}*/
/*for (unsigned int u = 0; u < 7 * 2; u++)
{
for (unsigned int v = 0; v < 7 * 2; v++)
{
overlayTileset.copyTo(outputTileset(cv::Rect(u * tileSize * 2, v * tileSize * 2, tileSize * 2, tileSize * 2)));
}
}*/
unsigned int u = 0, v = 0;
for (u = 0; u < 7 * 4; u++)
{
for (v = 0; v < 7 * 4; v++)
{
baseTileset(cv::Rect((u % 3) * tileSize, (v % 3) * tileSize, tileSize, tileSize)).copyTo(outputTileset(cv::Rect(u * tileSize, v * tileSize, tileSize, tileSize)));
}
}
u = 0, v = 0;
writeTile(getTile(edgeTileset, cv::Point(0, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(1, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(4, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 4)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 7)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 4)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 7)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(1, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 4)), outputTileset, cv::Point(u, v), cv::Point(2, 1));
writeTile(getTile(edgeTileset, cv::Point(1, 7)), outputTileset, cv::Point(u, v), cv::Point(1, 2));
writeTile(getTile(edgeTileset, cv::Point(4, 7)), outputTileset, cv::Point(u, v), cv::Point(2, 2));
u = 1, v = 0;
writeTile(getTile(edgeTileset, cv::Point(0, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(1, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 4)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 7)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(1, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(1, 7)), outputTileset, cv::Point(u, v), cv::Point(1, 2));
u = 2, v = 0;
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 3, v = 0;
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
u = 4, v = 0;
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
u = 5, v = 0;
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 6, v = 0;
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(4, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 4)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 4)), outputTileset, cv::Point(u, v), cv::Point(2, 1));
u = 0, v = 1;
writeTile(getTile(edgeTileset, cv::Point(0, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(1, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(4, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 4)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 4)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 4)), outputTileset, cv::Point(u, v), cv::Point(2, 1));
u = 1, v = 1;
writeTile(getTile(edgeTileset, cv::Point(0, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(1, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 4)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
u = 2, v = 1;
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 3, v = 1;
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
u = 4, v = 1;
u = 5, v = 1;
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
u = 6, v = 1;
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
u = 0, v = 2;
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 1, v = 2;
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 2, v = 2;
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
u = 3, v = 2;
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
u = 4, v = 2;
u = 5, v = 2;
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 6, v = 2;
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
u = 0, v = 3;
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
u = 1, v = 3;
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
u = 2, v = 3;
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 3, v = 3;
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 4, v = 3;
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 5, v = 3;
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 6, v = 3;
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
u = 0, v = 4;
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
u = 1, v = 4;
u = 2, v = 4;
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 3, v = 4;
writeTile(getTile(edgeTileset, cv::Point(0, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(1, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 4)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 4, v = 4;
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 7)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(4, 7)), outputTileset, cv::Point(u, v), cv::Point(2, 2));
u = 5, v = 4;
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 6, v = 4;
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 7)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 7)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(1, 7)), outputTileset, cv::Point(u, v), cv::Point(1, 2));
writeTile(getTile(edgeTileset, cv::Point(4, 7)), outputTileset, cv::Point(u, v), cv::Point(2, 2));
u = 0, v = 5;
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 1, v = 5;
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
u = 2, v = 5;
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 3, v = 5;
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 2)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 4, v = 5;
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
u = 5, v = 5;
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 2)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
u = 6, v = 5;
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(4, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 4)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 4)), outputTileset, cv::Point(u, v), cv::Point(2, 1));
u = 0, v = 6;
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 7)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(1, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(1, 7)), outputTileset, cv::Point(u, v), cv::Point(1, 2));
u = 1, v = 6;
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
u = 2, v = 6;
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
u = 3, v = 6;
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 0)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 0)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
u = 4, v = 6;
writeTile(getTile(edgeTileset, cv::Point(2, 3)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(3, 3)), outputTileset, cv::Point(u, v), cv::Point(1, 0));
writeTile(getTile(edgeTileset, cv::Point(4, 3)), outputTileset, cv::Point(u, v), cv::Point(2, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 3)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 4)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 7)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 4)), outputTileset, cv::Point(u, v), cv::Point(2, 1));
writeTile(getTile(edgeTileset, cv::Point(4, 7)), outputTileset, cv::Point(u, v), cv::Point(2, 2));
u = 5, v = 6;
writeTile(getTile(edgeTileset, cv::Point(0, 5)), outputTileset, cv::Point(u, v), cv::Point(0, 0));
writeTile(getTile(edgeTileset, cv::Point(0, 6)), outputTileset, cv::Point(u, v), cv::Point(0, 1));
writeTile(getTile(edgeTileset, cv::Point(0, 7)), outputTileset, cv::Point(u, v), cv::Point(0, 2));
writeTile(getTile(edgeTileset, cv::Point(0, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(1, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(1, 7)), outputTileset, cv::Point(u, v), cv::Point(1, 2));
u = 6, v = 6;
writeTile(getTile(edgeTileset, cv::Point(5, 5)), outputTileset, cv::Point(u, v), cv::Point(3, 0));
writeTile(getTile(edgeTileset, cv::Point(5, 6)), outputTileset, cv::Point(u, v), cv::Point(3, 1));
writeTile(getTile(edgeTileset, cv::Point(5, 7)), outputTileset, cv::Point(u, v), cv::Point(3, 2));
writeTile(getTile(edgeTileset, cv::Point(2, 8)), outputTileset, cv::Point(u, v), cv::Point(0, 3));
writeTile(getTile(edgeTileset, cv::Point(3, 8)), outputTileset, cv::Point(u, v), cv::Point(1, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 8)), outputTileset, cv::Point(u, v), cv::Point(2, 3));
writeTile(getTile(edgeTileset, cv::Point(5, 8)), outputTileset, cv::Point(u, v), cv::Point(3, 3));
writeTile(getTile(edgeTileset, cv::Point(4, 7)), outputTileset, cv::Point(u, v), cv::Point(2, 2));
/*std::string outputPath = "D:\\source\\repos\\Assets\\Sprites\\MT_Terrains_Lite_1.0\\EXTRAS\\" + baseOffset.x;
outputPath += baseOffset.y;
outputPath += ".png";*/
cv::imwrite("D:\\source\\repos\\Assets\\Sprites\\MT_Terrains_Lite_1.0\\EXTRAS\\image.png", outputTileset);
cv::namedWindow("Display Image", cv::WINDOW_KEEPRATIO);
cv::imshow("Display Image", outputTileset);
cv::waitKey(0);
}
cv::Mat TileExtractor::getTile(cv::Mat input, cv::Point offset, cv::Point coordinates)
{
cv::Mat tile;
input(cv::Rect((offset.x + coordinates.x) * tileSize, (offset.y + coordinates.y) * tileSize, tileSize, tileSize)).copyTo(tile);
return tile;
}
cv::Mat TileExtractor::getTile(cv::Mat input, cv::Point coordinates)
{
cv::Mat tile;
input(cv::Rect(coordinates.x * tileSize, coordinates.y * tileSize, tileSize, tileSize)).copyTo(tile);
return tile;
}
void TileExtractor::writeTile(cv::Mat input, cv::Mat& output, cv::Point offset, cv::Point coordinates)
{
input.copyTo(output(cv::Rect((offset.x * 4 + coordinates.x) * tileSize, (offset.y * 4 + coordinates.y) * tileSize, tileSize, tileSize)));
}