@Test public void testGetOffsets() throws Exception { assert getOffsets("sample1", false)[0] == 1; assert getOffsets("sample1", false)[1] == 7; assert getOffsets("sample2", false)[0] == 1; assert getOffsets("sample2", false)[1] == 7; assert getOffsets("sample3", false)[0] == 1; assert getOffsets("sample3", false)[1] == 5; assert getOffsets("sample4", false)[0] == 2; assert getOffsets("sample4", false)[1] == 6; assert getOffsets("sample5", false)[0] == 0; assert getOffsets("sample5", false)[1] == 3; assert getOffsets("sample6", false)[0] == 0; assert getOffsets("sample6", false)[1] == 3; assert getOffsets("sample7", false)[0] == 0; assert getOffsets("sample7", false)[1] == 3; assert getOffsets("sample8", false)[0] == 0; assert getOffsets("sample8", false)[1] == 3; assert getOffsets("sample9", false)[0] == 1; assert getOffsets("sample9", false)[1] == 8; assert getOffsets("sample10", false)[0] == 0; assert getOffsets("sample10", false)[1] == 7; assert getOffsets("sample11", false)[0] == 1; assert getOffsets("sample11", false)[1] == 8; assert getOffsets("sample12", false)[0] == 0; assert getOffsets("sample12", false)[1] == 7; assert getOffsets("sample13", false)[0] == 3; assert getOffsets("sample13", false)[1] == 4; assert getOffsets("sample14", false)[0] == 1; assert getOffsets("sample14", false)[1] == 8; assert getOffsets("sample15", false)[0] == 1; assert getOffsets("sample15", false)[1] == 7; assert getOffsets("sample16", false)[0] == 1; assert getOffsets("sample16", false)[1] == 7; assert getOffsets("sample17", false)[0] == 0; assert getOffsets("sample17", false)[1] == 8; assert getOffsets("sample18", false)[0] == 4; assert getOffsets("sample18", false)[1] == 8; assert getOffsets("sample19", false)[0] == 3; assert getOffsets("sample19", false)[1] == 8; assert getOffsets("sample20", false)[0] == 0; assert getOffsets("sample20", false)[1] == 5; assert getOffsets("sample21", false)[0] == 0; assert getOffsets("sample21", false)[1] == 3; assert getOffsets("sample22", false)[0] == 0; assert getOffsets("sample22", false)[1] == 3; assert getOffsets("sample23", false)[0] == 0; assert getOffsets("sample23", false)[1] == 3; assert getOffsets("sample1", true)[0] == 0; assert getOffsets("sample1", true)[1] == 3; assert getOffsets("sample2", true)[0] == 0; assert getOffsets("sample2", true)[1] == 3; assert getOffsets("sample3", true)[0] == 0; assert getOffsets("sample3", true)[1] == 3; assert getOffsets("sample4", true)[0] == 0; assert getOffsets("sample4", true)[1] == 3; assert getOffsets("sample5", true)[0] == 1; assert getOffsets("sample5", true)[1] == 5; assert getOffsets("sample6", true)[0] == 2; assert getOffsets("sample6", true)[1] == 6; assert getOffsets("sample7", true)[0] == 1; assert getOffsets("sample7", true)[1] == 7; assert getOffsets("sample8", true)[0] == 1; assert getOffsets("sample8", true)[1] == 7; assert getOffsets("sample9", true)[0] == 0; assert getOffsets("sample9", true)[1] == 2; assert getOffsets("sample10", true)[0] == 1; assert getOffsets("sample10", true)[1] == 3; assert getOffsets("sample11", true)[0] == 1; assert getOffsets("sample11", true)[1] == 3; assert getOffsets("sample12", true)[0] == 0; assert getOffsets("sample12", true)[1] == 2; assert getOffsets("sample13", true)[0] == 1; assert getOffsets("sample13", true)[1] == 3; assert getOffsets("sample14", true)[0] == 1; assert getOffsets("sample14", true)[1] == 2; assert getOffsets("sample15", true)[0] == 1; assert getOffsets("sample15", true)[1] == 2; assert getOffsets("sample16", true)[0] == 1; assert getOffsets("sample16", true)[1] == 2; assert getOffsets("sample17", true)[0] == 0; assert getOffsets("sample17", true)[1] == 3; assert getOffsets("sample18", true)[0] == 0; assert getOffsets("sample18", true)[1] == 3; assert getOffsets("sample19", true)[0] == 0; assert getOffsets("sample19", true)[1] == 3; assert getOffsets("sample20", true)[0] == 0; assert getOffsets("sample20", true)[1] == 3; assert getOffsets("sample21", true)[0] == 4; assert getOffsets("sample21", true)[1] == 8; assert getOffsets("sample22", true)[0] == 3; assert getOffsets("sample22", true)[1] == 8; assert getOffsets("sample23", true)[0] == 0; assert getOffsets("sample23", true)[1] == 5; }
public static int[] getOffsets(int width, int height, boolean checkHeight, TIntObjectHashMap<int[]> pixels) { int[] result = new int[]{0, width}; if (checkHeight) { Integer[] scanline = new Integer[width]; loop: for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[0] = y + 1; } scanline = new Integer[width]; loop: for (int y = height - 1; y >= 0; y--) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[1] = y; } if (result[0] > result[1]) { result[0] = 0; result[1] = height; } else if (result[0] == result[1]) { if (result[0] > (height - result[1])) { result[0] = 0; } else { result[1] = height; } } } else { Integer[] scanline = new Integer[height]; loop: for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[0] = x + 1; } scanline = new Integer[height]; loop: for (int x = width - 1; x >= 0; x--) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[1] = x; } if (result[0] > result[1]) { result[0] = 0; result[1] = width; } else if (result[0] == result[1]) { if (result[0] > (width - result[1])) { result[0] = 0; } else { result[1] = width; } } } return result; }
TextureTools { public static int[] getOffsets(int width, int height, boolean checkHeight, TIntObjectHashMap<int[]> pixels) { int[] result = new int[]{0, width}; if (checkHeight) { Integer[] scanline = new Integer[width]; loop: for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[0] = y + 1; } scanline = new Integer[width]; loop: for (int y = height - 1; y >= 0; y--) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[1] = y; } if (result[0] > result[1]) { result[0] = 0; result[1] = height; } else if (result[0] == result[1]) { if (result[0] > (height - result[1])) { result[0] = 0; } else { result[1] = height; } } } else { Integer[] scanline = new Integer[height]; loop: for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[0] = x + 1; } scanline = new Integer[height]; loop: for (int x = width - 1; x >= 0; x--) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[1] = x; } if (result[0] > result[1]) { result[0] = 0; result[1] = width; } else if (result[0] == result[1]) { if (result[0] > (width - result[1])) { result[0] = 0; } else { result[1] = width; } } } return result; } }
TextureTools { public static int[] getOffsets(int width, int height, boolean checkHeight, TIntObjectHashMap<int[]> pixels) { int[] result = new int[]{0, width}; if (checkHeight) { Integer[] scanline = new Integer[width]; loop: for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[0] = y + 1; } scanline = new Integer[width]; loop: for (int y = height - 1; y >= 0; y--) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[1] = y; } if (result[0] > result[1]) { result[0] = 0; result[1] = height; } else if (result[0] == result[1]) { if (result[0] > (height - result[1])) { result[0] = 0; } else { result[1] = height; } } } else { Integer[] scanline = new Integer[height]; loop: for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[0] = x + 1; } scanline = new Integer[height]; loop: for (int x = width - 1; x >= 0; x--) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[1] = x; } if (result[0] > result[1]) { result[0] = 0; result[1] = width; } else if (result[0] == result[1]) { if (result[0] > (width - result[1])) { result[0] = 0; } else { result[1] = width; } } } return result; }  }
TextureTools { public static int[] getOffsets(int width, int height, boolean checkHeight, TIntObjectHashMap<int[]> pixels) { int[] result = new int[]{0, width}; if (checkHeight) { Integer[] scanline = new Integer[width]; loop: for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[0] = y + 1; } scanline = new Integer[width]; loop: for (int y = height - 1; y >= 0; y--) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[1] = y; } if (result[0] > result[1]) { result[0] = 0; result[1] = height; } else if (result[0] == result[1]) { if (result[0] > (height - result[1])) { result[0] = 0; } else { result[1] = height; } } } else { Integer[] scanline = new Integer[height]; loop: for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[0] = x + 1; } scanline = new Integer[height]; loop: for (int x = width - 1; x >= 0; x--) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[1] = x; } if (result[0] > result[1]) { result[0] = 0; result[1] = width; } else if (result[0] == result[1]) { if (result[0] > (width - result[1])) { result[0] = 0; } else { result[1] = width; } } } return result; }  static int[] getOffsets(int width, int height, boolean checkHeight, TIntObjectHashMap<int[]> pixels); static int[] compress(int width, int height, int front, int back, boolean useHeight, TIntObjectHashMap<int[]> pixels); }
TextureTools { public static int[] getOffsets(int width, int height, boolean checkHeight, TIntObjectHashMap<int[]> pixels) { int[] result = new int[]{0, width}; if (checkHeight) { Integer[] scanline = new Integer[width]; loop: for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[0] = y + 1; } scanline = new Integer[width]; loop: for (int y = height - 1; y >= 0; y--) { for (int x = 0; x < width; x++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[x] == null) { scanline[x] = pixel[2]; } else if (scanline[x] != pixel[2]) { break loop; } } } result[1] = y; } if (result[0] > result[1]) { result[0] = 0; result[1] = height; } else if (result[0] == result[1]) { if (result[0] > (height - result[1])) { result[0] = 0; } else { result[1] = height; } } } else { Integer[] scanline = new Integer[height]; loop: for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[0] = x + 1; } scanline = new Integer[height]; loop: for (int x = width - 1; x >= 0; x--) { for (int y = 0; y < height; y++) { int[] pixel = pixels.get(IntegerTools.makeInt(x, y)); if (pixel != null) { if (scanline[y] == null) { scanline[y] = pixel[2]; } else if (scanline[y] != pixel[2]) { break loop; } } } result[1] = x; } if (result[0] > result[1]) { result[0] = 0; result[1] = width; } else if (result[0] == result[1]) { if (result[0] > (width - result[1])) { result[0] = 0; } else { result[1] = width; } } } return result; }  static int[] getOffsets(int width, int height, boolean checkHeight, TIntObjectHashMap<int[]> pixels); static int[] compress(int width, int height, int front, int back, boolean useHeight, TIntObjectHashMap<int[]> pixels);  }