public BufferedImage(ColorModel colormodel, WritableRaster writableraster, boolean premultiplied, Hashtable properties) { init(colormodel, writableraster, premultiplied, properties, TYPE_CUSTOM);
public BufferedImage(int w, int h, int type) { ColorModel cm = null;  boolean alpha = false; boolean premultiplied = false; switch (type) { case TYPE_4BYTE_ABGR_PRE: case TYPE_INT_ARGB_PRE: premultiplied = true;  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 = null; 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, masks[0], masks[1], masks[2], alpha ? 0xff000000 : 0, premultiplied, masks[3] ); 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);  }  init(cm, cm.createCompatibleWritableRaster(w, h), premultiplied, null, type );
	public BufferedImage(ColorModel colormodel, WritableRaster writableraster, boolean premultiplied, Hashtable properties) {		init(colormodel, writableraster, premultiplied, properties, TYPE_CUSTOM);		// TODO: perhaps try to identify type?	}