structurized codebase

This commit is contained in:
antifallobst 2023-03-21 13:12:41 +01:00
parent 5d98c7e88e
commit 07bd5be830
9 changed files with 22 additions and 4 deletions

View File

@ -3,7 +3,8 @@ project(Juniorcamp C)
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_include_directories(Juniorcamp PRIVATE inc)
target_link_directories(Juniorcamp PRIVATE /usr/local/lib/)

View File

Before

Width:  |  Height:  |  Size: 245 KiB

After

Width:  |  Height:  |  Size: 245 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

View File

View File

@ -5,6 +5,7 @@
#include <math.h>
#include <memory.h>
#include <imago2.h>
#include <time.h>
#include "gfx.h"
#define MASK_MULTIPLIER 50
@ -104,9 +105,9 @@ void image_calculate_dist_buffer(image_T* image) {
shortest_dist = (distance_T) {dist, -1};
}
dist = -10;
dist = 0;
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) {
shortest_dist = (distance_T) {dist, 0};
@ -185,14 +186,19 @@ void image_dump(image_T* image) {
}
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[]) {
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");
image_dump(image);
@ -209,6 +215,17 @@ int main(int argc, char* argv[]) {
}
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': {
running = false;
break;