diff --git a/Rgb2Hires_PC/src/App_Tile.cpp b/Rgb2Hires_PC/src/App_Tile.cpp index 02f31c9..38837e4 100644 --- a/Rgb2Hires_PC/src/App_Tile.cpp +++ b/Rgb2Hires_PC/src/App_Tile.cpp @@ -46,25 +46,38 @@ int main( int argc, char *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"); + TCLAP::ValueArg imagePath("i", "image", "Source image path", true, "", "string"); + TCLAP::ValueArg outputPath("o", "output", "Output path", true, "", "string"); + TCLAP::ValueArg column("c", "column", "Column number in the tile sheet. Starts at 0.", true, 0u, "integer"); + TCLAP::ValueArg line("l", "line", "Line number in the tile sheet. Starts at 0.", true, 0u, "integer"); cmd.add(imagePath); cmd.add(outputPath); + cmd.add(column); + cmd.add(line); cmd.parse(argc, argv); if (imagePath.getValue().size() == 0 || outputPath.getValue().size() == 0) { std::cout << "No input or output path privided."; return -1; } + if (column.getValue() > 9) { + std::cout << "Column number shall be < 9"; + return -1; + } + if (line.getValue() > 11) { + std::cout << "Line number shall be < 11"; + return -1; + } - try { + 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 }; + const auto tileHiRes = Tile{ imageQuantized, column.getValue(), line.getValue()}; // Always output in asm ofstream output(outputPath.getValue()); diff --git a/Rgb2Hires_PC/src/Tile.cpp b/Rgb2Hires_PC/src/Tile.cpp index 9601a94..3695f20 100644 --- a/Rgb2Hires_PC/src/Tile.cpp +++ b/Rgb2Hires_PC/src/Tile.cpp @@ -2,9 +2,11 @@ #include #include "Tile.h" -RgbToHires::Tile::Tile(const ImageQuantized& source) +RgbToHires::Tile::Tile(const ImageQuantized& source, const unsigned col, const unsigned line) { - auto pixel_src = source.getConstPixels(0u, 0u, 14, 16); + constexpr unsigned w_tile = 14; + constexpr unsigned h_tile = 16; + auto pixel_src = source.getConstPixels(col * w_tile, line * h_tile, w_tile, h_tile); //Filling the storage with BlockHrs for (auto& line : _blob) { diff --git a/Rgb2Hires_PC/src/Tile.h b/Rgb2Hires_PC/src/Tile.h index 302a2bf..f950479 100644 --- a/Rgb2Hires_PC/src/Tile.h +++ b/Rgb2Hires_PC/src/Tile.h @@ -15,7 +15,7 @@ namespace RgbToHires { public: /// @brief Constructs the tile from the upper left corner of a 140x192 quantized image - Tile(const ImageQuantized&); + Tile(const ImageQuantized&, const unsigned col, const unsigned line); ~Tile() = default; /// @brief Returns asm code corresponding to the tile: the lines are not interleaved!