view src/samer/maths/IteratorImageSource.java @ 5:b67a33c44de7

Remove some crap, etc
author samer
date Fri, 05 Apr 2019 21:34:25 +0100
parents bf79fb79ee13
children
line wrap: on
line source
/*
 *	IteratorImageSource.java	
 *
 *	Copyright (c) 2000, Samer Abdallah, King's College London.
 *	All rights reserved.
 *
 *	This software is provided AS iS and WITHOUT ANY WARRANTY; 
 *	without even the implied warranty of MERCHANTABILITY or 
 *	FITNESS FOR A PARTICULAR PURPOSE.
 */

package samer.maths;
import  samer.tools.*;
import  java.awt.image.*;

/**
	This is an image source that gets its values
	from a Vec (vector) via its Vec.Iterator - ie,
	it does not need access to an array of value
  */

public class IteratorImageSource extends ImageSourceBase
{
	Vec			vec;
	byte []		buf;

	public IteratorImageSource( Vec v) { this( v, v.size(), 1); }
	public IteratorImageSource( Vec v, int w, int h)
	{
		vec		= v;
		width	= w;
		height	= h;
		buf		= new byte[v.size()];
	}


	protected int getHints() {
		return  ImageConsumer.TOPDOWNLEFTRIGHT 
				| ImageConsumer.COMPLETESCANLINES
				| ImageConsumer.SINGLEPASS;
	}

	protected void sendPixels(ImageConsumer ic)
	{
		Vec.Iterator it=vec.iterator(); 

		for (int i=0; it.more(); i++) {
			buf[i] = (byte)map.clipInt(it.next());
		}
		ic.setPixels(0, 0, width, height, model, buf, 0, width);
	}
}