From 2c73051e30a02b42ccd62a2c58ddf1f73256c66f Mon Sep 17 00:00:00 2001 From: Christophe Meneboeuf Date: Sun, 7 Oct 2018 00:37:44 +0200 Subject: [PATCH] Minor: better doc --- Readme.md | 19 ++++++++++--------- Rgb2Hires_PC/CMakeLists.txt | 24 ++++++++++++++++++++++++ Rgb2Hires_PC/RgbToHiRes.vcxproj | 12 ++++++------ Rgb2Hires_PC/src/HiRes.h | 20 ++++++++++---------- Rgb2Hires_PC/src/ImageQuantized.h | 5 ++++- Rgb2Hires_PC/src/Main.cpp | 4 ++-- 6 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 Rgb2Hires_PC/CMakeLists.txt diff --git a/Readme.md b/Readme.md index 0057ad4..1cf9f6a 100644 --- a/Readme.md +++ b/Readme.md @@ -1,32 +1,33 @@ #Rgb2Hires This program converts an RGB image to the Apple II's "HiRes" format. Provided it complies with this format's constraints: -* Source image must be 140x280. Pixels are anamorphic: twice wider than tall. +* Source image must be 140x192. Pixels are anamorphic: twice wider than tall. * Source image must contains six colors : BLACK, WHITE, ORANGE, GREEN, BLUE and PURPLE For more information about the "Hires" format and its limitations, please refer to Wikipedia: https://en.wikipedia.org/wiki/Apple_II_graphics#High-Resolution_.28Hi-Res.29_graphics -## Compiling - -This repository contains two projects: -* Rgb2Hires, the conversion programm running on a PC +## Compiling + +This repository contains two projects: +* Rgb2Hires, the conversion programm running on a PC * Loader, for testing purposes. This program runs on Apple II hardware and displays an HiRes binary file named *test.picture* and located on the same disk. ### Rgb2Hires The source is provided as a Visual Studio project. Howerver, it is standard C++11 without any Windows dependency, so it should compile on Linux and macOs without any modification. #### Dependencies -* Magick++ - * On Windows, you have provide an environment variable called *MAGICK_HOME* and pointing to the ImageMagick folder. +* Magick++ + * On Windows, you have provide an environment variable called *MAGICK_HOME* and pointing to the ImageMagick folder. * On Linux, install libmagick++-dev ### Loader (for Apple II) -This program will compile as an Apple II executable that you can run on the actual hardware. +This program will compile as an Apple II executable that you can run on the actual hardware. It is a Makefile project and must be crosscompiled using **[CC65](https://cc65.github.io/cc65/)** - + #### Dependencies * CC65: The crosscompiler suit. Please provide an environment variable, *CC65_HOME* pointing to your CC65 folder. # Running A correct source image, *test.png*, is provided as an example. Convert it into a file named *test.picture* and copy it along the Apple II *Loader*, then execute on the actual hardware ;) + diff --git a/Rgb2Hires_PC/CMakeLists.txt b/Rgb2Hires_PC/CMakeLists.txt new file mode 100644 index 0000000..da72fee --- /dev/null +++ b/Rgb2Hires_PC/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required (VERSION 2.6) +project (Rgb2Hires) + +# The version number. +set (Rgb2Hires_VERSION_MAJOR 1) +set (Rgb2Hires_VERSION_MINOR 0) + +#Warning level +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR + "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(warnings "-Wall -Wextra -Werror") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(warnings "/W4 /WX /EHsc") +endif() + + +add_executable(${PROJECT_NAME} src/Common.h + src/HiRes.cpp + src/HiRes.h + src/ImageQuantized.cpp + src/ImageQuantized.h + src/Main.cpp +) + \ No newline at end of file diff --git a/Rgb2Hires_PC/RgbToHiRes.vcxproj b/Rgb2Hires_PC/RgbToHiRes.vcxproj index d3d800b..de34abe 100644 --- a/Rgb2Hires_PC/RgbToHiRes.vcxproj +++ b/Rgb2Hires_PC/RgbToHiRes.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -32,33 +32,33 @@ {754364B2-84E3-40A5-B838-C153775D8F4C} Win32Proj RgbToHiRes - 8.1 + 10.0.17134.0 Rgb2HiRes Application true - v140 + v141 Unicode Application false - v140 + v141 true Unicode Application true - v140 + v141 Unicode Application false - v140 + v141 true Unicode diff --git a/Rgb2Hires_PC/src/HiRes.h b/Rgb2Hires_PC/src/HiRes.h index af1fe87..22b0ec7 100644 --- a/Rgb2Hires_PC/src/HiRes.h +++ b/Rgb2Hires_PC/src/HiRes.h @@ -35,27 +35,27 @@ namespace RgbToHires { class BlockHr { public: - /// \brief Default constructor: all black + /// @brief Default constructor: all black BlockHr(); - /// \brief Construction from 7 pixels + /// @brief Construction from 7 pixels BlockHr(const BlockPixel& ); - /// \brief returns the position of the first element + /// @brief returns the position of the first element inline std::array::const_iterator begin() const { return _data.begin(); } - /// \brief returns the position after the last element + /// @brief returns the position after the last element inline std::array::const_iterator end() const { return _data.end(); } private: - /// \brief color group as defined in Apple's documentation + /// @brief color group as defined in Apple's documentation enum eColorGroup { GROUP_1, GROUP_2 }; - /// \brief Returns the color group of these two 3.5 pixel blocks + /// @brief Returns the color group of these two 3.5 pixel blocks std::pair getGroup(const BlockPixel&) const; - /// \brief Returns the bit pait corresponding to the given color + /// @brief Returns the bit pait corresponding to the given color uint8_t getDibit(const Magick::Color&) const; std::array _data; @@ -68,7 +68,7 @@ namespace RgbToHires { using Blob = std::array; - + /// @brief Describes an HIRES image class HiRes { public: @@ -77,9 +77,9 @@ namespace RgbToHires { HiRes(const ImageQuantized&); ~HiRes() = default; - /// \brief Returns the binary hires picture + /// @brief Returns the binary hires picture std::unique_ptr > getBlob() const; - /// \brief Returns asm code corresponding to the image in memory (CA65 format) + /// @brief Returns asm code corresponding to the image in memory (CA65 format) std::string getAsm() const; private: diff --git a/Rgb2Hires_PC/src/ImageQuantized.h b/Rgb2Hires_PC/src/ImageQuantized.h index 4fe3423..b1bac78 100644 --- a/Rgb2Hires_PC/src/ImageQuantized.h +++ b/Rgb2Hires_PC/src/ImageQuantized.h @@ -27,6 +27,8 @@ namespace RgbToHires { + /// @brief Image quantized to the HIRES colors. + /// @details Quantization works with a nearest distance algorithm. class ImageQuantized : public Magick::Image { @@ -39,10 +41,11 @@ namespace RgbToHires { ImageQuantized(const Magick::Image& src); ~ImageQuantized()=default; + /// @brief Returns an array of bytes forming the RGB quantized image std::unique_ptr getBlob() const; private: - + /// @brief Computes the euclidian distance between two colors double Distance(const Magick::Color&, const Magick::Color&); }; diff --git a/Rgb2Hires_PC/src/Main.cpp b/Rgb2Hires_PC/src/Main.cpp index 0c8a9ab..cd96f22 100644 --- a/Rgb2Hires_PC/src/Main.cpp +++ b/Rgb2Hires_PC/src/Main.cpp @@ -31,14 +31,14 @@ using namespace std; using namespace RgbToHires; -/// \brief Returns true if a file exists +/// @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 +/// @brief Program entry point int main( int argc, char *argv[] ) { Magick::InitializeMagick(*argv);