public static JPEGQTable[] getQTables(final List<JPEGSegment> segments) throws IOException { int[][] tables = getQuantizationTables(segments); List<JPEGQTable> qTables = new ArrayList<JPEGQTable>(); for (int[] table : tables) { if (table != null) { qTables.add(new JPEGQTable(table)); } } return qTables.toArray(new JPEGQTable[qTables.size()]); }
public static JPEGQTable[] getQTables(final List<JPEGSegment> segments) throws IOException { int[][] tables = getQuantizationTables(segments); List<JPEGQTable> qTables = new ArrayList<JPEGQTable>(); for (int[] table : tables) { if (table != null) { qTables.add(new JPEGQTable(table)); } } return qTables.toArray(new JPEGQTable[qTables.size()]); }
@Test public void testGetQTables() throws IOException { ImageInputStream stream = ImageIO.createImageInputStream(getClass().getResourceAsStream("/jpeg/9788245605525.jpg")); try { JPEGQTable[] tables = JPEGQuality.getQTables(JPEGSegmentUtil.readSegments(stream, JPEG.DQT, null)); assertEquals(1, tables.length); int[] table = { 3, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3, 3, 3, 4, 6, 4, 4, 4, 4, 4, 8, 6, 6, 5, 6, 9, 8, 10, 10, 9, 8, 9, 9, 10, 12, 15, 12, 10, 11, 14, 11, 9, 9, 13, 17, 13, 14, 15, 16, 16, 17, 16, 10, 12, 18, 19, 18, 16, 19, 15, 16, 16, 16 }; assertArrayEquals(table, tables[0].getTable()); // JPEGQTable has no useful equals method.. // assertArrayEquals(new JPEGQTable[] {new JPEGQTable(table)}, tables); } finally { stream.close(); } }
public static JPEGQTable[] getQTables(final List<JPEGSegment> segments) throws IOException { int[][] tables = getQuantizationTables(segments); List<JPEGQTable> qTables = new ArrayList<JPEGQTable>(); for (int[] table : tables) { if (table != null) { qTables.add(new JPEGQTable(table)); } } return qTables.toArray(new JPEGQTable[qTables.size()]); }
QTable(ImageInputStream stream) throws IOException { elementPrecision = (int)stream.readBits(4); tableID = (int)stream.readBits(4); byte[] tmp = new byte[QTABLE_SIZE]; stream.readFully(tmp); int[] data = new int[QTABLE_SIZE]; for (int i = 0; i < QTABLE_SIZE; i++) { data[i] = tmp[zigzag[i]] & 0xff; } table = new JPEGQTable(data); length = data.length + 1; } }
(byte)(((qt.elementPrecision & 0xf0) << 4) | (qt.tableID & 0x0f)); int[] table = qt.table.getTable(); int qlen = table.length; for(int i = 0; i < qlen; i++) {
@Test public void testGetQTables() throws IOException { ImageInputStream stream = ImageIO.createImageInputStream(getClass().getResourceAsStream("/jpeg/9788245605525.jpg")); try { JPEGQTable[] tables = JPEGQuality.getQTables(JPEGSegmentUtil.readSegments(stream, JPEG.DQT, null)); assertEquals(1, tables.length); int[] table = { 3, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3, 3, 3, 4, 6, 4, 4, 4, 4, 4, 8, 6, 6, 5, 6, 9, 8, 10, 10, 9, 8, 9, 9, 10, 12, 15, 12, 10, 11, 14, 11, 9, 9, 13, 17, 13, 14, 15, 16, 16, 17, 16, 10, 12, 18, 19, 18, 16, 19, 15, 16, 16, 16 }; assertArrayEquals(table, tables[0].getTable()); // JPEGQTable has no useful equals method.. // assertArrayEquals(new JPEGQTable[] {new JPEGQTable(table)}, tables); } finally { stream.close(); } }
42, 38, 50, 53, 50, 66, 66, 86, }, tables[0].getTable() ); assertArrayEquals(
3, 3, 3, 3, 3, 3, 3, 3, }, tables[0].getTable() ); assertArrayEquals(