Esempio n. 1
0
 private ImageReadParam decompressParam(ImageReadParam param) {
   ImageReadParam decompressParam = decompressor.getDefaultReadParam();
   ImageTypeSpecifier imageType = param.getDestinationType();
   BufferedImage dest = param.getDestination();
   if (isRLELossless() && imageType == null && dest == null)
     imageType = createImageType(bitsStored, dataType, true);
   decompressParam.setDestinationType(imageType);
   decompressParam.setDestination(dest);
   return decompressParam;
 }
Esempio n. 2
0
  public static void main(String[] args) throws IOException {
    PCXImageReader reader = new PCXImageReader(null);

    for (String arg : args) {
      File in = new File(arg);
      reader.setInput(ImageIO.createImageInputStream(in));

      ImageReadParam param = reader.getDefaultReadParam();
      param.setDestinationType(reader.getImageTypes(0).next());
      //            param.setSourceSubsampling(2, 3, 0, 0);
      //            param.setSourceSubsampling(2, 1, 0, 0);
      //
      //            int width = reader.getWidth(0);
      //            int height = reader.getHeight(0);
      //
      //            param.setSourceRegion(new Rectangle(width / 4, height / 4, width / 2, height /
      // 2));
      //            param.setSourceRegion(new Rectangle(width / 2, height / 2));
      //            param.setSourceRegion(new Rectangle(width / 2, height / 2, width / 2, height /
      // 2));

      System.err.println("header: " + reader.header);

      BufferedImage image = reader.read(0, param);

      System.err.println("image: " + image);

      showIt(image, in.getName());

      new XMLSerializer(System.out, System.getProperty("file.encoding"))
          .serialize(
              reader
                  .getImageMetadata(0)
                  .getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName),
              false);

      //            File reference = new File(in.getParent() + "/../reference",
      // in.getName().replaceAll("\\.p(a|b|g|p)m", ".png"));
      //            if (reference.exists()) {
      //                System.err.println("reference.getAbsolutePath(): " +
      // reference.getAbsolutePath());
      //                showIt(ImageIO.read(reference), reference.getName());
      //            }

      //            break;
    }
  }
  public TIFFRenderedImage(
      TIFFImageReader reader, int imageIndex, ImageReadParam readParam, int width, int height)
      throws IOException {
    this.reader = reader;
    this.imageIndex = imageIndex;
    this.tileParam = cloneImageReadParam(readParam, false);

    this.subsampleX = tileParam.getSourceXSubsampling();
    this.subsampleY = tileParam.getSourceYSubsampling();

    this.isSubsampling = this.subsampleX != 1 || this.subsampleY != 1;

    this.width = width / subsampleX;
    this.height = height / subsampleY;

    // If subsampling is being used, we may not match the
    // true tile grid exactly, but everything should still work
    this.tileWidth = reader.getTileWidth(imageIndex) / subsampleX;
    this.tileHeight = reader.getTileHeight(imageIndex) / subsampleY;

    Iterator iter = reader.getImageTypes(imageIndex);
    this.its = (ImageTypeSpecifier) iter.next();
    tileParam.setDestinationType(its);
  }