private Rectangle findDiffRect(BufferedImage img, int frame) {
		int left = width;
		int top = height;
		int right = 0;
		int bottom = 0;
		int x1 = (frame % grid) * width;
		int y1 = (frame / grid) * height;
		frame--;
		int x2 = (frame % grid) * width;
		int y2 = (frame / grid) * height;
		for (int y = 0; y < height; y++) {
			for (int x = 0; x < width; x++) {
				if (img.getRGB(x+x1, y+y1) == img.getRGB(x+x2, y+y2))
					img.setRGB(x+x1, y+y1, 0);  // transparent
				else {
					if (y < top)
						top = y;
					bottom = y;
					if (x < left)
						left = x;
					if (x > right)
						right = x;
				}
			}
		}
		if (bottom < top)
			return null;
		return new Rectangle(left, top, right-left+1, bottom-top+1);
	}