⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pixelgrabber.java

📁 gcc的JAVA模块的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    if ((consumerStatus & IMAGEABORTED) != 0)      observerStatus |= ImageObserver.ABORT;    if ((consumerStatus & STATICIMAGEDONE) != 0)      {	observerStatus |= ImageObserver.ALLBITS;	retval = true;      }    if ((consumerStatus & SINGLEFRAMEDONE) != 0)      {	observerStatus |= ImageObserver.FRAMEBITS;	retval = true;      }    return retval;  }  /**   * @return the status of the pixel grabbing thread, represented by a   * bitwise OR of ImageObserver flags   */  public synchronized int getStatus()  {    return observerStatus;  }  /**   * @return the width of the grab rectangle in pixels, or a negative   * number if the ImageProducer has not yet called our setDimensions   * method   */  public synchronized int getWidth()  {    return width;  }  /**   * @return the height of the grab rectangle in pixels, or a negative   * number if the ImageProducer has not yet called our setDimensions   * method   */  public synchronized int getHeight()  {    return height;  }  /**   * @return a byte array of pixel data if ImageProducer delivered   * pixel data using the byte[] variant of setPixels, or an int array   * otherwise   */  public synchronized Object getPixels()  {    if (ints_delivered)      return int_pixel_buffer;    else if (bytes_delivered)      return byte_pixel_buffer;    else      return null;  }  /**   * @return the ColorModel currently being used for the majority of   * pixel data conversions   */  public synchronized ColorModel getColorModel()  {    return model;  }  /**   * Our <code>ImageProducer</code> calls this method to indicate the   * size of the image being produced.   *   * setDimensions is an ImageConsumer method.  None of PixelGrabber's   * ImageConsumer methods should be called by code that instantiates   * a PixelGrabber.  They are only made public so they can be called   * by the PixelGrabber's ImageProducer.   *    * @param width the width of the image   * @param height the height of the image   */  public synchronized void setDimensions(int width, int height)  {    // Our width wasn't set when we were constructed.  Set our width    // so that the grab region includes all pixels from x to the right    // edge of the source image.    if (this.width < 0)      this.width = width - x;    // Our height wasn't set when we were constructed.  Set our height    // so that the grab region includes all pixels from y to the    // bottom edge of the source image.    if (this.height < 0)      this.height = height - y;    if (scansize < 0)      scansize = this.width;    if (int_pixel_buffer == null)      int_pixel_buffer = new int[this.width * this.height];    if (byte_pixel_buffer == null)      byte_pixel_buffer = new byte[this.width * this.height];  }  /**   * Our <code>ImageProducer</code> may call this method to send us a   * list of its image's properties.   *   * setProperties is an ImageConsumer method.  None of PixelGrabber's   * ImageConsumer methods should be called by code that instantiates   * a PixelGrabber.  They are only made public so they can be called   * by the PixelGrabber's ImageProducer.   *   * @param props a list of properties associated with the image being   * produced   */  public synchronized void setProperties(Hashtable props)  {    this.props = props;  }  /**   * Our ImageProducer will call <code>setColorModel</code> to   * indicate the model used by the majority of calls to   * <code>setPixels</code>.  Each call to <code>setPixels</code>   * could however indicate a different <code>ColorModel</code>.   *   * setColorModel is an ImageConsumer method.  None of PixelGrabber's   * ImageConsumer methods should be called by code that instantiates   * a PixelGrabber.  They are only made public so they can be called   * by the PixelGrabber's ImageProducer.   *   * @param model the color model to be used most often by setPixels   *   * @see ColorModel   */  public synchronized void setColorModel(ColorModel model)  {    this.model = model;  }  /**   * Our <code>ImageProducer</code> may call this method with a   * bit mask of hints from any of <code>RANDOMPIXELORDER</code>,   * <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>,   * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code>.   *    * setHints is an ImageConsumer method.  None of PixelGrabber's   * ImageConsumer methods should be called by code that instantiates   * a PixelGrabber.  They are only made public so they can be called   * by the PixelGrabber's ImageProducer.   *   * @param flags a bit mask of hints   */  public synchronized void setHints(int flags)  {    hints = flags;  }  /**   * Our ImageProducer calls setPixels to deliver a subset of its   * pixels.   *   * Each element of the pixels array represents one pixel.  The   * pixel data is formatted according to the color model model.   * The x and y parameters are the coordinates of the rectangular   * region of pixels being delivered to this ImageConsumer,   * specified relative to the top left corner of the image being   * produced.  Likewise, w and h are the pixel region's dimensions.   *   * @param x x coordinate of pixel block   * @param y y coordinate of pixel block   * @param w width of pixel block   * @param h height of pixel block   * @param model color model used to interpret pixel data   * @param pixels pixel block data   * @param offset offset into pixels array   * @param scansize width of one row in the pixel block   */  public synchronized void setPixels(int x, int y, int w, int h, 				     ColorModel model, byte[] pixels,				     int offset, int scansize)  {    ColorModel currentModel;    if (model != null)      currentModel = model;    else      currentModel = this.model;    for(int yp = y; yp < (y + h); yp++)      {	for(int xp = x; xp < (x + w); xp++)	  {	    // Check if the coordinates (xp, yp) are within the	    // pixel block that we are grabbing.	    if(xp >= this.x	       && yp >= this.y	       && xp < (this.x + this.width)	       && yp < (this.y + this.height))	      {		int i = (yp - this.y) * this.scansize + (xp - this.x) + this.offset;		int p = (yp - y) * scansize + (xp - x) + offset;		if (forceRGB)		  {		    ints_delivered = true;		    assert (i >= 0 && i < int_pixel_buffer.length);		    assert (p >= 0 && p < pixels.length);		    int_pixel_buffer[i] = currentModel.getRGB (pixels[p]);		  }		else		  {		    bytes_delivered = true;		    assert (i >= 0 && i < byte_pixel_buffer.length);		    assert (p >= 0 && p < pixels.length);		    byte_pixel_buffer[i] = pixels[p];		  }	      }	  }      }  }  /**   * Our ImageProducer calls setPixels to deliver a subset of its   * pixels.   *   * Each element of the pixels array represents one pixel.  The   * pixel data is formatted according to the color model model.   * The x and y parameters are the coordinates of the rectangular   * region of pixels being delivered to this ImageConsumer,   * specified relative to the top left corner of the image being   * produced.  Likewise, w and h are the pixel region's dimensions.   *   * @param x x coordinate of pixel block   * @param y y coordinate of pixel block   * @param w width of pixel block   * @param h height of pixel block   * @param model color model used to interpret pixel data   * @param pixels pixel block data   * @param offset offset into pixels array   * @param scansize width of one row in the pixel block   */  public synchronized void setPixels(int x, int y, int w, int h, 				     ColorModel model, int[] pixels,				     int offset, int scansize)  {    ColorModel currentModel;    if (model != null)      currentModel = model;    else      currentModel = this.model;    ints_delivered = true;    for(int yp = y; yp < (y + h); yp++)      {	for(int xp = x; xp < (x + w); xp++)	  {	    // Check if the coordinates (xp, yp) are within the	    // pixel block that we are grabbing.	    if(xp >= this.x	       && yp >= this.y	       && xp < (this.x + this.width)	       && yp < (this.y + this.height))	      {		int i = (yp - this.y) * this.scansize + (xp - this.x) + this.offset;		int p = (yp - y) * scansize + (xp - x) + offset;		assert (i >= 0 && i < int_pixel_buffer.length);		assert (p >= 0 && p < pixels.length);		if (forceRGB)		  int_pixel_buffer[i] = currentModel.getRGB (pixels[p]);		else		  int_pixel_buffer[i] = pixels[p];	      }	  }      }  }  /**   * Our <code>ImageProducer</code> calls this method to inform us   * that a single frame or the entire image is complete.  The method   * is also used to inform us of an error in loading or producing the   * image.   *   * @param status the status of image production, represented by a   * bitwise OR of ImageConsumer flags   */  public synchronized void imageComplete(int status)  {    consumerStatus = status;    setObserverStatus ();    grabbing = false;    ip.removeConsumer (this);    notifyAll ();  }  /**   * @return the return value of getStatus   *   * @specnote The newer getStatus should be used in place of status.   */  public synchronized int status()  {    return getStatus();  }}

⌨️ 快捷键说明

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