package a2geek.apple2.image.encoder.encode; import a2geek.apple2.image.encoder.A2Image; /** * Perform variable length repeated byte packing (really is a type of RLE). *

* Encoding becomes: ## R1 R2 ... [ XX | Rn XX NN ] * where:

* Each succeeding repeat toggle byte is for a run of N bytes. * For example, "02 55 66" identifes two repeat toggle bytes with "55" * indicating a run of 1 byte and "66" indicating a run of 2 bytes. * * @author a2geek@users.noreply.github.com */ public class VariableRleEncoder extends A2Encoder { public String getTitle() { return "RLE (Variable)"; } public void encode(A2Image a2, int maxSize) { byte[] data = a2.getBytes(); encode(data, maxSize); } protected void encode(byte[] data, int maxSize) { int[] repeatBytes = new int[8]; reset(maxSize); // Identify an unused value: int count[] = new int[256]; for (int i=0; i