view com/hjg/pngj/PngReaderInt.java @ 4:3f418d4451d6 pngj

add pngj
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 Apr 2016 09:52:58 +0200
parents
children
line wrap: on
line source

package ar.com.hjg.pngj;

import java.io.File;
import java.io.InputStream;

/**
 * Trivial extension of {@link PngReader} that uses {@link ImageLineInt}.
 * <p>
 * In the current implementation this is quite dummy/redundant, because (for backward compatibility) PngReader already
 * uses a {@link ImageLineInt}.
 * <p>
 * The factory is set at construction time. Remember that this could still be changed at runtime.
 */
public class PngReaderInt extends PngReader {

  public PngReaderInt(File file) {
    super(file); // not necessary to set factory, PngReader already does that
  }

  public PngReaderInt(InputStream inputStream) {
    super(inputStream);
  }

  /**
   * Utility method that casts the IImageLine to a ImageLineInt
   * 
   * This only make sense for this concrete class
   * 
   */
  public ImageLineInt readRowInt() {
    IImageLine line = readRow();
    if (line instanceof ImageLineInt)
      return (ImageLineInt) line;
    else
      throw new PngjException("This is not a ImageLineInt : " + line.getClass());
  }
}