📄 componentcolormodel.html
字号:
<A NAME="ComponentColorModel(java.awt.color.ColorSpace, int[], boolean, boolean, int, int)"><!-- --></A><H3>ComponentColorModel</H3><PRE>public <B>ComponentColorModel</B>(<A HREF="../../../java/awt/color/ColorSpace.html">ColorSpace</A> colorSpace, int[] bits, boolean hasAlpha, boolean isAlphaPremultiplied, int transparency, int transferType)</PRE><DL><DD>Constructs a <CODE>ComponentColorModel</CODE> from the specified parameters. Color components will be in the specified <CODE>ColorSpace</CODE>. The <CODE>bits</CODE> array specifies the number of significant bits per color and alpha component. Its length should be the number of components in the <CODE>ColorSpace</CODE> if there is no alpha information in the pixel values, or one more than this number if there is alpha information. An <CODE>IllegalArgumentException</CODE> is thrown if the length of the array does not match the number of components. <CODE>hasAlpha</CODE> indicates whether alpha information is present. If <CODE>hasAlpha</CODE> is true, then the boolean <CODE>isAlphaPremultiplied</CODE> specifies how to interpret color and alpha samples in pixel values. If the boolean is true, color samples are assumed to have been multiplied by the alpha sample. The <CODE>transparency</CODE> specifies what alpha values can be represented by this color model. The acceptable <code>transparency</code> values are <CODE>OPAQUE</CODE>, <CODE>BITMASK</CODE> or <CODE>TRANSLUCENT</CODE>. The <CODE>transferType</CODE> is the type of primitive array used to represent pixel values. Note that the <CODE>bits</CODE> array contains the number of significant bits per color/alpha component after the translation from pixel values.<DD><DL><DT><B>Parameters:</B><DD><CODE>colorSpace</CODE> - The <CODE>ColorSpace</CODE> associated with this color model.<DD><CODE>bits</CODE> - The number of significant bits per component.<DD><CODE>hasAlpha</CODE> - If true, this color model supports alpha.<DD><CODE>isAlphaPremultiplied</CODE> - If true, alpha is premultiplied.<DD><CODE>transparency</CODE> - Specifies what alpha values can be represented by this color model.<DD><CODE>transferType</CODE> - Specifies the type of primitive array used to represent pixel values.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - If the length of the <CODE>bits</CODE> array does not match the number of components.<DT><B>See Also: </B><DD><A HREF="../../../java/awt/color/ColorSpace.html"><CODE>ColorSpace</CODE></A>, <A HREF="../../../java/awt/Transparency.html"><CODE>Transparency</CODE></A></DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getRed(int)"><!-- --></A><H3>getRed</H3><PRE>public int <B>getRed</B>(int pixel)</PRE><DL><DD>Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as an int. The returned value will be a non pre-multiplied value. If the alpha is premultiplied, this method divides it out before returning the value (if the alpha value is 0, the red value will be 0).<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getRed(int)">getRed</A></CODE> in class <CODE><A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>pixel</CODE> - The pixel from which you want to get the red color component.<DT><B>Returns:</B><DD>The red color component for the specified pixel, as an int.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - If there is more than one component in this <CODE>ColorModel</CODE>.</DL></DD></DL><HR><A NAME="getGreen(int)"><!-- --></A><H3>getGreen</H3><PRE>public int <B>getGreen</B>(int pixel)</PRE><DL><DD>Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as an int. The returned value will be a non pre-multiplied value. If the alpha is premultiplied, this method divides it out before returning the value (if the alpha value is 0, the green value will be 0).<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getGreen(int)">getGreen</A></CODE> in class <CODE><A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>pixel</CODE> - The pixel from which you want to get the green color component.<DT><B>Returns:</B><DD>The green color component for the specified pixel, as an int.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - If there is more than one component in this <CODE>ColorModel</CODE>.</DL></DD></DL><HR><A NAME="getBlue(int)"><!-- --></A><H3>getBlue</H3><PRE>public int <B>getBlue</B>(int pixel)</PRE><DL><DD>Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as an int. The returned value will be a non pre-multiplied value. If the alpha is premultiplied, this method divides it out before returning the value (if the alpha value is 0, the blue value will be 0).<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getBlue(int)">getBlue</A></CODE> in class <CODE><A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>pixel</CODE> - The pixel from which you want to get the blue color component.<DT><B>Returns:</B><DD>The blue color component for the specified pixel, as an int.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - If there is more than one component in this <CODE>ColorModel</CODE>.</DL></DD></DL><HR><A NAME="getAlpha(int)"><!-- --></A><H3>getAlpha</H3><PRE>public int <B>getAlpha</B>(int pixel)</PRE><DL><DD>Returns the alpha component for the specified pixel, scaled from 0 to 255. The pixel value is specified as an int.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getAlpha(int)">getAlpha</A></CODE> in class <CODE><A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>pixel</CODE> - The pixel from which you want to get the alpha component.<DT><B>Returns:</B><DD>The alpha component for the specified pixel, as an int.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - If there is more than one component in this <CODE>ColorModel</CODE>.</DL></DD></DL><HR><A NAME="getRGB(int)"><!-- --></A><H3>getRGB</H3><PRE>public int <B>getRGB</B>(int pixel)</PRE><DL><DD>Returns the color/alpha components of the pixel in the default RGB color model format. A color conversion is done if necessary. The returned value will be in a non pre-multiplied format. If the alpha is premultiplied, this method divides it out of the color components (if the alpha value is 0, the color values will be 0).<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getRGB(int)">getRGB</A></CODE> in class <CODE><A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>pixel</CODE> - The pixel from which you want to get the color/alpha components.<DT><B>Returns:</B><DD>The color/alpha components for the specified pixel, as an int.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - If there is more than one component in this <CODE>ColorModel</CODE>.</DL></DD></DL><HR><A NAME="getRed(java.lang.Object)"><!-- --></A><H3>getRed</H3><PRE>public int <B>getRed</B>(<A HREF="../../../java/lang/Object.html">Object</A> inData)</PRE><DL><DD>Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. A color conversion is done if necessary. The <CODE>pixel</CODE> value is specified by an array of data elements of type <CODE>transferType</CODE> passed in as an object reference. The returned value will be a non pre-multiplied value. If the alpha is premultiplied, this method divides it out before returning the value (if the alpha value is 0, the red value will be 0). Since <code>ComponentColorModel</code> can be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupported <code>transferType</code>.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getRed(java.lang.Object)">getRed</A></CODE> in class <CODE><A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>inData</CODE> - The pixel from which you want to get the red color component, specified by an array of data elements of type <CODE>transferType</CODE>.<DT><B>Returns:</B><DD>The red color component for the specified pixel, as an int.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - If <CODE>inData</CODE> is not a primitive array of type <CODE>transferType</CODE>.<DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <CODE>inData</CODE> is not large enough to hold a pixel value for this <CODE>ColorModel</CODE>.<DD><CODE><A HREF="../../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - If the transfer type of this <CODE>ComponentColorModel</CODE> is not one of the supported transfer types: <CODE>DataBuffer.TYPE_BYTE</CODE>, <CODE>DataBuffer.TYPE_USHORT</CODE>, or <CODE>DataBuffer.TYPE_INT</CODE>.</DL></DD></DL><HR><A NAME="getGreen(java.lang.Object)"><!-- --></A><H3>getGreen</H3><PRE>public int <B>getGreen</B>(<A HREF="../../../java/lang/Object.html">Object</A> inData)</PRE><DL><DD>Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB <CODE>ColorSpace</CODE>, sRGB. A color conversion is done if necessary. The <CODE>pixel</CODE> value is specified by an array of data elements of type <CODE>transferType</CODE> passed in as an object reference. The returned value is a non pre-multiplied value. If the alpha is premultiplied, this method divides it out before returning the value (if the alpha value is 0, the green value will be 0). Since <code>ComponentColorModel</code> can be subclassed, subclasses inherit the implementation of this method and if they don't override it then they throw an exception if they use an unsupported <code>transferType</code>.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getGreen(java.lang.Object)">getGreen</A></CODE> in class <CODE><A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>inData</CODE> - The pixel from which you want to get the green color component, specified by an array of data elements of type <CODE>transferType</CODE>.<DT><B>Returns:</B><DD>The green color component for the specified pixel, as an int.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - If <CODE>inData</CODE> is not a primitive array of type <CODE>transferType</CODE>.<DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <CODE>inData</CODE> is not large enough to hold a pixel value for this <CODE>ColorModel</CODE>.<DD><CODE><A HREF="../../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - If the transfer type of this <CODE>ComponentColorModel</CODE> is not one of the supported transfer types: <CODE>DataBuffer.TYPE_BYTE</CODE>, <CODE>DataBuffer.TYPE_USHORT</CODE>, or <CODE>DataBuffer.TYPE_INT</CODE>.</DL></DD></DL><HR><A NAME="getBlue(java.lang.Object)"><!-- --></A><H3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -