Skip to content

Commit 4ee664e

Browse files
committed
Initial migration to Maven and Git.
0 parents  commit 4ee664e

40 files changed

+3805
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/target/
2+
/.settings/
3+
/.classpath
4+
/.project

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Overview
2+
3+
This application will convert a modern image into a format usable by an Apple II - lores, double lores, and super hires are currently supported. It also includes basic compression capabilities. The color palettes go through an optimization phase to the standard 16 color palette, or, of the existing palette in the case of a super hires.
4+
5+
**Requires:** Java 1.8 (originally implemented for Java 1.4, but being rebuilt with modern tools, hence Java 1.8 requirement).
6+
7+
**Tip:** You can drag an image into the original tab instead of digging around for it.
8+
9+
Currently supported Apple II graphic formats:
10+
11+
Format | Width | Height | Colors
12+
------ | ----- | ------ | ------
13+
Lores | 40 | 40 | Standard Apple 16 colors
14+
Double | Lores | 80 | 40 | Standard Apple 16 colors
15+
Super Hires | 320 | 200 | 16 palettes of 16 colors; each palette entry is 12 bit color (4 bits per red, green, blue).
16+
17+
Currently supported "compression" formats: RLE, Variable RLE, PackBits, 'deflate' method of Zip, GZip, BitPack #1 - #3 (my attempts and they're worthless).
18+
19+
The [original TODO list](TODO.md) has been preserved for any future efforts.
20+
21+
# Screen Shots
22+
23+
This is the original tab with a 2048x1536 image taken on my digital camera. If you're not sure what you are looking at, it is the upper-left corner of the image in the next picture.
24+
25+
!(doc/images/a2ie-original.png)
26+
27+
Choose the image type to convert to and click the convert button. If you wish, you can save the raw Apple II data. Note that for lores and double lores, no screen holes are saved.
28+
29+
!(doc/images/a2ie-convert.png)
30+
31+
If you want some ideas about compressability, click the compression tab. You can enter the "max size allowed" which I use to figure out if the image can fit into the memory I've allocated for it on the Apple II. Click the Compress button to run through all the possibilities. Those that fit in the size given are colored green, the rest are red. If the compression method fails for some reason, it does not show up (note that Bit Pack #1 is missing - it only works on images less than 64 pixels wide or high or something like that). Note that each compression method's results can be saved to disk.
32+
33+
!(doc/images/a2ie-compression.png)
34+
35+
# Installation
36+
37+
Apple Image Encoder is distributed in a self-executing Java JAR file. What this means is that once Java has been installed on your system, you just need to (a) click the link and open the program to run it or (b) save the file to your hard disk and then double-click on that file. Use whichever works best for you.
38+
39+
# Version History
40+
41+
* 09/12/2016 - 4.4.0 - Migrated to GitHub, Maven, rebuilt application.
42+
* 08/06/2005 - 4.3.1 - Initial public release. Prior (internal) releases include command-line only, proof-of-concept work, etc. *This is the only version that will still work with Java 1.5 or later. This is the original package from 2005.

TODO.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
> This is the historical ideas list, tweaked for markdown.
2+
3+
# TODO
4+
* [x] Allow sorting compression results
5+
* [ ] View palette(s) after compression
6+
* [x] Highlight compressed image as red/green
7+
* [x] Save settings - last folder, max size
8+
* [x] Progress bar
9+
* [ ] Demo with Harry pictures for all modes - RLE
10+
* [ ] Add HGR, DHR?
11+
* [ ] Rotate original before conversion?
12+
* [x] Drop files into Original pane instead of loading.
13+
* [ ] Color fixing - bands (currently done), interlaced, closest colors
14+
* [ ] Add Floyd-Steinberg Dithering (and none)
15+
* [ ] Move convert options to popup dialog? (color fixing, aspect ratio)
16+
* [ ] Do something else with compression errors
17+
* [ ] Implement encoders as ServiceLoader modules

doc/images/a2ie-compression.png

13.7 KB
Loading

doc/images/a2ie-convert.png

58.5 KB
Loading

doc/images/a2ie-original.png

165 KB
Loading

pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>a2geek.apple2</groupId>
6+
<artifactId>apple2-image-encoder</artifactId>
7+
<version>4.4.0-FINAL</version>
8+
<name>Apple II Image Encoder</name>
9+
<description>A utility that got out of hand and became an application to move modern images to the Apple II platform.</description>
10+
11+
<properties>
12+
<maven.compiler.source>1.8</maven.compiler.source>
13+
<maven.compiler.target>1.8</maven.compiler.target>
14+
<maven.shade.version>2.4.3</maven.shade.version>
15+
<junit.version>4.12</junit.version>
16+
</properties>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>junit</groupId>
21+
<artifactId>junit</artifactId>
22+
<version>${junit.version}</version>
23+
<scope>test</scope>
24+
</dependency>
25+
</dependencies>
26+
27+
<build>
28+
<plugins>
29+
<plugin>
30+
<groupId>org.apache.maven.plugins</groupId>
31+
<artifactId>maven-shade-plugin</artifactId>
32+
<version>${maven.shade.version}</version>
33+
<executions>
34+
<execution>
35+
<phase>package</phase>
36+
<goals>
37+
<goal>shade</goal>
38+
</goals>
39+
<configuration>
40+
<transformers>
41+
<transformer
42+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
43+
<manifestEntries>
44+
<Main-Class>a2geek.apple2.image.encoder.ui.ImageEncoderApp</Main-Class>
45+
<Implementation-Title>Apple II Image Encoder</Implementation-Title>
46+
<Implementation-Version>${project.version}</Implementation-Version>
47+
</manifestEntries>
48+
</transformer>
49+
</transformers>
50+
</configuration>
51+
</execution>
52+
</executions>
53+
</plugin>
54+
</plugins>
55+
</build></project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package a2geek.apple2.image.encoder;
2+
import java.awt.image.BufferedImage;
3+
4+
import a2geek.apple2.image.encoder.util.ProgressListener;
5+
6+
/**
7+
* Represents an Apple II double lores image.
8+
* @author a2geek@users.noreply.github.com
9+
*/
10+
public class A2DoubleLoresImage extends A2LoresImage {
11+
public A2DoubleLoresImage(BufferedImage image, boolean keepAspectRatio) {
12+
this(image, keepAspectRatio, null);
13+
}
14+
public A2DoubleLoresImage(BufferedImage image, boolean keepAspectRatio, ProgressListener listener) {
15+
super(image, 80, keepAspectRatio, listener);
16+
}
17+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package a2geek.apple2.image.encoder;
2+
import java.awt.Graphics;
3+
import java.awt.image.BufferedImage;
4+
5+
/**
6+
* Represents an abstract Apple II image.
7+
* @author a2geek@users.noreply.github.com
8+
*/
9+
public abstract class A2Image {
10+
private BufferedImage image;
11+
private int height;
12+
private int width;
13+
14+
public A2Image(BufferedImage originalImage, int physicalHeight, int physicalWidth, boolean keepAspectRatio) {
15+
this.height = physicalHeight;
16+
this.width = physicalWidth;
17+
18+
this.image = new BufferedImage(physicalWidth, physicalHeight, BufferedImage.TYPE_INT_RGB);
19+
int x = 0;
20+
int y = 0;
21+
if (keepAspectRatio) {
22+
double aspectRatioH = (double)physicalHeight / (double)originalImage.getHeight();
23+
double aspectRatioW = (double)physicalWidth / (double)originalImage.getWidth();
24+
double aspectRatio = (aspectRatioH < aspectRatioW) ?
25+
aspectRatioH : aspectRatioW;
26+
height = (int)(originalImage.getHeight() * aspectRatio);
27+
width = (int)(originalImage.getWidth() * aspectRatio);
28+
x = (physicalWidth - width) / 2;
29+
y = (physicalHeight - height) / 2;
30+
}
31+
Graphics g = this.image.getGraphics();
32+
g.drawImage(originalImage, x, y, width, height, null);
33+
g.dispose();
34+
35+
this.height = physicalHeight;
36+
this.width = physicalWidth;
37+
}
38+
39+
public int getHeight() {
40+
return height;
41+
}
42+
public int getWidth() {
43+
return width;
44+
}
45+
public int getTotalBytes() {
46+
return getTotalPixels() / 2;
47+
}
48+
public int getTotalPixels() {
49+
return height * width;
50+
}
51+
protected int getRGB(int x, int y) {
52+
return image.getRGB(x,y);
53+
}
54+
protected void setRGB(int x, int y, int color) {
55+
image.setRGB(x, y, color);
56+
}
57+
public BufferedImage getImage() {
58+
return image;
59+
}
60+
/**
61+
* Get Apple II color at X, Y.
62+
*/
63+
public abstract int getColor(int x, int y);
64+
/**
65+
* Get Apple II color treating the screen as an array of pixels.
66+
*/
67+
public int getColor(int pos) {
68+
if (pos >= getTotalPixels()) return -1;
69+
int y = (pos / getWidth());
70+
int x = pos % getWidth();
71+
return getColor(x,y);
72+
}
73+
/**
74+
* Get a byte of memory as stored by the hardware.
75+
*/
76+
public abstract int getMemoryByte(int x, int y);
77+
/**
78+
* Treat the screen as an array of bytes.
79+
*/
80+
public abstract int getMemoryByte(int pos);
81+
/**
82+
* Test if, from a given coordinate, the rest of the row is a given color.
83+
*/
84+
public boolean checkRowColor(int y, int xStart, int color) {
85+
for (int x=xStart; x<getWidth(); x++) {
86+
if (getColor(x,y) != color) return false;
87+
}
88+
return true;
89+
}
90+
/**
91+
* Create a byte array of a physical memory dump for the image.
92+
*/
93+
public abstract byte[] getBytes();
94+
95+
/**
96+
* Setup the default Apple II 16 colors (lores, double lores, double hires colors).
97+
*/
98+
public static PaletteEntry[] getStandard12BitPalette() {
99+
PaletteEntry[] standardPalette = new PaletteEntry[16];
100+
standardPalette[0x0] = new PaletteEntry(0x000); // black
101+
standardPalette[0x1] = new PaletteEntry(0xf00); // magenta
102+
standardPalette[0x2] = new PaletteEntry(0x800); // brown
103+
standardPalette[0x3] = new PaletteEntry(0xf80); // orange
104+
standardPalette[0x4] = new PaletteEntry(0x080); // dark green
105+
standardPalette[0x5] = new PaletteEntry(0x888); // grey1
106+
standardPalette[0x6] = new PaletteEntry(0x0f0); // green
107+
standardPalette[0x7] = new PaletteEntry(0xff0); // yellow
108+
standardPalette[0x8] = new PaletteEntry(0x008); // dark blue
109+
standardPalette[0x9] = new PaletteEntry(0xf0f); // violet
110+
standardPalette[0xa] = new PaletteEntry(0xccc); // grey2
111+
standardPalette[0xb] = new PaletteEntry(0xf8c); // pink
112+
standardPalette[0xc] = new PaletteEntry(0x00c); // medium blue
113+
standardPalette[0xd] = new PaletteEntry(0x00f); // light blue
114+
standardPalette[0xe] = new PaletteEntry(0x0c8); // aqua
115+
standardPalette[0xf] = new PaletteEntry(0xfff); // white
116+
// Force each entry to be active
117+
for (PaletteEntry paletteEntry : standardPalette) paletteEntry.setActive();
118+
return standardPalette;
119+
}
120+
}

0 commit comments

Comments
 (0)