📄 samplemodel.html
字号:
<DL><DD>Returns the number of data elements needed to transfer a pixel via the getDataElements and setDataElements methods. When pixels are transferred via these methods, they may be transferred in a packed or unpacked format, depending on the implementation of the SampleModel. Using these methods, pixels are transferred as an array of getNumDataElements() elements of a primitive type given by getTransferType(). The TransferType may or may not be the same as the storage DataType.<DD><DL><DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/SampleModel.html#getDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>getDataElements(int, int, Object, DataBuffer)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#getDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>getDataElements(int, int, int, int, Object, DataBuffer)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>setDataElements(int, int, Object, DataBuffer)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#setDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>setDataElements(int, int, int, int, Object, DataBuffer)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#getTransferType()"><CODE>getTransferType()</CODE></A></DL></DD></DL><HR><A NAME="getDataType()"><!-- --></A><H3>getDataType</H3><PRE>public final int <B>getDataType</B>()</PRE><DL><DD>Returns the data type of the DataBuffer storing the pixel data.</DL><HR><A NAME="getTransferType()"><!-- --></A><H3>getTransferType</H3><PRE>public int <B>getTransferType</B>()</PRE><DL><DD>Returns the TransferType used to transfer pixels via the getDataElements and setDataElements methods. When pixels are transferred via these methods, they may be transferred in a packed or unpacked format, depending on the implementation of the SampleModel. Using these methods, pixels are transferred as an array of getNumDataElements() elements of a primitive type given by getTransferType(). The TransferType may or may not be the same as the storage DataType. The TransferType will be one of the types defined in DataBuffer.<DD><DL><DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/SampleModel.html#getDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>getDataElements(int, int, Object, DataBuffer)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#getDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>getDataElements(int, int, int, int, Object, DataBuffer)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>setDataElements(int, int, Object, DataBuffer)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#setDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer)"><CODE>setDataElements(int, int, int, int, Object, DataBuffer)</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#getNumDataElements()"><CODE>getNumDataElements()</CODE></A>, <A HREF="../../../java/awt/image/DataBuffer.html"><CODE>DataBuffer</CODE></A></DL></DD></DL><HR><A NAME="getPixel(int, int, int[], java.awt.image.DataBuffer)"><!-- --></A><H3>getPixel</H3><PRE>public int[] <B>getPixel</B>(int x, int y, int[] iArray, <A HREF="../../../java/awt/image/DataBuffer.html">DataBuffer</A> data)</PRE><DL><DD>Returns the samples for a specified pixel in an int array, one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.<DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - The X coordinate of the pixel location.<DD><CODE>y</CODE> - The Y coordinate of the pixel location.<DD><CODE>iArray</CODE> - If non-null, returns the samples in this array.<DD><CODE>data</CODE> - The DataBuffer containing the image data.</DL></DD></DL><HR><A NAME="getDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)"><!-- --></A><H3>getDataElements</H3><PRE>public abstract <A HREF="../../../java/lang/Object.html">Object</A> <B>getDataElements</B>(int x, int y, <A HREF="../../../java/lang/Object.html">Object</A> obj, <A HREF="../../../java/awt/image/DataBuffer.html">DataBuffer</A> data)</PRE><DL><DD>Returns data for a single pixel in a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT. Data may be returned in a packed format, thus increasing efficiency for data transfers. Generally, obj should be passed in as null, so that the Object will be created automatically and will be of the right primitive data type. <p> The following code illustrates transferring data for one pixel from DataBuffer <code>db1</code>, whose storage layout is described by SampleModel <code>sm1</code>, to DataBuffer <code>db2</code>, whose storage layout is described by SampleModel <code>sm2</code>. The transfer will generally be more efficient than using getPixel/setPixel. <pre> SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, sm1.getDataElements(x, y, null, db1), db2); </pre> Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same. <p> If obj is non-null, it should be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is non-null and is not large enough to hold the pixel data.<DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - The X coordinate of the pixel location.<DD><CODE>y</CODE> - The Y coordinate of the pixel location.<DD><CODE>obj</CODE> - If non-null, a primitive array in which to return the pixel data.<DD><CODE>data</CODE> - The DataBuffer containing the image data.<DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/SampleModel.html#getNumDataElements()"><CODE>getNumDataElements()</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#getTransferType()"><CODE>getTransferType()</CODE></A>, <A HREF="../../../java/awt/image/DataBuffer.html"><CODE>DataBuffer</CODE></A></DL></DD></DL><HR><A NAME="getDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer)"><!-- --></A><H3>getDataElements</H3><PRE>public <A HREF="../../../java/lang/Object.html">Object</A> <B>getDataElements</B>(int x, int y, int w, int h, <A HREF="../../../java/lang/Object.html">Object</A> obj, <A HREF="../../../java/awt/image/DataBuffer.html">DataBuffer</A> data)</PRE><DL><DD>Returns the pixel data for the specified rectangle of pixels in a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT. Data may be returned in a packed format, thus increasing efficiency for data transfers. Generally, obj should be passed in as null, so that the Object will be created automatically and will be of the right primitive data type. <p> The following code illustrates transferring data for a rectangular region of pixels from DataBuffer <code>db1</code>, whose storage layout is described by SampleModel <code>sm1</code>, to DataBuffer <code>db2</code>, whose storage layout is described by SampleModel <code>sm2</code>. The transfer will generally be more efficient than using getPixels/setPixels. <pre> SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, w, h, sm1.getDataElements(x, y, w, h, null, db1), db2); </pre> Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same. <p> If obj is non-null, it should be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is non-null and is not large enough to hold the pixel data.<DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - The minimum X coordinate of the pixel rectangle.<DD><CODE>y</CODE> - The minimum Y coordinate of the pixel rectangle.<DD><CODE>w</CODE> - The width of the pixel rectangle.<DD><CODE>h</CODE> - The height of the pixel rectangle.<DD><CODE>obj</CODE> - If non-null, a primitive array in which to return the pixel data.<DD><CODE>data</CODE> - The DataBuffer containing the image data.<DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/SampleModel.html#getNumDataElements()"><CODE>getNumDataElements()</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#getTransferType()"><CODE>getTransferType()</CODE></A>, <A HREF="../../../java/awt/image/DataBuffer.html"><CODE>DataBuffer</CODE></A></DL></DD></DL><HR><A NAME="setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)"><!-- --></A><H3>setDataElements</H3><PRE>public abstract void <B>setDataElements</B>(int x, int y, <A HREF="../../../java/lang/Object.html">Object</A> obj, <A HREF="../../../java/awt/image/DataBuffer.html">DataBuffer</A> data)</PRE><DL><DD>Sets the data for a single pixel in the specified DataBuffer from a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT. Data in the array may be in a packed format, thus increasing efficiency for data transfers. <p> The following code illustrates transferring data for one pixel from DataBuffer <code>db1</code>, whose storage layout is described by SampleModel <code>sm1</code>, to DataBuffer <code>db2</code>, whose storage layout is described by SampleModel <code>sm2</code>. The transfer will generally be more efficient than using getPixel/setPixel. <pre> SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, sm1.getDataElements(x, y, null, db1), db2); </pre> Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same. <p> obj must be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is not large enough to hold the pixel data.<DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - The X coordinate of the pixel location.<DD><CODE>y</CODE> - The Y coordinate of the pixel location.<DD><CODE>obj</CODE> - A primitive array containing pixel data.<DD><CODE>data</CODE> - The DataBuffer containing the image data.<DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/SampleModel.html#getNumDataElements()"><CODE>getNumDataElements()</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#getTransferType()"><CODE>getTransferType()</CODE></A>, <A HREF="../../../java/awt/image/DataBuffer.html"><CODE>DataBuffer</CODE></A></DL></DD></DL><HR><A NAME="setDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer)"><!-- --></A><H3>setDataElements</H3><PRE>public void <B>setDataElements</B>(int x, int y, int w, int h, <A HREF="../../../java/lang/Object.html">Object</A> obj, <A HREF="../../../java/awt/image/DataBuffer.html">DataBuffer</A> data)</PRE><DL><DD>Sets the data for a rectangle of pixels in the specified DataBuffer from a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT. Data in the array may be in a packed format, thus increasing efficiency for data transfers. <p> The following code illustrates transferring data for a rectangular region of pixels from DataBuffer <code>db1</code>, whose storage layout is described by SampleModel <code>sm1</code>, to DataBuffer <code>db2</code>, whose storage layout is described by SampleModel <code>sm2</code>. The transfer will generally be more efficient than using getPixels/setPixels. <pre> SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, w, h, sm1.getDataElements(x, y, w, h, null, db1), db2); </pre> Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same. <p> obj must be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is not large enough to hold the pixel data.<DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - The minimum X coordinate of the pixel rectangle.<DD><CODE>y</CODE> - The minimum Y coordinate of the pixel rectangle.<DD><CODE>w</CODE> - The width of the pixel rectangle.<DD><CODE>h</CODE> - The height of the pixel rectangle.<DD><CODE>obj</CODE> - A primitive array containing pixel data.<DD><CODE>data</CODE> - The DataBuffer containing the image data.<DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/SampleModel.html#getNumDataElements()"><CODE>getNumDataElements()</CODE></A>, <A HREF="../../../java/awt/image/SampleModel.html#getTransferType()"><CODE>getTransferType()</CODE></A>, <A HREF="../../../java/awt/image/DataBuffer.html"><CODE>DataBuffer</CODE></A></DL></DD></DL><HR><A NAME="getPixel(int, int, float[], java.awt.image.DataBuffer)"><!-- --></A><H3>getPixel</H3><PRE>public float[] <B>getPixel</B>(int x, int y, float[] fArray,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -