📄 memoryimagesource.html
字号:
<!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:10 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class MemoryImageSource</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> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/MemoryImageSource.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../java/awt/image/LookupTable.html"><B>PREV CLASS</B></A> <A HREF="../../../java/awt/image/MultiPixelPackedSampleModel.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> <A HREF="MemoryImageSource.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <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 MemoryImageSource</H2><PRE><A HREF="../../../java/lang/Object.html">java.lang.Object</A> | +--<B>java.awt.image.MemoryImageSource</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../java/awt/image/ImageProducer.html">ImageProducer</A></DD></DL><HR><DL><DT>public class <B>MemoryImageSource</B><DT>extends <A HREF="../../../java/lang/Object.html">Object</A><DT>implements <A HREF="../../../java/awt/image/ImageProducer.html">ImageProducer</A></DL><P>This class is an implementation of the ImageProducer interface which uses an array to produce pixel values for an Image. Here is an example which calculates a 100x100 image representing a fade from black to blue along the X axis and a fade from black to red along the Y axis: <pre> int w = 100; int h = 100; int pix[] = new int[w * h]; int index = 0; for (int y = 0; y < h; y++) { int red = (y * 255) / (h - 1); for (int x = 0; x < w; x++) { int blue = (x * 255) / (w - 1); pix[index++] = (255 << 24) | (red << 16) | blue; } } Image img = createImage(new MemoryImageSource(w, h, pix, 0, w)); </pre> The MemoryImageSource is also capable of managing a memory image which varies over time to allow animation or custom rendering. Here is an example showing how to set up the animation source and signal changes in the data (adapted from the MemoryAnimationSourceDemo by Garth Dickie): <pre> int pixels[]; MemoryImageSource source; public void init() { int width = 50; int height = 50; int size = width * height; pixels = new int[size]; int value = getBackground().getRGB(); for (int i = 0; i < size; i++) { pixels[i] = value; } source = new MemoryImageSource(width, height, pixels, 0, width); source.setAnimated(true); image = createImage(source); } public void run() { Thread me = Thread.currentThread( ); me.setPriority(Thread.MIN_PRIORITY); while (true) { try { thread.sleep(10); } catch( InterruptedException e ) { return; } // Modify the values in the pixels array at (x, y, w, h) // Send the new data to the interested ImageConsumers source.newPixels(x, y, w, h); } } </pre><P><DL><DT><B>See Also: </B><DD><A HREF="../../../java/awt/image/ImageProducer.html"><CODE>ImageProducer</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== 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><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#MemoryImageSource(int, int, java.awt.image.ColorModel, byte[], int, int)">MemoryImageSource</A></B>(int w, int h, <A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A> cm, byte[] pix, int off, int scan)</CODE><BR> Constructs an ImageProducer object which uses an array of bytes to produce data for an Image object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#MemoryImageSource(int, int, java.awt.image.ColorModel, byte[], int, int, java.util.Hashtable)">MemoryImageSource</A></B>(int w, int h, <A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A> cm, byte[] pix, int off, int scan, <A HREF="../../../java/util/Hashtable.html">Hashtable</A> props)</CODE><BR> Constructs an ImageProducer object which uses an array of bytes to produce data for an Image object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#MemoryImageSource(int, int, java.awt.image.ColorModel, int[], int, int)">MemoryImageSource</A></B>(int w, int h, <A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A> cm, int[] pix, int off, int scan)</CODE><BR> Constructs an ImageProducer object which uses an array of integers to produce data for an Image object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#MemoryImageSource(int, int, java.awt.image.ColorModel, int[], int, int, java.util.Hashtable)">MemoryImageSource</A></B>(int w, int h, <A HREF="../../../java/awt/image/ColorModel.html">ColorModel</A> cm, int[] pix, int off, int scan, <A HREF="../../../java/util/Hashtable.html">Hashtable</A> props)</CODE><BR> Constructs an ImageProducer object which uses an array of integers to produce data for an Image object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#MemoryImageSource(int, int, int[], int, int)">MemoryImageSource</A></B>(int w, int h, int[] pix, int off, int scan)</CODE><BR> Constructs an ImageProducer object which uses an array of integers in the default RGB ColorModel to produce data for an Image object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#MemoryImageSource(int, int, int[], int, int, java.util.Hashtable)">MemoryImageSource</A></B>(int w, int h, int[] pix, int off, int scan, <A HREF="../../../java/util/Hashtable.html">Hashtable</A> props)</CODE><BR> Constructs an ImageProducer object which uses an array of integers in the default RGB ColorModel to produce data for an Image object.</TD></TR></TABLE> <!-- ========== 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> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#addConsumer(java.awt.image.ImageConsumer)">addConsumer</A></B>(<A HREF="../../../java/awt/image/ImageConsumer.html">ImageConsumer</A> ic)</CODE><BR> Adds an ImageConsumer to the list of consumers interested in data for this image.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#isConsumer(java.awt.image.ImageConsumer)">isConsumer</A></B>(<A HREF="../../../java/awt/image/ImageConsumer.html">ImageConsumer</A> ic)</CODE><BR> Determine if an ImageConsumer is on the list of consumers currently interested in data for this image.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../java/awt/image/MemoryImageSource.html#newPixels()">newPixels</A></B>()</CODE><BR> Send a whole new buffer of pixels to any ImageConsumers that
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -