Example #1
0
  public BufferedImage readBufferedImage() throws IOException {
    colorModel = getColorModel();
    sampleModel = getSampleModel();
    WritableRaster raster = null;
    BufferedImage image = j2krparam.getDestination();

    int x = destinationRegion.x;
    int y = destinationRegion.y;
    destinationRegion.setLocation(j2krparam.getDestinationOffset());
    if (image == null) {
      // If the destination type is specified, use the color model of it.
      ImageTypeSpecifier type = j2krparam.getDestinationType();
      if (type != null) colorModel = type.getColorModel();

      raster =
          Raster.createWritableRaster(
              sampleModel.createCompatibleSampleModel(
                  destinationRegion.x + destinationRegion.width,
                  destinationRegion.y + destinationRegion.height),
              new Point(0, 0));
      image =
          new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), new Hashtable());
    } else raster = image.getWritableTile(0, 0);

    destImage = image;
    readSubsampledRaster(raster);
    destinationRegion.setLocation(x, y);
    destImage = null;
    return image;
  }
Example #2
0
 private void clipDestination(Rectangle dest) {
   Point offset = j2krparam.getDestinationOffset();
   if (dest.x < offset.x) {
     dest.width += dest.x - offset.x;
     dest.x = offset.x;
   }
   if (dest.y < offset.y) {
     dest.height += dest.y - offset.y;
     dest.y = offset.y;
   }
 }