📄 indexcolormodel.html
字号:
<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 specified pixel<DT><B>Returns:</B><DD>the value of the alpha component for the specified pixel</DL></DD></DL><HR><A NAME="getRGB(int)"><!-- --></A><H3>getRGB</H3><PRE>public final int <B>getRGB</B>(int pixel)</PRE><DL><DD>Returns the color/alpha components of the pixel in the default RGB color model format. The pixel value is specified as an int. The returned value is in a non pre-multiplied format.<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 specified pixel<DT><B>Returns:</B><DD>the color and alpha components of the specified pixel<DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/ColorModel.html#getRGBdefault()"><CODE>ColorModel.getRGBdefault()</CODE></A></DL></DD></DL><HR><A NAME="getDataElements(int, java.lang.Object)"><!-- --></A><H3>getDataElements</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A> <B>getDataElements</B>(int rgb, <A HREF="../../../java/lang/Object.html">Object</A> pixel)</PRE><DL><DD>Returns a data element array representation of a pixel in this ColorModel, given an integer pixel representation in the default RGB color model. This array can then be passed to the <A HREF="../../../java/awt/image/WritableRaster.html#setDataElements(int, int, java.lang.Object)"><CODE>setDataElements</CODE></A> method of a <A HREF="../../../java/awt/image/WritableRaster.html"><CODE>WritableRaster</CODE></A> object. If the pixel variable is <code>null</code>, a new array is allocated. If <code>pixel</code> is not <code>null</code>, it must be a primitive array of type <code>transferType</code>; otherwise, a <code>ClassCastException</code> is thrown. An <code>ArrayIndexOutOfBoundsException</code> is thrown if <code>pixel</code> is not large enough to hold a pixel value for this <code>ColorModel</code>. The pixel array is returned. <p> Since <code>IndexColorModel</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#getDataElements(int, java.lang.Object)">getDataElements</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>rgb</CODE> - the integer pixel representation in the default RGB color model<DD><CODE>pixel</CODE> - the specified pixel<DT><B>Returns:</B><DD>an array representation of the specified pixel in this <code>IndexColorModel</code>.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if <code>pixel</code> is not a primitive array of type <code>transferType</code><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <code>pixel</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 <code>transferType</code> is invalid<DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/WritableRaster.html#setDataElements(int, int, java.lang.Object)"><CODE>WritableRaster.setDataElements(int, int, java.lang.Object)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>SampleModel.setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)</CODE></A></DL></DD></DL><HR><A NAME="getComponents(int, int[], int)"><!-- --></A><H3>getComponents</H3><PRE>public int[] <B>getComponents</B>(int pixel, int[] components, int offset)</PRE><DL><DD>Returns an array of unnormalized color/alpha components for a specified pixel in this <code>ColorModel</code>. The pixel value is specified as an int. If the components array is <code>null</code>, a new array is allocated. The components array is returned. Color/alpha components are stored in the components array starting at <code>offset</code> even if the array is allocated by this method. An <code>ArrayIndexOutOfBoundsException</code> is thrown if the components array is not <code>null</code> and is not large enough to hold all the color and alpha components starting at <code>offset</code>.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getComponents(int, int[], int)">getComponents</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 specified pixel<DD><CODE>components</CODE> - the array to receive the color and alpha components of the specified pixel<DD><CODE>offset</CODE> - the offset into the <code>components</code> array at which to start storing the color and alpha components<DT><B>Returns:</B><DD>an array containing the color and alpha components of the specified pixel starting at the specified offset.</DL></DD></DL><HR><A NAME="getComponents(java.lang.Object, int[], int)"><!-- --></A><H3>getComponents</H3><PRE>public int[] <B>getComponents</B>(<A HREF="../../../java/lang/Object.html">Object</A> pixel, int[] components, int offset)</PRE><DL><DD>Returns an array of unnormalized color/alpha components for a specified pixel in this <code>ColorModel</code>. The pixel value is specified by an array of data elements of type <code>transferType</code> passed in as an object reference. If <code>pixel</code> is not a primitive array of type <code>transferType</code>, a <code>ClassCastException</code> is thrown. An <code>ArrayIndexOutOfBoundsException</code> is thrown if <code>pixel</code> is not large enough to hold a pixel value for this <code>ColorModel</code>. If the <code>components</code> array is <code>null</code>, a new array is allocated. The <code>components</code> array is returned. Color/alpha components are stored in the <code>components</code> array starting at <code>offset</code> even if the array is allocated by this method. An <code>ArrayIndexOutOfBoundsException</code> is also thrown if the <code>components</code> array is not <code>null</code> and is not large enough to hold all the color and alpha components starting at <code>offset</code>. <p> Since <code>IndexColorModel</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#getComponents(java.lang.Object, int[], int)">getComponents</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 specified pixel<DD><CODE>components</CODE> - an array that receives the color and alpha components of the specified pixel<DD><CODE>offset</CODE> - the index into the <code>components</code> array at which to begin storing the color and alpha components of the specified pixel<DT><B>Returns:</B><DD>an array containing the color and alpha components of the specified pixel starting at the specified offset.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <code>pixel</code> is not large enough to hold a pixel value for this <code>ColorModel</code> or if the <code>components</code> array is not <code>null</code> and is not large enough to hold all the color and alpha components starting at <code>offset</code><DD><CODE><A HREF="../../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if <code>pixel</code> is not a primitive array of type <code>transferType</code><DD><CODE><A HREF="../../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if <code>transferType</code> is not one of the supported transer types</DL></DD></DL><HR><A NAME="getDataElement(int[], int)"><!-- --></A><H3>getDataElement</H3><PRE>public int <B>getDataElement</B>(int[] components, int offset)</PRE><DL><DD>Returns a pixel value represented as an int in this <code>ColorModel</code> given an array of unnormalized color/alpha components. An <code>ArrayIndexOutOfBoundsException</code> is thrown if the <code>components</code> array is not large enough to hold all of the color and alpha components starting at <code>offset</code>. Since <code>ColorModel</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 transferType.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#getDataElement(int[], int)">getDataElement</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>components</CODE> - an array of unnormalized color and alpha components<DD><CODE>offset</CODE> - the index into <code>components</code> at which to begin retrieving the color and alpha components<DT><B>Returns:</B><DD>an <code>int</code> pixel value in this <code>ColorModel</code> corresponding to the specified components.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if the <code>components</code> array is not large enough to hold all of the color and alpha components starting at <code>offset</code><DD><CODE><A HREF="../../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if <code>transferType</code> is invalid</DL></DD></DL><HR><A NAME="getDataElements(int[], int, java.lang.Object)"><!-- --></A><H3>getDataElements</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A> <B>getDataElements</B>(int[] components, int offset, <A HREF="../../../java/lang/Object.html">Object</A> pixel)</PRE><DL><DD>Returns a data element array representation of a pixel in this <code>ColorModel</code> given an array of unnormalized color/alpha components. This array can then be passed to the <code>setDataElements</code> method of a <code>WritableRaster</code> object. An <code>ArrayIndexOutOfBoundsException</code> is thrown if the <code>components</code> array is not large enough to hold all of the color and alpha components starting at <code>offset</code>. If the pixel variable is <code>null</code>, a new array is allocated. If <code>pixel</code> is not <code>null</code>, it must be a primitive array of type <code>transferType</code>; otherwise, a <code>ClassCastException</code> is thrown. An <code>ArrayIndexOutOfBoundsException</code> is thrown if pixel is not large enough to hold a pixel value for this <code>ColorModel</code>. <p> Since <code>IndexColorModel</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#getDataElements(int[], int, java.lang.Object)">getDataElements</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>components</CODE> - an array of unnormalized color and alpha components<DD><CODE>offset</CODE> - the index into <code>components</code> at which to begin retrieving color and alpha components<DD><CODE>pixel</CODE> - the <code>Object</code> representing an array of color and alpha components<DT><B>Returns:</B><DD>an <code>Object</code> representing an array of color and alpha components.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - if <code>pixel</code> is not a primitive array of type <code>transferType</code><DD><CODE><A HREF="../../../java/lang/ArrayIndexOutOfBoundsException.html">ArrayIndexOutOfBoundsException</A></CODE> - if <code>pixel</code> is not large enough to hold a pixel value for this <code>ColorModel</code> or the <code>components</code> array is not large enough to hold all of the color and alpha components starting at <code>offset</code><DD><CODE><A HREF="../../../java/lang/UnsupportedOperationException.html">UnsupportedOperationException</A></CODE> - if <code>transferType</code> is not one of the supported transer types<DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/WritableRaster.html#setDataElements(int, int, java.lang.Object)"><CODE>WritableRaster.setDataElements(int, int, java.lang.Object)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>SampleModel.setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)</CODE></A></DL></DD></DL><HR><A NAME="createCompatibleWritableRaster(int, int)"><!-- --></A><H3>createCompatibleWritableRaster</H3><PRE>public <A HREF="../../../java/awt/image/WritableRaster.html">WritableRaster</A> <B>createCompatibleWritableRaster</B>(int w, int h)</PRE><DL><DD>Creates a <code>WritableRaster</code> with the specified width and height that has a data layout (<code>SampleModel</code>) compatible with this <code>ColorModel</code>. This method only works for color models with 16 or fewer bits per pixel. <p> Since <code>IndexColorModel</code> can be subclassed, any subclass that supports greater than 16 bits per pixel must override this method.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../../java/awt/image/ColorModel.html#createCompatibleWritableRaster(int, int)">createCompatibleWritableRaster</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>w</CODE> - the width to apply to the new <code>WritableRaster</code><DD><CODE>h</CODE> - the height to apply to the new <code>WritableRaster</code><DT><B>Returns:</B><DD>a <code>WritableRaster</code> object with the specified width and height.<DT><B>Throws:</B><DD><CODE><A HREF="../../../j
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -