uk.co.silentsoftware.core.converters.spectrum
Class ScrConverter

java.lang.Object
  extended by uk.co.silentsoftware.core.converters.spectrum.ScrConverter

public class ScrConverter
extends java.lang.Object

Converter to save images to the Spectrum scr memory model/dump format.


Field Summary
private static int SCR_BITS_SIZE
          SCR images are fixed size (representing Spectrum memory) - this is the size in bits
static int SCR_SIZE
          SCR images are fixed size (representing Spectrum memory) - this is the size in bytes
 
Constructor Summary
ScrConverter()
           
 
Method Summary
 int colourToBitSet(int colour, java.util.BitSet bs, int counter)
          Shockingly bad method to convert Spectrum colour indexes to the relevant little endian bits.
 byte[] convert(java.awt.image.BufferedImage original, ImageProcessor imagePro, boolean isAlreadyProcessed)
          Converts and returns an image converted using the given image processor if the image has not already been processed
private  byte[] convert(java.awt.image.BufferedImage original, ImageProcessor imagePro, boolean isAlreadyProcessed, int screen)
           
private  ColourData[][] getBlockedColourData(java.awt.image.BufferedImage img)
          Retrieves the Spectrum two ink/paper colour data for blocks in the provided image.
private  int toScr(java.awt.image.BufferedImage output, java.util.BitSet bs, int counter, ColourData[][] colourData)
          Copies the buffered image output to the given bitset, but only copies the "ink" values, i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCR_SIZE

public static final int SCR_SIZE
SCR images are fixed size (representing Spectrum memory) - this is the size in bytes

See Also:
Constant Field Values

SCR_BITS_SIZE

private static final int SCR_BITS_SIZE
SCR images are fixed size (representing Spectrum memory) - this is the size in bits

See Also:
Constant Field Values
Constructor Detail

ScrConverter

public ScrConverter()
Method Detail

getBlockedColourData

private ColourData[][] getBlockedColourData(java.awt.image.BufferedImage img)
Retrieves the Spectrum two ink/paper colour data for blocks in the provided image. I.e. a 256x192 image is passed in, this is divided by the Spectrum colour block size (8x8) and returns a two colour ColourData array of 32x24 holding ink and paper. Note this method EXPECTS PIXELS TO BE IN SPECTRUM COLOURS ONLY - NO VALIDATION IS DONE! A popularity check is also performed in choosing which colour is ink and which is paper - the most popular is paper (i.e. usually a background)

Parameters:
img -
Returns:

convert

public byte[] convert(java.awt.image.BufferedImage original,
                      ImageProcessor imagePro,
                      boolean isAlreadyProcessed)
Converts and returns an image converted using the given image processor if the image has not already been processed

Parameters:
original -
imagePro -
isAlreadyProcessed -
Returns:

convert

private byte[] convert(java.awt.image.BufferedImage original,
                       ImageProcessor imagePro,
                       boolean isAlreadyProcessed,
                       int screen)

toScr

private int toScr(java.awt.image.BufferedImage output,
                  java.util.BitSet bs,
                  int counter,
                  ColourData[][] colourData)
Copies the buffered image output to the given bitset, but only copies the "ink" values, i.e. those that match the colour data for the relevant pixel 8x8 range. The data in the bitset is in correctly formatted scr order.

Parameters:
output -
bs -
counter -
colourData -
Returns:

colourToBitSet

public int colourToBitSet(int colour,
                          java.util.BitSet bs,
                          int counter)
Shockingly bad method to convert Spectrum colour indexes to the relevant little endian bits. There is probably a better way of doing this but I'm tired.

Parameters:
colour -
bs -
counter -
Returns: