structurized codebase
|
@ -3,7 +3,8 @@ project(Juniorcamp C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
||||||
add_executable(Juniorcamp main.c gfx.c)
|
add_executable(Juniorcamp src/main.c src/gfx.c)
|
||||||
|
|
||||||
target_link_libraries(Juniorcamp imago m X11)
|
target_link_libraries(Juniorcamp imago m X11)
|
||||||
|
target_include_directories(Juniorcamp PRIVATE inc)
|
||||||
target_link_directories(Juniorcamp PRIVATE /usr/local/lib/)
|
target_link_directories(Juniorcamp PRIVATE /usr/local/lib/)
|
Before Width: | Height: | Size: 245 KiB After Width: | Height: | Size: 245 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
@ -5,6 +5,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <imago2.h>
|
#include <imago2.h>
|
||||||
|
#include <time.h>
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
|
||||||
#define MASK_MULTIPLIER 50
|
#define MASK_MULTIPLIER 50
|
||||||
|
@ -104,9 +105,9 @@ void image_calculate_dist_buffer(image_T* image) {
|
||||||
shortest_dist = (distance_T) {dist, -1};
|
shortest_dist = (distance_T) {dist, -1};
|
||||||
}
|
}
|
||||||
|
|
||||||
dist = -10;
|
dist = 0;
|
||||||
dist += dist_last_row[x].distance;
|
dist += dist_last_row[x].distance;
|
||||||
dist += pixel_distance(pixel_row[x - 1], pixel_row[x + 1], mask_row[x]);
|
dist += pixel_distance(pixel_row[x - 1], pixel_row[x + 1], mask_row[x]) * 2;
|
||||||
|
|
||||||
if (x == 0 || shortest_dist.distance > dist) {
|
if (x == 0 || shortest_dist.distance > dist) {
|
||||||
shortest_dist = (distance_T) {dist, 0};
|
shortest_dist = (distance_T) {dist, 0};
|
||||||
|
@ -185,14 +186,19 @@ void image_dump(image_T* image) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx_flush();
|
gfx_flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void image_export(image_T* image, const char* filename) {
|
||||||
|
printf("exporting image to '%s'\n", filename);
|
||||||
|
struct img_pixmap img;
|
||||||
|
img_init(&img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
printf("Line Cutter - Juniorcamp Informatik\n");
|
printf("Line Cutter - Juniorcamp Informatik\n");
|
||||||
|
|
||||||
image_T* image = image_load("../paris.png", "../paris_mask.png");
|
image_T* image = image_load("../bench.png", "../bench_mask.png");
|
||||||
|
|
||||||
gfx_open(800, 600, "Juniorcamp Informatik - Line Cutter");
|
gfx_open(800, 600, "Juniorcamp Informatik - Line Cutter");
|
||||||
image_dump(image);
|
image_dump(image);
|
||||||
|
@ -209,6 +215,17 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'e': {
|
||||||
|
time_t time_raw = time(NULL);
|
||||||
|
struct tm* timestamp = localtime(&time_raw);
|
||||||
|
|
||||||
|
char filename[64];
|
||||||
|
snprintf(filename, 64, "../output/export_%04d-%02d-%02d_%02d-%02d-%02d.png",
|
||||||
|
1900+timestamp->tm_year, 1+timestamp->tm_mon, timestamp->tm_mday,
|
||||||
|
timestamp->tm_hour, timestamp->tm_min, timestamp->tm_sec);
|
||||||
|
image_export(image, filename);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'q': {
|
case 'q': {
|
||||||
running = false;
|
running = false;
|
||||||
break;
|
break;
|