mirror of
https://github.com/Pixinn/Rgb2Hires.git
synced 2025-01-04 21:32:02 +00:00
Minor: better doc
This commit is contained in:
parent
93ee71ab7c
commit
2c73051e30
19
Readme.md
19
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 ;)
|
||||
|
||||
|
||||
|
24
Rgb2Hires_PC/CMakeLists.txt
Normal file
24
Rgb2Hires_PC/CMakeLists.txt
Normal file
@ -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
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@ -32,33 +32,33 @@
|
||||
<ProjectGuid>{754364B2-84E3-40A5-B838-C153775D8F4C}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>RgbToHiRes</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>Rgb2HiRes</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
@ -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<uint8_t, 2>::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<uint8_t, 2>::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<eColorGroup, eColorGroup> 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<uint8_t, 2> _data;
|
||||
@ -68,7 +68,7 @@ namespace RgbToHires {
|
||||
using Blob = std::array<LineHr, NB_LINES_PER_SCREEN>;
|
||||
|
||||
|
||||
|
||||
/// @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 <std::array<uint8_t, FRAME_SIZE>> 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:
|
||||
|
@ -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<Blob> getBlob() const;
|
||||
|
||||
private:
|
||||
|
||||
/// @brief Computes the euclidian distance between two colors
|
||||
double Distance(const Magick::Color&, const Magick::Color&);
|
||||
|
||||
};
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user