Mercurial > hg > digilib-old
comparison servlet/src/digilib/servlet/Scaler.java @ 94:d9bfec4f046e
New version 1.8b4.
Uses new DocuFileset classes.
author | robcast |
---|---|
date | Mon, 17 Mar 2003 16:06:42 +0100 |
parents | 997ba69afb81 |
children | cc6a0b9ac78e |
comparison
equal
deleted
inserted
replaced
93:a2d5ea76350b | 94:d9bfec4f046e |
---|---|
54 */ | 54 */ |
55 //public class Scaler extends HttpServlet implements SingleThreadModel { | 55 //public class Scaler extends HttpServlet implements SingleThreadModel { |
56 public class Scaler extends HttpServlet { | 56 public class Scaler extends HttpServlet { |
57 | 57 |
58 // digilib servlet version (for all components) | 58 // digilib servlet version (for all components) |
59 public static final String dlVersion = "1.8b1"; | 59 public static final String dlVersion = "1.8b4"; |
60 | 60 |
61 // Utils instance with debuglevel | 61 // Utils instance with debuglevel |
62 Utils util; | 62 Utils util; |
63 // FileOps instance | 63 // FileOps instance |
64 FileOps fileOp; | 64 FileOps fileOp; |
67 // ServletOps instance | 67 // ServletOps instance |
68 ServletOps servletOp; | 68 ServletOps servletOp; |
69 // DocuDirCache instance | 69 // DocuDirCache instance |
70 DocuDirCache dirCache; | 70 DocuDirCache dirCache; |
71 | 71 |
72 // DigilibParameters instance | 72 // DigilibConfiguration instance |
73 DigilibConfiguration dlConfig; | 73 DigilibConfiguration dlConfig; |
74 | 74 |
75 // use authorization database | 75 // use authorization database |
76 boolean useAuthentication = true; | 76 boolean useAuthentication = true; |
77 | 77 |
274 * find the file to load/send | 274 * find the file to load/send |
275 */ | 275 */ |
276 | 276 |
277 // get PathInfo | 277 // get PathInfo |
278 String loadPathName = dlRequest.getFilePath(); | 278 String loadPathName = dlRequest.getFilePath(); |
279 // if it's zoomed, try hires version (to be optimized...) | |
280 if ((paramWW < 1f) || (paramWH < 1f)) { | |
281 preScaledFirst = false; | |
282 } | |
283 | 279 |
284 /* | 280 /* |
285 * check permissions | 281 * check permissions |
286 */ | 282 */ |
287 if (useAuthentication) { | 283 if (useAuthentication) { |
306 return; | 302 return; |
307 } | 303 } |
308 } | 304 } |
309 } | 305 } |
310 | 306 |
307 // if it's zoomed, try hires version (to be optimized...) | |
308 if ((paramWW < 1f) || (paramWH < 1f)) { | |
309 preScaledFirst = false; | |
310 } | |
311 | |
311 // find the file | 312 // find the file |
312 DocuFile fileToLoad; | 313 DocuFile fileToLoad; |
313 DocuFileset fileset = dirCache.getFileset(loadPathName, dlRequest.getPn()); | 314 DocuFileset fileset = |
315 dirCache.getFileset(loadPathName, dlRequest.getPn()); | |
316 if (fileset == null) { | |
317 throw new FileOpException( | |
318 "File " | |
319 + loadPathName | |
320 + "(" | |
321 + dlRequest.getPn() | |
322 + ") not found."); | |
323 } | |
324 | |
314 // simplistic selection of resolution | 325 // simplistic selection of resolution |
315 if (preScaledFirst) { | 326 if (preScaledFirst) { |
316 fileToLoad = (DocuFile)fileset.lastElement(); | 327 // get last element |
328 fileToLoad = fileset.get(fileset.size() - 1); | |
317 } else { | 329 } else { |
318 fileToLoad = (DocuFile)fileset.firstElement(); | 330 // get first element |
331 fileToLoad = fileset.get(0); | |
319 } | 332 } |
320 util.dprintln(1, "Loading: " + fileToLoad.getFile()); | 333 util.dprintln(1, "Loading: " + fileToLoad.getFile()); |
321 | 334 |
322 // check the source image | 335 // check the source image |
323 docuImage.checkFile(fileToLoad); | 336 docuImage.checkFile(fileToLoad); |
360 fileToLoad.setSize(new Dimension(imgWidth, imgHeight)); | 373 fileToLoad.setSize(new Dimension(imgWidth, imgHeight)); |
361 } else { | 374 } else { |
362 imgWidth = fileToLoad.getSize().width; | 375 imgWidth = fileToLoad.getSize().width; |
363 imgHeight = fileToLoad.getSize().height; | 376 imgHeight = fileToLoad.getSize().height; |
364 } | 377 } |
365 | 378 |
366 util.dprintln(2, "IMG: " + imgWidth + "x" + imgHeight); | 379 util.dprintln(2, "IMG: " + imgWidth + "x" + imgHeight); |
367 util.dprintln( | 380 util.dprintln( |
368 2, | 381 2, |
369 "time " + (System.currentTimeMillis() - startTime) + "ms"); | 382 "time " + (System.currentTimeMillis() - startTime) + "ms"); |
370 | 383 |
568 docuImage.mirror(mirrorAngle); | 581 docuImage.mirror(mirrorAngle); |
569 } | 582 } |
570 | 583 |
571 // rotate image (first shot :-) | 584 // rotate image (first shot :-) |
572 if (paramROT != 0) { | 585 if (paramROT != 0) { |
573 docuImage.rotate( | 586 docuImage.rotate(paramROT); |
574 paramROT); | |
575 } | 587 } |
576 | 588 |
577 // contrast and brightness enhancement | 589 // contrast and brightness enhancement |
578 if ((paramCONT != 0) || (paramBRGT != 0)) { | 590 if ((paramCONT != 0) || (paramBRGT != 0)) { |
579 double mult = Math.pow(2, paramCONT); | 591 double mult = Math.pow(2, paramCONT); |
580 docuImage.enhance((float)mult, (float)paramBRGT); | 592 docuImage.enhance((float) mult, (float) paramBRGT); |
581 } | 593 } |
582 | 594 |
583 // color modification | 595 // color modification |
584 if ((paramRGBM != null) || (paramRGBA != null)) { | 596 if ((paramRGBM != null) || (paramRGBA != null)) { |
585 // make shure we actually have two arrays | 597 // make shure we actually have two arrays |
590 paramRGBA = new float[3]; | 602 paramRGBA = new float[3]; |
591 } | 603 } |
592 // calculate "contrast" values | 604 // calculate "contrast" values |
593 float[] mult = new float[3]; | 605 float[] mult = new float[3]; |
594 for (int i = 0; i < 3; i++) { | 606 for (int i = 0; i < 3; i++) { |
595 mult[i] = (float)Math.pow(2, (double)paramRGBM[i]); | 607 mult[i] = (float) Math.pow(2, (double) paramRGBM[i]); |
596 } | 608 } |
597 docuImage.enhanceRGB(mult, paramRGBA); | 609 docuImage.enhanceRGB(mult, paramRGBA); |
598 } | 610 } |
599 | 611 |
600 util.dprintln( | 612 util.dprintln( |
601 2, | 613 2, |
602 "time " + (System.currentTimeMillis() - startTime) + "ms"); | 614 "time " + (System.currentTimeMillis() - startTime) + "ms"); |
603 | 615 |
604 /* | 616 /* |