comparison servlet/src/digilib/image/ImageLoaderDocuImage.java @ 469:11e11fe4d680

Improved performance of JAIDocuImage for large images - simulated subsampling by scaling
author robcast
date Wed, 15 Feb 2006 00:09:50 +0100
parents f1f710ff14ad
children 1760b19df530
comparison
equal deleted inserted replaced
468:0fc853d98820 469:11e11fe4d680
276 } 276 }
277 ImageWriteParam param = writer.getDefaultWriteParam(); 277 ImageWriteParam param = writer.getDefaultWriteParam();
278 if (quality > 1) { 278 if (quality > 1) {
279 // change JPEG compression quality 279 // change JPEG compression quality
280 param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); 280 param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
281 logger.debug("JPEG qual before: " 281 //logger.debug("JPEG qual before: "
282 + Float.toString(param.getCompressionQuality())); 282 // + Float.toString(param.getCompressionQuality()));
283 param.setCompressionQuality(0.9f); 283 param.setCompressionQuality(0.9f);
284 logger.debug("JPEG qual now: " 284 //logger.debug("JPEG qual now: "
285 + Float.toString(param.getCompressionQuality())); 285 // + Float.toString(param.getCompressionQuality()));
286 } 286 }
287 writer.setOutput(imgout); 287 writer.setOutput(imgout);
288 // render output 288 // render output
289 logger.debug("writing"); 289 logger.debug("writing");
290 writer.write(null, new IIOImage(img, null, null), param); 290 writer.write(null, new IIOImage(img, null, null), param);
333 scaledImg = new BufferedImage((int) dstBounds.getWidth(), 333 scaledImg = new BufferedImage((int) dstBounds.getWidth(),
334 (int) dstBounds.getHeight(), type); 334 (int) dstBounds.getHeight(), type);
335 } 335 }
336 logger.debug("scaling..."); 336 logger.debug("scaling...");
337 scaledImg = scaleOp.filter(img, scaledImg); 337 scaledImg = scaleOp.filter(img, scaledImg);
338 logger.debug("destination image type " + scaledImg.getType());
339 if (scaledImg == null) { 338 if (scaledImg == null) {
340 throw new ImageOpException("Unable to scale"); 339 throw new ImageOpException("Unable to scale");
341 } 340 }
342 // DEBUG 341 // DEBUG
342 logger.debug("destination image type " + scaledImg.getType());
343 logger.debug("SCALE: " + scale + " ->" + scaledImg.getWidth() + "x" 343 logger.debug("SCALE: " + scale + " ->" + scaledImg.getWidth() + "x"
344 + scaledImg.getHeight()); 344 + scaledImg.getHeight());
345 img = scaledImg; 345 img = scaledImg;
346 scaledImg = null; 346 scaledImg = null;
347 } 347 }
378 378
379 public void crop(int x_off, int y_off, int width, int height) 379 public void crop(int x_off, int y_off, int width, int height)
380 throws ImageOpException { 380 throws ImageOpException {
381 // setup Crop 381 // setup Crop
382 BufferedImage croppedImg = img.getSubimage(x_off, y_off, width, height); 382 BufferedImage croppedImg = img.getSubimage(x_off, y_off, width, height);
383 logger.debug("CROP:" + croppedImg.getWidth() + "x"
384 + croppedImg.getHeight());
385 // DEBUG 383 // DEBUG
386 // util.dprintln(2, " time 384 // util.dprintln(2, " time
387 // "+(System.currentTimeMillis()-startTime)+"ms"); 385 // "+(System.currentTimeMillis()-startTime)+"ms");
388 if (croppedImg == null) { 386 if (croppedImg == null) {
389 throw new ImageOpException("Unable to crop"); 387 throw new ImageOpException("Unable to crop");
390 } 388 }
389 logger.debug("CROP:" + croppedImg.getWidth() + "x"
390 + croppedImg.getHeight());
391 img = croppedImg; 391 img = croppedImg;
392 } 392 }
393 393
394 public void enhance(float mult, float add) throws ImageOpException { 394 public void enhance(float mult, float add) throws ImageOpException {
395 /* 395 /*