package ch.werner_randelshofer.gui.image;/*Copyright (C) 1999 Werner Randelshoferwerner.randelshofer@mythen.chhttp://www.mythen.ch/w.randelshofer/    Permission to use this release of ANIMKeyFrame is herebygranted without fee provided that the complete copyrightnotice and this permission notice appear in all copiesand in supporting documentation.*/import java.awt.image.ColorModel;import java.awt.image.IndexColorModel;import java.awt.image.DirectColorModel;import java.util.Hashtable;/** * @author	Werner Randelshofer, Staldenmattweg 2, CH-6405 Immensee, Switzerland * @version	1999-02-14	Created. */public class ANIMKeyFrameextends ANIMFrame	{	private ColorModel colorModel_;	private byte[] data_;	private boolean isCompressed_;		public ANIMKeyFrame()		{ }		public void setColorModel(ColorModel cm) { colorModel_ = cm; }	public void setData(byte[] data) { data_ = data; }	public void setCompressed(boolean isCompressed) { isCompressed_ = isCompressed; }	public ColorModel getColorModel() { return colorModel_; }	public void decode(Bitmap bitmap, ANIMMovieTrack track)		{		if (isCompressed_)			{			decodeByteRun1(data_,bitmap.getBitmap());					}		else			{			System.arraycopy(data_,0,bitmap.getBitmap(),0,data_.length);			}		}	public static int decodeByteRun1(byte[] in, byte[] out)		{		int iOut = 0; 		int iIn = 0;		int command = 0;		int finalIndex = in.length;		byte copyByte;		try			{			while (iOut < out.length)				{ 				command = in[iIn++];				if (command >= 0)					{					for (;command >= 0;command--)						{ out[iOut++] = in[iIn++]; }					}				else					{					if (command != -128)						{						copyByte = in[iIn++];						for (;command < 1;command++)							{ out[iOut++] = copyByte; }						}					}				}			}		catch (IndexOutOfBoundsException e)			{			System.out.println("ILBMDecoder.decodeByteRun1(): " + e);			System.out.println("  Plane-Index: " + iOut + " Plane size:" + out.length); 			System.out.println("  Buffer-Index: " + iIn + " Buffer size:" + in.length); 			System.out.println("  Command: " + command); 			}		return iOut;		}	}