Move image lib to utils.cpp

This commit is contained in:
augustin64 2025-04-03 16:34:12 +02:00
parent 095b14d3a9
commit a8cfc6a26b
4 changed files with 32 additions and 5 deletions

View File

@ -17,4 +17,9 @@ target_include_directories(seam-carving
PRIVATE
${PROJECT_SOURCE_DIR}/deps
)
target_link_libraries(seam-carving utils)
target_link_libraries(seam-carving utils)
target_include_directories(utils
PRIVATE
${PROJECT_SOURCE_DIR}/deps
)

19
src/image.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef STBIDEF
#ifdef STB_IMAGE_WRITE_STATIC
#define STBIDEF static
#else
#ifdef __cplusplus
#define STBIDEF extern "C"
#else
#define STBIDEF extern
#endif
#endif
#endif
typedef unsigned char stbi_uc;
STBIDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);
STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp);
STBIDEF void stbi_image_free (void *retval_from_stbi_load);

View File

@ -1,4 +1,5 @@
#include <iostream>
#include <cassert>
#include <random>
#include <string>
#include <vector>
@ -6,12 +7,9 @@
#include <CLI11.hpp>
// Image filtering and I/O
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <SimpleProgressBar.hpp>
#include <stb_image_write.h>
#include "utils.hpp"
#include "image.h"
#define DEFAULT_SEAMS 1

View File

@ -1,3 +1,8 @@
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
#include <iostream>
#include <random>
#include <vector>