colormodel.html

来自「API資料大全」· HTML 代码 · 共 1,326 行 · 第 1/5 页

HTML
1,326
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:34:01 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class  ColorModel</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/ColorModel.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../java/awt/image/ColorConvertOp.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../../java/awt/image/ComponentColorModel.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="ColorModel.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.awt.image</FONT><BR>Class  ColorModel</H2><PRE><A HREF="../../../java/lang/Object.html">java.lang.Object</A>  |  +--<B>java.awt.image.ColorModel</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../java/awt/Transparency.html">Transparency</A></DD></DL><DL><DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../java/awt/image/ComponentColorModel.html">ComponentColorModel</A>, <A HREF="../../../java/awt/image/IndexColorModel.html">IndexColorModel</A>, <A HREF="../../../java/awt/image/PackedColorModel.html">PackedColorModel</A></DD></DL><HR><DL><DT>public abstract class <B>ColorModel</B><DT>extends <A HREF="../../../java/lang/Object.html">Object</A><DT>implements <A HREF="../../../java/awt/Transparency.html">Transparency</A></DL><P>The <code>ColorModel</code> abstract class encapsulates the methods for translating a pixel value to color components  (for example, red, green, and blue) and an alpha component. In order to render an image to the screen, a printer, or another image, pixel values must be converted to color and alpha components. As arguments to or return values from methods of this class, pixels are represented as 32-bit ints or as arrays of primitive types. The number, order, and interpretation of color components for a  <code>ColorModel</code> is specified by its <code>ColorSpace</code>.   A <code>ColorModel</code> used with pixel data that does not include alpha information treats all pixels as opaque, which is an alpha value of 1.0. <p> This <code>ColorModel</code> class supports two representations of pixel values.  A pixel value can be a single 32-bit int or an array of primitive types.  The Java(tm) Platform 1.0 and 1.1 APIs represented pixels as single <code>byte</code> or single  <code>int</code> values.  For purposes of the <code>ColorModel</code>  class, pixel value arguments were passed as ints.  The Java(tm) 2 Platform API introduced additional classes for representing images. With <A HREF="../../../java/awt/image/BufferedImage.html"><CODE>BufferedImage</CODE></A> or <A HREF="../../../java/awt/image/RenderedImage.html"><CODE>RenderedImage</CODE></A> objects, based on <A HREF="../../../java/awt/image/Raster.html"><CODE>Raster</CODE></A> and <A HREF="../../../java/awt/image/SampleModel.html"><CODE>SampleModel</CODE></A> classes, pixel values might not be conveniently representable as a single int.   Consequently, <code>ColorModel</code> now has methods that accept pixel values represented as arrays of primitive types.  The primitive type used by a particular <code>ColorModel</code> object is called its transfer type. <p> <code>ColorModel</code> objects used with images for which pixel values are not conveniently representable as a single int throw an <A HREF="../../../java/lang/IllegalArgumentException.html"><CODE>IllegalArgumentException</CODE></A> when methods taking a single int pixel argument are called.  Subclasses of <code>ColorModel</code> must specify the conditions under which this occurs.  This does not occur with <A HREF="../../../java/awt/image/DirectColorModel.html"><CODE>DirectColorModel</CODE></A> or <A HREF="../../../java/awt/image/IndexColorModel.html"><CODE>IndexColorModel</CODE></A> objects. <p> Currently, the transfer types supported by the Java 2D(tm) API are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, and DataBuffer.TYPE_INT. The transfer type for a particular <code>ColorModel</code> object is specified when the object is created, either explicitly or by default. All subclasses of <code>ColorModel</code> must specify what the possible transfer types are and how the number of elements in the primitive arrays representing pixels is determined. <p> For <code>BufferedImages</code>, the transfer type of its  <code>Raster</code> and of the <code>Raster</code> object's <code>SampleModel</code> (available from the <code>getTransferType</code> methods of these classes) must match that of the <code>ColorModel</code>.  The number of elements in an array representing a pixel for the <code>Raster</code> and  <code>SampleModel</code> (available from the <code>getNumDataElements</code> methods of these classes) must match that of the <code>ColorModel</code>. <p> The algorithm used to convert from pixel values to color and alpha components varies by subclass.  For example, there is not necessarily a one-to-one correspondence between samples obtained from the <code>SampleModel</code> of a <code>BufferedImage</code> object's <code>Raster</code> and color/alpha components.  Even when there is such a correspondence, the number of bits in a sample is not necessarily the same as the number of bits in the corresponding color/alpha component.  Each subclass must specify how the translation from pixel values to color/alpha components is done. <p> Methods in the <code>ColorModel</code> class use two different representations of color and alpha components.  In the unnormalized form, each component is an unsigned integral value between 0 and 2<sup>n</sup> - 1, where n is the number of significant bits for a particular component.  If pixel values for a particular  <code>ColorModel</code> represent color samples premultiplied by the alpha sample, unnormalized color component values are also premultiplied.  In the normalized form, each component is a  <code>float</code> value between 0.0 and 1.0.  Normalized color component values are not premultiplied.<P><DL><DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/IndexColorModel.html"><CODE>IndexColorModel</CODE></A>, <A HREF="../../../java/awt/image/ComponentColorModel.html"><CODE>ComponentColorModel</CODE></A>, <A HREF="../../../java/awt/image/PackedColorModel.html"><CODE>PackedColorModel</CODE></A>, <A HREF="../../../java/awt/image/DirectColorModel.html"><CODE>DirectColorModel</CODE></A>, <A HREF="../../../java/awt/Image.html"><CODE>Image</CODE></A>, <A HREF="../../../java/awt/image/BufferedImage.html"><CODE>BufferedImage</CODE></A>, <A HREF="../../../java/awt/image/RenderedImage.html"><CODE>RenderedImage</CODE></A>, <A HREF="../../../java/awt/color/ColorSpace.html"><CODE>ColorSpace</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html"><CODE>SampleModel</CODE></A>, <A HREF="../../../java/awt/image/Raster.html"><CODE>Raster</CODE></A>, <A HREF="../../../java/awt/image/DataBuffer.html"><CODE>DataBuffer</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/ColorModel.html#pixel_bits">pixel_bits</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The total number of bits in the pixel.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected &nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/ColorModel.html#transferType">transferType</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Data type of the array used to represent pixel values.</TD></TR></TABLE>&nbsp;<A NAME="fields_inherited_from_class_java.awt.Transparency"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from interface java.awt.<A HREF="../../../java/awt/Transparency.html">Transparency</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../java/awt/Transparency.html#BITMASK">BITMASK</A>, <A HREF="../../../java/awt/Transparency.html#OPAQUE">OPAQUE</A>, <A HREF="../../../java/awt/Transparency.html#TRANSLUCENT">TRANSLUCENT</A></CODE></TD></TR></TABLE>&nbsp;<!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/ColorModel.html#ColorModel(int)">ColorModel</A></B>(int&nbsp;bits)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a <code>ColorModel</code> that translates pixels of the specified number of bits to color/alpha components.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected </CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/ColorModel.html#ColorModel(int, int[], java.awt.color.ColorSpace, boolean, boolean, int, int)">ColorModel</A></B>(int&nbsp;pixel_bits,           int[]&nbsp;bits,           <A HREF="../../../java/awt/color/ColorSpace.html">ColorSpace</A>&nbsp;cspace,           boolean&nbsp;hasAlpha,           boolean&nbsp;isAlphaPremultiplied,           int&nbsp;transparency,           int&nbsp;transferType)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a <code>ColorModel</code> that translates pixel values to color/alpha components.</TD></TR></TABLE>&nbsp;<!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/ColorModel.html#coerceData(java.awt.image.WritableRaster, boolean)">coerceData</A></B>(<A HREF="../../../java/awt/image/WritableRaster.html">WritableRaster</A>&nbsp;raster,           boolean&nbsp;isAlphaPremultiplied)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Forces the raster data to match the state specified in the <code>isAlphaPremultiplied</code> variable, assuming the data is currently correctly described by this <code>ColorModel</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../../java/awt/image/SampleModel.html">SampleModel</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/ColorModel.html#createCompatibleSampleModel(int, int)">createCompatibleSampleModel</A></B>(int&nbsp;w,                            int&nbsp;h)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a <code>SampleModel</code> with the specified width and height that has a data layout compatible with this  <code>ColorModel</code>.</TD>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?