add full-color script

This commit is contained in:
Dagen Brock 2017-05-26 12:13:50 -05:00
parent b17d2f8d72
commit e1dd4b2b20
12 changed files with 79 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

40
full-color/readme.md Normal file
View File

@ -0,0 +1,40 @@
# Full-color
This is based off of a concept seen on early systems to simulate separate Red, Green, and Blue scanlines in order to approximate a higher number of colors.
## About
In this case we are targeting the 12-bit color space on the Apple IIgs (2^12 = 4096). It color system allows 4-bits per channel, meaning I can have a red value from 0-15, a green value from 0-15, and a blue value from 0-15. In hexadecimal it looks like this #$06FA, with the leftmost zero nibble being ignored on the IIgs.
To approximate it here, we use imagemagick to perform the following conversion steps:
- resize the image to 320x67 - because IIgs resolution is 320x200 and we want it 1/3 height so CEILING(66.66666)
- crop it into 67 images - each sized 320x1 - still all full color
- for each line:
- remove two channels (Green,Blue) to get remaining channel (Red)
- reduce that channel to a 16 color, 12 bit, dithered image
- recombine the 67 * 3 images into single 320x201 image
- crop to 320x200, effectively dropping the last Blue line since we start with RGB at the top
## Prerequisite
You must have imagemagick installed. To see if it's installed, open a command line and type `convert`
If you need to install it, for Mac OSX, I'd suggest `brew`:
```$ brew install imagemagick```
Linux - RHEL/CentOS
```$ sudo yum install ImageMagick```
Linux - Debian/Ubuntu
```$ sudo apt-get install imagemagick```
## Running the script to build an image
Basically you can just run the `slicer.sh` script against any image that imagemagick supports.
```./slicer.sh my_picture.png```
## Running the test suite
From the parent directory (the one this readme file is in), run the test script:
```$ ./tests/run_1.sh```
Output will be generated in the **out/** directory.

29
full-color/scripts/slicer.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
IMAGE=$1 # ./something/foo.png
IMAGEBASE=$(basename $IMAGE) # foo.png
IMAGEBASENOEXT=${IMAGEBASE%%.*} # foo
OUTBASE=out
OUTDIR=$OUTBASE/$IMAGEBASENOEXT
mkdir -p $OUTDIR
# start with RGB, so from 200 vertical pixels divided by 3 colors = 320x66.6 (we'll do 67 and remove extras)
# also, we don't reduce colors yet, because we need 67 full-color lines to split into three separate
# 4-bpc (12bit color) lines to composite at the end
convert -resize 320x67\! -crop 320x1 $IMAGE $OUTDIR/$IMAGEBASENOEXT-%03d.full.png
for file in `ls $OUTDIR/$IMAGEBASENOEXT*.full.png`;
do
echo Working on splice: $file
filebase=$(basename $file)
filebasenoext=${filebase%%.*}
dither=Riemersma
convert -channel Green,Blue -evaluate set 0 +channel -colors 16 -depth 12 -dither $dither $file $OUTDIR/$filebasenoext.gs.0-R.png
convert -channel Red,Blue -evaluate set 0 +channel -colors 16 -depth 12 -dither $dither $file $OUTDIR/$filebasenoext.gs.1-G.png
convert -channel Red,Green -evaluate set 0 +channel -colors 16 -depth 12 -dither $dither $file $OUTDIR/$filebasenoext.gs.2-B.png
done
convert -append $OUTDIR/$IMAGEBASENOEXT*gs* $OUTDIR/$IMAGEBASENOEXT-FINAL.png
convert -crop 320x200 $OUTDIR/$IMAGEBASENOEXT-FINAL.png $OUTBASE/$IMAGEBASENOEXT-FINAL-APPX.png

6
full-color/tests/run_1.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
# run from parent dir "./tests/run_1.sh"
for i in lion.jpg painting-swirl.jpg pink-cosmos.jpg radiant-color.jpg ;
do
./scripts/slicer.sh ../sample_images/$i
done

4
readme.md Normal file
View File

@ -0,0 +1,4 @@
# Image Conversion Tools for the Apple IIgs
This is a set of random utilities and convertors I've written over the years. Each on is it's own directory here with a readme, so you'll have to click on the directories to see what a tool does.
Currently I've only added a recently written tool, `full-color`. I'll try to add others as I start scouring my archives and clean them up.

BIN
sample_images/lion.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB