size < 0 ? "" : Integer.toString((int) size));
log("thumb = " + scaled.getAbsolutePath());
if (useScaled(file, scaled)) {
streamScaled(scaled, response.getOutputStream());
} else {
PlanarImage image = loadImage(file);
image = scale(image, size);
writeToResponse(response, mime, scaled, image, doCache);
}
} else {
BufferedImage image = new BufferedImage((int)size, (int)size, BufferedImage.TYPE_INT_ARGB);
// Graphics2D graphics = image.createGraphics();
// Color color = new Color(0x00FFFFFF, true);
// graphics.setColor(color);
// graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
// graphics.dispose();
writeToResponse(response, mime, null, image, false);
}
} else if ("crop".equals(action)) {
float x = getParameter(request, "x");
float y = getParameter(request, "y");
float width = getParameter(request, "w");
float height = getParameter(request, "h");
StringBuilder suffix = new StringBuilder();
suffix.append("x").append((int) x).append("y").append((int) y)
.append("+").append((int) width).append("y")
.append((int) height);
File scaled = getFile(dir, file, mime, suffix.toString());
log("thumb = " + scaled.getAbsolutePath());
if (useScaled(file, scaled)) {
streamScaled(scaled, response.getOutputStream());
} else {
PlanarImage image = loadImage(file);
image = crop(image, x, y, width, height);
writeToResponse(response, mime, scaled, image.getAsBufferedImage(), doCache);
}
}
response.flushBuffer();
}