PixelExtractor { static int[] flipIntArray(int[] data, int w, int h, boolean flipX, boolean flipY) { if (flipY) { for (int y = 0; y < h; y++) { for (int x = 0; x < w / 2; x++) { int frontIndex = x + y * w; int backIndex = (y + 1) * w - (x + 1); int temp = data[frontIndex]; data[frontIndex] = data[backIndex]; data[backIndex] = temp; } } } if (flipX) { for (int x = 0; x < w; x++) { for (int y = 0; y < h / 2; y++) { int topIndex = x + y * w; int bottomIndex = x + (h - y - 1) * w; int temp = data[topIndex]; data[topIndex] = data[bottomIndex]; data[bottomIndex] = temp; } } } return data; } PixelExtractor(Header inputHeader,
                          Product product,
                          int macroPixelSize,
                          boolean onlyExtractComplete,
                          String goodPixelMaskExpression,
                          boolean copyInput,
                          AffineTransform i2oTransform); Header getHeader(); Record extract(Record inputRecord, PixelPos originalPixelPos, Date originalPixelTime); static final String GOOD_PIXEL_MASK_NAME; static final String ATTRIB_NAME_AGGREG_PREFIX; static final String EXCLUSION_REASON_ALL_MASKED; }
@Test public void testFlipIntArray() throws Exception { int[] original = { 0, 1, 2, 3, 4, 5 }; int[] flipY = { 1, 0, 3, 2, 5, 4 }; int[] flipX = { 4, 5, 2, 3, 0, 1 }; int[] flipBoth = { 5, 4, 3, 2, 1, 0 }; assertArrayEquals(original, PixelExtractor.flipIntArray(new int[]{0, 1, 2, 3, 4, 5}, 2, 3, false, false)); assertArrayEquals(flipY, PixelExtractor.flipIntArray(new int[]{0, 1, 2, 3, 4, 5}, 2, 3, false, true)); assertArrayEquals(flipX, PixelExtractor.flipIntArray(new int[]{0, 1, 2, 3, 4, 5}, 2, 3, true, false)); assertArrayEquals(flipBoth, PixelExtractor.flipIntArray(new int[]{0, 1, 2, 3, 4, 5}, 2, 3, true, true)); assertArrayEquals(new int[]{1, 0}, PixelExtractor.flipIntArray(new int[]{0, 1}, 1, 2, true, true)); assertArrayEquals(new int[]{3, 2, 1, 0}, PixelExtractor.flipIntArray(new int[]{0, 1, 2, 3}, 2, 2, true, true)); }