package subPicture;

import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;

public class Pixel implements Serializable {
	
	public int r,g,b;
	
	/**
	 * Constructor: full
	 * @param rgb - RGB-array. Alpha ignored.
	 */
	public Pixel(int[] rgb){
		r = rgb[0];
		g = rgb[1];
		b = rgb[2];
		
		test();
	}
	
	/**
	 * Constructor: empty
	 */
	public Pixel(){
		//empty
	}
	
	/**
	 * TODO: testing
	 */
	public void test(){
		assert r<256 && g<256 && b<=256;
		assert r>0 && g>0 && b>0;
	}
	
	@Override
	public String toString(){
		return ""+r+"/"+g+"/"+b;
	}
	
	protected void writeObjectNew(java.io.ObjectOutputStream out) throws IOException {
		out.writeInt(r);
		out.writeInt(g);
		out.writeInt(b);
	}
	protected Pixel readObjectNew(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
		r=in.readInt();
		g=in.readInt();
		b=in.readInt();
		return this;
	}
}
