| 195 | FastJPEG j2 = new FastJPEG(); |
| 196 | |
| 197 | private Callable<Pair<ByteBuffer, ByteBuffer>> makeWorker(final Pair<ByteBuffer, ByteBuffer> storage, final String filename) { |
| 198 | return new Callable<Pair<ByteBuffer, ByteBuffer>>() { |
| 199 | public Pair<ByteBuffer, ByteBuffer> call() throws Exception { |
| 200 | |
| 201 | for (int y = 0; y < height; y++) { |
| 202 | storage.first.position(y * width * 3); |
| 203 | storage.first.limit((y + 1) * width * 3); |
| 204 | storage.second.position((height - y - 1) * width * 3); |
| 205 | storage.second.limit((height - y - 1 + 1) * width * 3); |
| 206 | storage.second.put(storage.first); |
| 207 | storage.second.clear(); |
| 208 | storage.first.clear(); |
| 209 | } |
| 210 | |
| 211 | try { |
| 212 | new SlowJPEG().compress(filename, storage.second, width, height); |
| 213 | } catch (Throwable t) { |
| 214 | System.err.println(" -- exception thrown in compress for :" + filename + " " + storage + " " + width + " " + height); |
| 215 | t.printStackTrace(); |
| 216 | } |
| 217 | return storage; |
| 218 | |
| 219 | } |
| 220 | }; |