// Path: app/src/main/java/se/embargo/retroboy/color/IColorDistance.java
// public interface IColorDistance {
// 	/**
// 	 * @return	A number between 0 and 1 indicating the color distance.
// 	 */
// 	public double get(int r1,int g1,int b1, int r2,int g2,int b2);
// }


import se.embargo.core.concurrent.IForBody;
import se.embargo.core.concurrent.Parallel;
import se.embargo.retroboy.color.IColorDistance;
import android.content.Context;

package se.embargo.retroboy.filter;


/**
 * 2-tone raster dithering as used on most Amstrad CPC games.
 */
public class RasterFilter extends AbstractColorFilter {
	/**
	 * Version number for the cache files
	 */
	private static final int CACHE_VERSION_NUMBER = 10;

	/**
	 * Number of integers per bucket.
	 */
	private static final int COLOR_BUCKET_SIZE = 2;

	/**
	 * Dither matrix.
	 */
	private final int[] _matrix;
	
	/**
	 * Length of matrix side.
	 */
	private final int _patternsize;

	/**
	 * Ratio of color mixing.
	 */
	private final int _mixingratio;

	/**
	 * Divisor for the too-far-apart color penalty.
	 */
	private final double _penaltyDivisor;
	
	/**
	 * Parallel functor used to process frames.
	 */
	private final IForBody<ImageBuffer> _body = new ColorBody();
	
	/**
	 * @param context		Context running the filter
	 * @param distance		Measure for color distance
	 * @param colors		Palette of available colors
	 * @param matrix		Dithering matrix to use
	 * @param rasterlevel	Level of rastering to apply
	 */

// Path: app/src/main/java/se/embargo/retroboy/color/IColorDistance.java
// public interface IColorDistance {
// 	/**
// 	 * @return	A number between 0 and 1 indicating the color distance.
// 	 */
// 	public double get(int r1,int g1,int b1, int r2,int g2,int b2);
// }


// Path: app/src/main/java/se/embargo/retroboy/filter/RasterFilter.java
import se.embargo.core.concurrent.IForBody;
import se.embargo.core.concurrent.Parallel;
import se.embargo.retroboy.color.IColorDistance;
import android.content.Context;

package se.embargo.retroboy.filter;


/**
 * 2-tone raster dithering as used on most Amstrad CPC games.
 */
public class RasterFilter extends AbstractColorFilter {
	/**
	 * Version number for the cache files
	 */
	private static final int CACHE_VERSION_NUMBER = 10;

	/**
	 * Number of integers per bucket.
	 */
	private static final int COLOR_BUCKET_SIZE = 2;

	/**
	 * Dither matrix.
	 */
	private final int[] _matrix;
	
	/**
	 * Length of matrix side.
	 */
	private final int _patternsize;

	/**
	 * Ratio of color mixing.
	 */
	private final int _mixingratio;

	/**
	 * Divisor for the too-far-apart color penalty.
	 */
	private final double _penaltyDivisor;
	
	/**
	 * Parallel functor used to process frames.
	 */
	private final IForBody<ImageBuffer> _body = new ColorBody();
	
	/**
	 * @param context		Context running the filter
	 * @param distance		Measure for color distance
	 * @param colors		Palette of available colors
	 * @param matrix		Dithering matrix to use
	 * @param rasterlevel	Level of rastering to apply
	 */

	public RasterFilter(Context context, IColorDistance distance, int[] colors, int[] matrix, int rasterlevel) {
