[gui] Add IndexColorModel constructor
Jerry Quinn
jlquinn@optonline.net
Mon Sep 27 16:21:00 GMT 2004
2004-09-26 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/IndexColorModel.java (IndexColorModel): Implement
missing constructor.
Index: IndexColorModel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/image/IndexColorModel.java,v
retrieving revision 1.6
retrieving revision 1.6.14.1
diff -u -r1.6 -r1.6.14.1
--- IndexColorModel.java 29 Sep 2003 11:28:58 -0000 1.6
+++ IndexColorModel.java 26 Sep 2004 18:25:41 -0000 1.6.14.1
@@ -38,6 +38,8 @@
package java.awt.image;
+import java.awt.color.ColorSpace;
+
/**
* @author C. Brian Jones (cbj@gnu.org)
*/
@@ -169,6 +171,37 @@
this.trans = trans;
}
+ /**
+ * Each array much contain <code>size</code> elements. For each
+ * array, the i-th color is described by reds[i], greens[i],
+ * blues[i], alphas[i], unless alphas is not specified, then all the
+ * colors are opaque except for the transparent color.
+ *
+ * @param bits the number of bits needed to represent
<code>size</code> colors
+ * @param size the number of colors in the color map
+ * @param cmap packed color components
+ * @param start the offset of the first color component in
<code>cmap</code>
+ * @param hasAlpha <code>cmap</code> has alpha values
+ * @param trans the index of the transparent color
+ * @param transferType DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT
+ */
+ public IndexColorModel (int bits, int size, byte[] cmap, int start,
+ boolean hasAlpha, int trans, int transferType)
+ {
+ super(bits * 4, // total bits, sRGB, four channels
+ nArray(bits, 4), // bits for each channel
+ ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB
+ true, // has alpha
+ false, // not premultiplied
+ TRANSLUCENT, transferType);
+ if (transferType != DataBuffer.TYPE_BYTE
+ && transferType != DataBuffer.TYPE_USHORT)
+ throw new IllegalArgumentException();
+ map_size = size;
+ opaque = !hasAlpha;
+ this.trans = trans;
+ }
+
public final int getMapSize ()
{
return map_size;
More information about the Java-patches
mailing list