package a2geek.apple2.image.encoder.encode;
import a2geek.apple2.image.encoder.A2Image;
/**
* Perform repeated byte packing (really is a type of RLE).
*
* Encoding becomes: RR [ XX | RR XX NN ]
* where:
* - RR is the repeat toggle byte (1st entry is to identify it).
* - XX is the color byte to place in Apple II memory.
* - NN is the number of bytes repeated.
*
*
* @author a2geek@users.noreply.github.com
*/
public class RleEncoder extends A2Encoder {
public String getTitle() {
return "RLE (Standard)";
}
public void encode(A2Image a2, int maxSize) {
byte[] data = a2.getBytes();
encode(data, maxSize);
}
public void encode(byte[] data, int maxSize) {
reset(maxSize);
// Identify an unused value:
int count[] = new int[256];
for (int i=0; i