ColorModel cm;
ColorModel cm = null;
  public BufferedImage(int w, int h, int type)  {    ColorModel cm;        boolean alpha = false;    boolean premultiplied = false;    switch (type)      {      case TYPE_4BYTE_ABGR_PRE:      case TYPE_INT_ARGB_PRE:	premultiplied = true;	// fall through      case TYPE_INT_ARGB:      case TYPE_4BYTE_ABGR:	alpha = true;      }	    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);    switch (type)      {      case TYPE_INT_RGB:      case TYPE_INT_ARGB:      case TYPE_INT_ARGB_PRE:      case TYPE_USHORT_565_RGB:      case TYPE_USHORT_555_RGB:	int[] masks;	switch (type)	  {	  case TYPE_INT_RGB:	  case TYPE_INT_ARGB:	  case TYPE_INT_ARGB_PRE:	    masks = masks_int;	    break;	  case TYPE_USHORT_565_RGB:	    masks = masks_565;	    break;	  case TYPE_USHORT_555_RGB:	    masks = masks_555;	    break;	  }		cm = new DirectColorModel(cs,				  32, // 32 bits in an int				  masks[0], // r				  masks[1], // g				  masks[2], // b				  alpha ? 0xff000000 : 0,				  premultiplied,				  masks[3] // data type				  );	break;	      case TYPE_INT_BGR:	String msg =	  "FIXME: Programmer is confused. Why (and how) does a " +	  "TYPE_INT_BGR image use ComponentColorModel to store " +	  "8-bit values? Is data type TYPE_INT or TYPE_BYTE. What " +	  "is the difference between TYPE_INT_BGR and TYPE_3BYTE_BGR?";	throw new UnsupportedOperationException(msg);	      case TYPE_3BYTE_BGR:      case TYPE_4BYTE_ABGR:      case TYPE_4BYTE_ABGR_PRE:      case TYPE_BYTE_GRAY:      case TYPE_USHORT_GRAY:	int[] bits = null;	int dataType = DataBuffer.TYPE_BYTE;	switch (type) {	case TYPE_3BYTE_BGR:	  bits = bits3;	  break;	case TYPE_4BYTE_ABGR:	case TYPE_4BYTE_ABGR_PRE:	  bits = bits4;	  break;	case TYPE_BYTE_GRAY:	  bits = bits1byte;	  break;	case TYPE_USHORT_GRAY:	  bits = bits1ushort;	  dataType = DataBuffer.TYPE_USHORT;	  break;	}	cm = new ComponentColorModel(cs, bits, alpha, premultiplied,				     alpha ?				     Transparency.TRANSLUCENT:				     Transparency.OPAQUE,				     dataType);	break;      case TYPE_BYTE_BINARY:	byte[] vals = { 0, (byte) 0xff };	cm = new IndexColorModel(8, 2, vals, vals, vals);	break;      case TYPE_BYTE_INDEXED:	String msg2 = "type not implemented yet";	throw new UnsupportedOperationException(msg2);	// FIXME: build color-cube and create color model      }        init(cm,	 cm.createCompatibleWritableRaster(w, h),	 premultiplied,	 null, // no properties	 type	 );  }