
import java.io.InputStream;
import java.io.IOException;
import java.io.DataInputStream;

/**
 * class RasParam
 * @version 1.2 99/02/15
 * @since JDK 1.2
 */
public class RasParam {

	public static final int MAGIC=0x59a66a95;
	public static final byte[] MAGIC_BYTES={(byte)0x59,(byte)0xa6,(byte)0x6a,(byte)0x95};
	public static final int RT_OLD=0;
	public static final int RT_STANDARD=1;
	public static final int RT_BYTE_ENCODED=2;
	public static final int RMT_NONE=0;
	public static final int RMT_EQUAL_RGB=1;
	public static final int RMT_RAW=2;
	public int magic;
	public int width;
	public int height;
	public int depth;
	public int length;
	public int type;
	public int maptype;
	public int maplength;
	private boolean error_=false;


	public RasParam()
	{
	}

	public RasParam(InputStream is)
	{
		initParam(is);
	}

	/**
	 * init the param with the header of the inputstream
     * return true only if this header is valid 
	 *
	 * @return the image decoded
	**/
	public boolean initParam(InputStream is)
	{
		boolean res=false;
		DataInputStream dis=new DataInputStream(is);		
		try{
			if(dis.available()!=0){
				magic=dis.readInt();
				width=dis.readInt();
				height=dis.readInt();
				depth=dis.readInt();
				length=dis.readInt();
				type=dis.readInt();
				maptype=dis.readInt();
				maplength=dis.readInt();
				res=(magic==MAGIC);
			}
		}
		catch(IOException ioe){
			res=false;
		}
		return res;
	}

	public String toString()
	{
		String res="Ras Magic Number = "+MAGIC+"\n"+
			"This file Magic Number = "+magic+"\n"+
			"Width= "+width+"\n"+
			"Height= "+height+"\n"+
			"Depth= "+depth+"\n"+
			"Length= "+length+"\n"+
			"Type= "+type+"\n"+
			"MapType= "+maptype+"\n"+
			"MapLength= "+maplength;
		return res;
	}
	
} // ImageDecoder















