示例#1
0
 public boolean scaleImage(
     SunGraphics2D sg,
     Image img,
     int dx1,
     int dy1,
     int dx2,
     int dy2,
     int sx1,
     int sy1,
     int sx2,
     int sy2,
     Color bgColor,
     ImageObserver observer) {
   if (!(img instanceof ToolkitImage)) {
     return scaleImage(sg, img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgColor);
   } else {
     ToolkitImage sunimg = (ToolkitImage) img;
     if (!imageReady(sunimg, observer)) {
       return false;
     }
     ImageRepresentation ir = sunimg.getImageRep();
     return ir.drawToBufImage(
         sg, sunimg, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgColor, observer);
   }
 }
  /**
   * Create an ImageRepresentation for the given Image. The width and height are unknown at this
   * point. The color model is a hint as to the color model to use when creating the buffered image.
   * If null, the src color model will be used.
   */
  public ImageRepresentation(ToolkitImage im, ColorModel cmodel, boolean forceCMhint) {
    image = im;

    if (image.getSource() instanceof InputStreamImageSource) {
      src = (InputStreamImageSource) image.getSource();
    }

    setColorModel(cmodel);

    this.forceCMhint = forceCMhint;
  }
示例#3
0
 public boolean copyImage(
     SunGraphics2D sg, Image img, int x, int y, Color bgColor, ImageObserver observer) {
   if (!(img instanceof ToolkitImage)) {
     return copyImage(sg, img, x, y, bgColor);
   } else {
     ToolkitImage sunimg = (ToolkitImage) img;
     if (!imageReady(sunimg, observer)) {
       return false;
     }
     ImageRepresentation ir = sunimg.getImageRep();
     return ir.drawToBufImage(sg, sunimg, x, y, bgColor, observer);
   }
 }
示例#4
0
 public boolean transformImage(
     SunGraphics2D sg, Image img, AffineTransform atfm, ImageObserver observer) {
   if (!(img instanceof ToolkitImage)) {
     transformImage(sg, img, 0, 0, atfm, sg.interpolationType);
     return true;
   } else {
     ToolkitImage sunimg = (ToolkitImage) img;
     if (!imageReady(sunimg, observer)) {
       return false;
     }
     ImageRepresentation ir = sunimg.getImageRep();
     return ir.drawToBufImage(sg, sunimg, atfm, observer);
   }
 }
 public void setProperties(Hashtable<?, ?> props) {
   if (src != null) {
     src.checkSecurity(null, false);
   }
   image.setProperties(props);
   newInfo(image, ImageObserver.PROPERTIES, 0, 0, 0, 0);
 }
  public void imageComplete(int status) {
    if (src != null) {
      src.checkSecurity(null, false);
    }
    boolean done;
    int info;
    switch (status) {
      default:
      case ImageConsumer.IMAGEABORTED:
        done = true;
        info = ImageObserver.ABORT;
        break;
      case ImageConsumer.IMAGEERROR:
        image.addInfo(ImageObserver.ERROR);
        done = true;
        info = ImageObserver.ERROR;
        dispose();
        break;
      case ImageConsumer.STATICIMAGEDONE:
        done = true;
        info = ImageObserver.ALLBITS;
        break;
      case ImageConsumer.SINGLEFRAMEDONE:
        done = false;
        info = ImageObserver.FRAMEBITS;
        break;
    }
    synchronized (this) {
      if (done) {
        image.getSource().removeConsumer(this);
        consuming = false;
        newbits = null;

        if (bimage != null) {
          bimage = getOpaqueRGBImage();
        }
      }
      availinfo |= info;
      notifyAll();
    }

    newInfo(image, info, 0, 0, width, height);

    image.infoDone(status);
  }
示例#7
0
 protected static boolean imageReady(ToolkitImage sunimg, ImageObserver observer) {
   if (sunimg.hasError()) {
     if (observer != null) {
       observer.imageUpdate(sunimg, ImageObserver.ERROR | ImageObserver.ABORT, -1, -1, -1, -1);
     }
     return false;
   }
   return true;
 }
示例#8
0
 public boolean copyImage(
     SunGraphics2D sg,
     Image img,
     int dx,
     int dy,
     int sx,
     int sy,
     int w,
     int h,
     Color bgColor,
     ImageObserver observer) {
   if (!(img instanceof ToolkitImage)) {
     return copyImage(sg, img, dx, dy, sx, sy, w, h, bgColor);
   } else {
     ToolkitImage sunimg = (ToolkitImage) img;
     if (!imageReady(sunimg, observer)) {
       return false;
     }
     ImageRepresentation ir = sunimg.getImageRep();
     return ir.drawToBufImage(
         sg, sunimg, dx, dy, (dx + w), (dy + h), sx, sy, (sx + w), (sy + h), bgColor, observer);
   }
 }
  synchronized void abort() {
    image.getSource().removeConsumer(this);
    consuming = false;
    newbits = null;
    bimage = null;
    biRaster = null;
    cmodel = null;
    srcLUT = null;
    isDefaultBI = false;
    isSameCM = false;

    newInfo(image, ImageObserver.ABORT, -1, -1, -1, -1);
    availinfo &=
        ~(ImageObserver.SOMEBITS
            | ImageObserver.FRAMEBITS
            | ImageObserver.ALLBITS
            | ImageObserver.ERROR);
  }
  public void setDimensions(int w, int h) {
    if (src != null) {
      src.checkSecurity(null, false);
    }

    image.setDimensions(w, h);

    newInfo(image, (ImageObserver.WIDTH | ImageObserver.HEIGHT), 0, 0, w, h);

    if (w <= 0 || h <= 0) {
      imageComplete(ImageConsumer.IMAGEERROR);
      return;
    }

    if (width != w || height != h) {
      // dimension mismatch => trigger recreation of the buffer
      bimage = null;
    }

    width = w;
    height = h;

    availinfo |= ImageObserver.WIDTH | ImageObserver.HEIGHT;
  }
 synchronized void dispose() {
   image.getSource().removeConsumer(this);
   consuming = false;
   newbits = null;
   availinfo &= ~(ImageObserver.SOMEBITS | ImageObserver.FRAMEBITS | ImageObserver.ALLBITS);
 }
 /*synchronized*/ void startProduction() {
   if (!consuming) {
     consuming = true;
     image.getSource().startProduction(this);
   }
 }
 /**
  * Returns the BufferedImage that will be used as the representation of the pixel data. Subclasses
  * can override this method to return platform specific subclasses of BufferedImage that may or
  * may not be accelerated.
  *
  * <p>It is subclass' responsibility to propagate acceleration priority to the newly created
  * image.
  */
 protected BufferedImage createImage(
     ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable properties) {
   BufferedImage bi = new BufferedImage(cm, raster, isRasterPremultiplied, null);
   bi.setAccelerationPriority(image.getAccelerationPriority());
   return bi;
 }