KrisKennaway / ii-pix

Convert images to Apple II graphics formats
BSD 2-Clause "Simplified" License
36 stars 0 forks source link

][-pix 2.2

][-pix is an image conversion utility targeting Apple II graphics modes, currently Hi-Res (all models), Double Hi-Res (enhanced //e, //c, //gs) and Super Hi-Res (//gs).

Installation

Requires:

These dependencies can be installed using the following command:

# Install python dependencies
pip install -r requirements.txt

To build ][-pix, run the following commands:

# Compile cython code
python setup.py build_ext --inplace

# Precompute colour conversion matrices, used as part of image optimization
python precompute_conversion.py

Usage

To convert an image, the basic command is:

python convert.py <mode> [<flags>] <input> <output>

where

The following flags are supported in all modes:

For other available options, use python convert.py <mode> --help

See below for mode-specific instructions.

Hi-Res

To convert an image to Hi-Res the simplest usage is:

python convert.py hgr <input> <output.hgr>

<output.hgr> contains the hires image data in a form suitable for transfer to an Apple II disk image.

TODO: document flags

TODO: add more details about HGR - resolution and colour model.

Double Hi-Res

To convert an image to Double Hi-Res (560x192, 16 colours but it's complicated), the simplest usage is:

python convert.py dhr --palette ntsc <input> <output.dhr>

<output.dhr> contains the double-hires image data in a form suitable for transfer to an Apple II disk image. The 16k output consists of 8k AUX data first, 8K MAIN data second (this matches the output format of other DHGR image converters). i.e. if loaded at 0x2000, the contents of 0x2000..0x3fff should be moved to 0x4000..0x5fff in AUX memory, and the image can be viewed on DHGR page 2.

By default, a preview image will be shown after conversion, and saved as <output>-preview.png

TODO: document flags

For more details about Double Hi-Res graphics and the conversion process, see here.

Super Hi-Res

To convert an image to Super Hi-Res (320x200, up to 256 colours), the simplest usage is:

python convert.py shr <input> <output.shr>

i.e. no additional options are required. In addition to the common flags described above, these additional flags are supported for shr conversions:

TODO: link to KansasFest 2022 talk slides/video for more details

Examples

Hi-Res

This image was generated using

python convert.py hgr examples/hgr/mandarin-duck.jpg examples/hgr/mandarin-duck.bin

The image on the right is a screenshot taken from OpenEmulator.

Mandarin duck Mandarin duck

(Source: Adrian Pingstone, public domain, via Wikimedia Commons)

Portrait Portrait

(Source: Devanath, public domain)

TODO: add more hi-res images

Double Hi-Res

See here for more sample Double Hi-Res image conversions.

Original

Two colourful parrots sitting on a branch

(Source: Shreygadgil, CC BY-SA 4.0, via Wikimedia Commons)

][-pix preview image

This image was generated using

python convert.py dhr --lookahead 8 --palette openemulator examples/dhr/parrots-original.png examples/dhr/parrots-iipix-openemulator.dhr

The resulting ][-pix preview PNG image is shown here.

Two colourful parrots sitting on a branch

OpenEmulator screenshot

This is a screenshot taken from OpenEmulator when viewing the Double Hi-res image.

Two colourful parrots sitting on a branch

Some difference in colour tone is visible due to blending of colours across pixels (e.g. brown blending into grey, in the background). This is due to the fact that OpenEmulator simulates the reduced chroma bandwidth of the NTSC signal.

][-pix also allows modeling this NTSC signal behaviour, which effectively allows access to more than 16 DHGR colours, through carefully chosen sequences of pixels (see below for more details). The resulting images have much higher quality, but only when viewed on a suitable target (e.g. OpenEmulator, or real hardware). On other targets the colour balance tends to be skewed, though image detail is still good.

This is an OpenEmulator screenshot of the same image converted with --palette=ntsc instead of --palette=openemulator. Colour match to the original is substantially improved, and more colour detail is visible, e.g. in the shading of the background.

Two colourful parrots sitting on a branch

Super Hi-Res

See here for more sample Super Hi-Res image conversions.

Original

European rabbit kitten

(Source: Alexis LOURS, Licensed under Creative Commons Attribution 2.0 Generic, via Wikimedia Commons)

][-pix preview image

This image was generated using

python convert.py shr examples/shr/rabbit-kitten-original.png examples/shr/rabbit-kitten-original.shr

European rabbit kitten

Future work

Version history

v2.2 (2023-02-03)

v2.1 (2023-01-21)

v2.0 (2022-07-16)

v1.1 (2021-11-05)

v1.0 (2021-03-15)

Initial release

me