package yi.iu;

import java.io.*;

/******************************************************************************
This is a simple image class.  It can be used to provide fast access to the 
pixel array
******************************************************************************/

public class SImage
{
    public int width, height;
    public int data[];
    //types of image
    public int type;
    public final static int GRAY=0;
    public final static int RGB=1;
    public final static int BAREGRAY=2;
    public final static int BARERGB=3;
    
    public SImage(int w, int h, int t) {
        width=w; height=h; type=t;
        data= new int[w*h];
    }
    public SImage(int w, int h, int t, int d[]) {
        width=w; height=h; type=t;
        data= d;
    }
    
    //given the value of red, green, blue channel, and return the combination to a one integer array
    public static int[] makeRGB(int r[], int g[], int b[]) {
        int rgb[]= new int[r.length];
        for (int i=0;i<r.length;i++) {
            rgb[i]= 0xff<<24|r[i]<<16|g[i]<<8|b[i];
        }
        return rgb;
    }
    public int[] getBare() {
        int bare[]= new int[data.length];
        for (int i=0;i<data.length;i++) 
            bare[i]= data[i]&0xffffff;
        return bare;
    }
    
}