diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a2aa91e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,65 @@ +#Specify the version being used aswell as the language +cmake_minimum_required(VERSION 2.8) + +#Name your project here +project(2netpbm) + +#set the module directory +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}") + +#build the executable in the binary directory on MS Visual Studio +if ( MSVC ) + SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}") + SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}") + SET( LIBRARY_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}") + SET( LIBRARY_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}") + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_SCL_SECURE_NO_WARNINGS) +endif ( MSVC ) + +#find packages----------------------------------- +#find OpenCV +find_package(OpenCV REQUIRED) + +#find the pthreads package +find_package(Threads) + +#find the X11 package +find_package(X11) + +#find the STIM library +find_package(STIM) + +#find Boost for Unix-based file lists +if( CMAKE_COMPILER_IS_GNUCC ) + find_package(Boost COMPONENTS filesystem system) + if(Boost_FOUND) + add_definitions(-DBOOST_PRECOMPILED) + include_directories(${Boost_INCLUDE_DIR}) + else(Boost_FOUND) + message(FATAL_ERROR "HSIproc requires Boost::filesystem and Boost::system when using GCC") + endif(Boost_FOUND) +endif( CMAKE_COMPILER_IS_GNUCC ) + +#set the STIM include directory (either user provided or downloaded) +include_directories(${STIM_INCLUDE_DIRS}) + +#Assign source files to the appropriate variables to easily associate them with executables +file(GLOB SRC_CPP "*.cpp") +file(GLOB SRC_H "*.h") + +#create an executable file +add_executable(2netpbm + ${SRC_CPP} + ${SRC_H} +) + +#set the link libraries +target_link_libraries(2netpbm + ${OpenCV_LIBS} + ${X11_LIBRARIES} +) + +#copy data files to the binary directory +file(COPY data/skyrim.jpg DESTINATION .) +file(COPY data/galaxy.jpg DESTINATION .) \ No newline at end of file diff --git a/FindSTIM.cmake b/FindSTIM.cmake new file mode 100644 index 0000000..65a6fde --- /dev/null +++ b/FindSTIM.cmake @@ -0,0 +1,11 @@ +# set STIMLIB_PATH to the directory containing the stim subdirectory (the stim repository) + +include(FindPackageHandleStandardArgs) + +set(STIM_INCLUDE_DIR $ENV{STIMLIB_PATH}) + +find_package_handle_standard_args(STIM DEFAULT_MSG STIM_INCLUDE_DIR) + +if(STIM_FOUND) + set(STIM_INCLUDE_DIRS ${STIM_INCLUDE_DIR}) +endif() diff --git a/data/galaxy.jpg b/data/galaxy.jpg new file mode 100644 index 0000000..50923ce Binary files /dev/null and b/data/galaxy.jpg differ diff --git a/data/skyrim.jpg b/data/skyrim.jpg new file mode 100644 index 0000000..804fcda Binary files /dev/null and b/data/skyrim.jpg differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..1ece474 --- /dev/null +++ b/main.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) { + stim::arglist args; + + args.parse(argc, argv); + + if (args.nargs() == 0) { + std::cout << "Specify a file or file list to convert images to Netpbm." << std::endl; + exit(0); + } + + stim::filename fmask(args.arg(0)); + stim::filepath fpath("."); //default to the current file path + if (args.nargs() == 2) fpath = args.arg(1); //if a destination path is specified, save there + + if (fmask.wildcards()) { //if the given file name contains wild cards + std::vector flist; //declare an STL vector + flist = fmask.get_list(); //get the corresponding file list + + for (size_t i = 0; i < flist.size(); i++) { //for each file in the list + stim::image I(flist[i].str()); //load the corresponding image + std::string outname = fpath.str() + flist[i].prefix() + ".ppm"; + std::cout << "Saving " << outname << std::endl; + I.save_netpbm(outname); //save the file as a PPM + } + } + else { + stim::image I(fmask.str()); + I.save(fmask.str() + ".ppm"); + } +} \ No newline at end of file -- libgit2 0.21.4