diff --git a/.gitignore b/.gitignore index 78b6bcd..2887111 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ **/Debug **/Release *.user -*.filter +*.filters *.o *.map *.lib diff --git a/Rgb2Hires_PC/RgbToHiRes.sln b/Rgb2Hires_PC/RgbToHiRes.sln index cfc01db..2c35e07 100644 --- a/Rgb2Hires_PC/RgbToHiRes.sln +++ b/Rgb2Hires_PC/RgbToHiRes.sln @@ -6,6 +6,14 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libRgb2Hires", "projects\libRgb2Hires\libRgb2Hires.vcxproj", "{CA6F93C8-86B1-4F88-A1E8-8613ED5802AB}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Picture", "projects\picture\Picture.vcxproj", "{754364B2-84E3-40A5-B838-C153775D8F4C}" + ProjectSection(ProjectDependencies) = postProject + {CA6F93C8-86B1-4F88-A1E8-8613ED5802AB} = {CA6F93C8-86B1-4F88-A1E8-8613ED5802AB} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tile", "projects\Tile\Tile.vcxproj", "{C0C03B35-A98E-4F57-9399-A07068B23AB2}" + ProjectSection(ProjectDependencies) = postProject + {CA6F93C8-86B1-4F88-A1E8-8613ED5802AB} = {CA6F93C8-86B1-4F88-A1E8-8613ED5802AB} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -31,6 +39,14 @@ Global {754364B2-84E3-40A5-B838-C153775D8F4C}.Release|x64.Build.0 = Release|x64 {754364B2-84E3-40A5-B838-C153775D8F4C}.Release|x86.ActiveCfg = Release|Win32 {754364B2-84E3-40A5-B838-C153775D8F4C}.Release|x86.Build.0 = Release|Win32 + {C0C03B35-A98E-4F57-9399-A07068B23AB2}.Debug|x64.ActiveCfg = Debug|x64 + {C0C03B35-A98E-4F57-9399-A07068B23AB2}.Debug|x64.Build.0 = Debug|x64 + {C0C03B35-A98E-4F57-9399-A07068B23AB2}.Debug|x86.ActiveCfg = Debug|Win32 + {C0C03B35-A98E-4F57-9399-A07068B23AB2}.Debug|x86.Build.0 = Debug|Win32 + {C0C03B35-A98E-4F57-9399-A07068B23AB2}.Release|x64.ActiveCfg = Release|x64 + {C0C03B35-A98E-4F57-9399-A07068B23AB2}.Release|x64.Build.0 = Release|x64 + {C0C03B35-A98E-4F57-9399-A07068B23AB2}.Release|x86.ActiveCfg = Release|Win32 + {C0C03B35-A98E-4F57-9399-A07068B23AB2}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Rgb2Hires_PC/projects/Tile/Tile.vcxproj b/Rgb2Hires_PC/projects/Tile/Tile.vcxproj new file mode 100644 index 0000000..ec46349 --- /dev/null +++ b/Rgb2Hires_PC/projects/Tile/Tile.vcxproj @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {c0c03b35-a98e-4f57-9399-a07068b23ab2} + Tile + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)\src;$(MAGICK_HOME)\ImageMagick\Magick++\lib;$(MAGICK_HOME)\ImageMagick + + + Console + true + $(OutDir);$(MAGICK_HOME)\VisualMagick\lib + CORE_DB_Magick++_.lib;CORE_DB_Magick_.lib;CORE_DB_wand_.lib;libRgb2Hires.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)\src;$(MAGICK_HOME)\ImageMagick\Magick++\lib;$(MAGICK_HOME)\ImageMagick + + + Console + true + true + true + $(OutDir);$(MAGICK_HOME)\VisualMagick\lib + CORE_RL_Magick++_.lib;CORE_RL_Magick_.lib;CORE_RL_wand_.lib;libRgb2Hires.lib;%(AdditionalDependencies) + + + + + + + + + \ No newline at end of file diff --git a/Rgb2Hires_PC/projects/Tile/Tile.vcxproj.filters b/Rgb2Hires_PC/projects/Tile/Tile.vcxproj.filters new file mode 100644 index 0000000..4aef4af --- /dev/null +++ b/Rgb2Hires_PC/projects/Tile/Tile.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/Rgb2Hires_PC/projects/libRgb2Hires/libRgb2Hires.vcxproj.filters b/Rgb2Hires_PC/projects/libRgb2Hires/libRgb2Hires.vcxproj.filters deleted file mode 100644 index 948682d..0000000 --- a/Rgb2Hires_PC/projects/libRgb2Hires/libRgb2Hires.vcxproj.filters +++ /dev/null @@ -1,48 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/Rgb2Hires_PC/src/App_Picture.cpp b/Rgb2Hires_PC/src/App_Picture.cpp index 89246cf..2e11c24 100644 --- a/Rgb2Hires_PC/src/App_Picture.cpp +++ b/Rgb2Hires_PC/src/App_Picture.cpp @@ -45,7 +45,7 @@ int main( int argc, char *argv[] ) Magick::InitializeMagick(*argv); //Parsing command line - TCLAP::CmdLine cmd("rgbtohires", ' ', "0"); + TCLAP::CmdLine cmd("Picture", ' ', "0"); TCLAP::ValueArg imagePath("i", "image", "Source image path", true, "", "path_to_image"); TCLAP::ValueArg outputPath("o", "output", "Output path", true, "", "path_to_output"); TCLAP::SwitchArg assembly("a", "asm", "Output asm format"); diff --git a/Rgb2Hires_PC/src/App_Tile.cpp b/Rgb2Hires_PC/src/App_Tile.cpp new file mode 100644 index 0000000..02f31c9 --- /dev/null +++ b/Rgb2Hires_PC/src/App_Tile.cpp @@ -0,0 +1,83 @@ + +/* Rgb2Hires +* Copyright (C) 2020 Christophe Meneboeuf +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + + +#include +#include +#include +#include + +#include +#include + +#include "ImageQuantized.h" +#include "Picture.h" +#include "Tile.h" + +using namespace std; +using namespace RgbToHires; + +/// @brief Returns true if a file exists +inline bool exists(const std::string& path) +{ + struct stat buffer; + return (stat(path.c_str(), &buffer) == 0); +} + +/// @brief Program entry point +int main( int argc, char *argv[] ) +{ + Magick::InitializeMagick(*argv); + + //Parsing command line + TCLAP::CmdLine cmd("Tile", ' ', "0"); + TCLAP::ValueArg imagePath("i", "image", "Source image path", true, "", "path_to_image"); + TCLAP::ValueArg outputPath("o", "output", "Output path", true, "", "path_to_output"); + cmd.add(imagePath); + cmd.add(outputPath); + cmd.parse(argc, argv); + + if (imagePath.getValue().size() == 0 || outputPath.getValue().size() == 0) { + std::cout << "No input or output path privided."; + return -1; + } + + try { + const auto filepath = imagePath.getValue(); + if (!exists(filepath)) { + throw runtime_error("Cannot read " + filepath); + } + const auto imageRgb = Magick::Image{ filepath }; + auto imageQuantized = ImageQuantized{ imageRgb }; + const auto tileHiRes = Tile{ imageQuantized }; + + // Always output in asm + ofstream output(outputPath.getValue()); + output << tileHiRes.getAsm(); + + } + + //Fatal error + catch (const exception& e) { + cout << e.what(); + return -1; + } + + return 0; +} +