// Path: rezenerator-core/src/main/java/com/tlorrain/android/rezenerator/core/utils/StreamUtils.java
// static int readIntBigEndianOnTwoBytes(final InputStream is) throws IOException {
// 	int ret = 0;
// 	ret |= is.read() << 8;
// 	ret |= is.read();
// 	return ret;
// }
// 
// Path: rezenerator-core/src/main/java/com/tlorrain/android/rezenerator/core/Dimensions.java
// public class Dimensions {
// 	private final int height, width;
// 
// 	public Dimensions(final int height, final int width) {
// 		this.height = height;
// 		this.width = width;
// 	}
// 
// 	public Dimensions(final int squareSize) {
// 		this(squareSize, squareSize);
// 	}
// 
// 	public int getHeight() {
// 		return height;
// 	}
// 
// 	public int getWidth() {
// 		return width;
// 	}
// 
// 	public Dimensions multiply(final int factor) {
// 		return new Dimensions(height * factor, width * factor);
// 	}
// 
// 	public Dimensions divide(final int divisor) {
// 		return new Dimensions(height / divisor, width / divisor);
// 	}
// 
// 	public Dimensions scaleToWidth(final int newWidth) {
// 		return new Dimensions(height * newWidth / width, newWidth);
// 	}
// 
// 	public Dimensions scaleToHeight(final int newHeight) {
// 		return new Dimensions(newHeight, width * newHeight / height);
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + height;
// 		result = prime * result + width;
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(final Object obj) {
// 		if (this == obj) {
// 			return true;
// 		}
// 		if (obj == null) {
// 			return false;
// 		}
// 		if (getClass() != obj.getClass()) {
// 			return false;
// 		}
// 		final Dimensions other = (Dimensions) obj;
// 		if (height != other.height) {
// 			return false;
// 		}
// 		if (width != other.width) {
// 			return false;
// 		}
// 		return true;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Dimensions [height=" + height + ", width=" + width + "]";
// 	}
// 
// 	private static final Pattern PATTERN_SIMPLE = Pattern.compile("\\d+");
// 	private static final Pattern PATTERN_X = Pattern.compile("(\\d+)[xX](\\d+)");
// 
// 	public static Dimensions fromString(final String string) {
// 		if (string.matches(PATTERN_SIMPLE.pattern())) {
// 			return new Dimensions(Integer.parseInt(string));
// 		} else if (string.matches(PATTERN_X.pattern())) {
// 			final Matcher matcher = PATTERN_X.matcher(string);
// 			matcher.find();
// 			return new Dimensions(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)));
// 		}
// 		throw new IllegalArgumentException(string);
// 	}
// }


import static com.tlorrain.android.rezenerator.core.utils.StreamUtils.readIntBigEndianOnTwoBytes;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import com.tlorrain.android.rezenerator.core.Dimensions;
package com.tlorrain.android.rezenerator.core.utils;





public class PNGFileUtils {

	public static Dimensions getDimensions(final File outFile) throws FileNotFoundException, IOException {
		// this code is largely inspired from
		// http://blog.jaimon.co.uk/simpleimageinfo/SimpleImageInfo.java.html
		// credits to him (Apache 2 Licence)
		Dimensions dimensions = null;
		final FileInputStream is = new FileInputStream(outFile);
		try {
			// PNG file
			if (is.read() == 137 && is.read() == 80 && is.read() == 78) {
				is.skip(15);
				final int width = readIntBigEndianOnTwoBytes(is);
				is.skip(2);
// Path: rezenerator-core/src/main/java/com/tlorrain/android/rezenerator/core/utils/StreamUtils.java
// static int readIntBigEndianOnTwoBytes(final InputStream is) throws IOException {
// 	int ret = 0;
// 	ret |= is.read() << 8;
// 	ret |= is.read();
// 	return ret;
// }
// 
// Path: rezenerator-core/src/main/java/com/tlorrain/android/rezenerator/core/Dimensions.java
// public class Dimensions {
// 	private final int height, width;
// 
// 	public Dimensions(final int height, final int width) {
// 		this.height = height;
// 		this.width = width;
// 	}
// 
// 	public Dimensions(final int squareSize) {
// 		this(squareSize, squareSize);
// 	}
// 
// 	public int getHeight() {
// 		return height;
// 	}
// 
// 	public int getWidth() {
// 		return width;
// 	}
// 
// 	public Dimensions multiply(final int factor) {
// 		return new Dimensions(height * factor, width * factor);
// 	}
// 
// 	public Dimensions divide(final int divisor) {
// 		return new Dimensions(height / divisor, width / divisor);
// 	}
// 
// 	public Dimensions scaleToWidth(final int newWidth) {
// 		return new Dimensions(height * newWidth / width, newWidth);
// 	}
// 
// 	public Dimensions scaleToHeight(final int newHeight) {
// 		return new Dimensions(newHeight, width * newHeight / height);
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + height;
// 		result = prime * result + width;
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(final Object obj) {
// 		if (this == obj) {
// 			return true;
// 		}
// 		if (obj == null) {
// 			return false;
// 		}
// 		if (getClass() != obj.getClass()) {
// 			return false;
// 		}
// 		final Dimensions other = (Dimensions) obj;
// 		if (height != other.height) {
// 			return false;
// 		}
// 		if (width != other.width) {
// 			return false;
// 		}
// 		return true;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Dimensions [height=" + height + ", width=" + width + "]";
// 	}
// 
// 	private static final Pattern PATTERN_SIMPLE = Pattern.compile("\\d+");
// 	private static final Pattern PATTERN_X = Pattern.compile("(\\d+)[xX](\\d+)");
// 
// 	public static Dimensions fromString(final String string) {
// 		if (string.matches(PATTERN_SIMPLE.pattern())) {
// 			return new Dimensions(Integer.parseInt(string));
// 		} else if (string.matches(PATTERN_X.pattern())) {
// 			final Matcher matcher = PATTERN_X.matcher(string);
// 			matcher.find();
// 			return new Dimensions(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)));
// 		}
// 		throw new IllegalArgumentException(string);
// 	}
// }


// Path: rezenerator-core/src/main/java/com/tlorrain/android/rezenerator/core/utils/PNGFileUtils.java
import static com.tlorrain.android.rezenerator.core.utils.StreamUtils.readIntBigEndianOnTwoBytes;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import com.tlorrain.android.rezenerator.core.Dimensions;

package com.tlorrain.android.rezenerator.core.utils;





public class PNGFileUtils {

	public static Dimensions getDimensions(final File outFile) throws FileNotFoundException, IOException {
		// this code is largely inspired from
		// http://blog.jaimon.co.uk/simpleimageinfo/SimpleImageInfo.java.html
		// credits to him (Apache 2 Licence)
		Dimensions dimensions = null;
		final FileInputStream is = new FileInputStream(outFile);
		try {
			// PNG file
			if (is.read() == 137 && is.read() == 80 && is.read() == 78) {
				is.skip(15);
				final int width = readIntBigEndianOnTwoBytes(is);
				is.skip(2);
				final int height = readIntBigEndianOnTwoBytes(is);