upayavira    2003/07/03 02:43:25

  Modified:    src/documentation/xdocs/userdocs/readers book.xml
                        image-reader.xml
               src/java/org/apache/cocoon/reading ImageReader.java
  Log:
  Added parameter to image reader to allow the prevention of image enlarging 
(whilst still allowing image size reduction)
  Updated docs to include this change
  Moved image reader from scratchpad to core in book.xml
  
  Revision  Changes    Path
  1.2       +1 -1      
cocoon-2.1/src/documentation/xdocs/userdocs/readers/book.xml
  
  Index: book.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/readers/book.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- book.xml  9 Mar 2003 00:08:22 -0000       1.1
  +++ book.xml  3 Jul 2003 09:43:25 -0000       1.2
  @@ -12,6 +12,7 @@
       <menu-item label="Resource Reader" href="resource-reader.html"/>
     </menu>
     <menu label="Core">
  +    <menu-item label="Image Reader" href="image-reader.html"/>
     </menu>
     <menu label="Optional">
       <menu-item label="Database Reader" href="database-reader.html"/>
  @@ -21,7 +22,6 @@
       <menu-item label="AxisRPC Reader" href="axisrpc-reader.html"/>
       <menu-item label="Byte Range Resource Reader" 
href="byterangeresource-reader.html"/>
       <menu-item label="Directory ZIP Archiver" 
href="directoryziparchiver-reader.html"/>
  -    <menu-item label="Image Reader" href="image-reader.html"/>
     </menu>
   </book>
   
  
  
  
  1.2       +16 -2     
cocoon-2.1/src/documentation/xdocs/userdocs/readers/image-reader.xml
  
  Index: image-reader.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/readers/image-reader.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- image-reader.xml  9 Mar 2003 00:08:22 -0000       1.1
  +++ image-reader.xml  3 Jul 2003 09:43:25 -0000       1.2
  @@ -8,6 +8,7 @@
       <type>Technical document</type>
       <authors>
         <person name="Bernhard Huber" email="[EMAIL PROTECTED]"/>
  +      <person name="Upayavira" email="[EMAIL PROTECTED]"/>      
       </authors>
       <abstract>This document describes the ImageReader of Cocoon.</abstract>
     </header>
  @@ -112,7 +113,7 @@
               <td>
                 This parameter is optional. When specified it determines the 
width
                 of the binary image.
  -              If no height parameter is specified the ascpect ratio
  +              If no height parameter is specified the aspect ratio
                 of the image is kept.
               </td>
             </tr>
  @@ -120,10 +121,21 @@
               <td>
                 This parameter is optional. When specified it determines the 
width
                 of the binary image.
  -              If no width parameter is specified the ascpect ratio
  +              If no width parameter is specified the aspect ratio
                 of the image is kept.
               </td>
             </tr>
  +          <tr><td>allow-enlarging</td><td>Allow or prevent the enlarging of 
images</td>
  +            <td>
  +              This parameter is optional. The <code>width</code> and 
<code>height</code> parameters allow an image 
  +              to be resized. By default, if the image is smaller than the 
specified 
  +              width and height, the image will be enlarged. In some 
circumstances, this
  +              behaviour is undesirable, and can be switched off by setting 
this parameter
  +              to <code>no</code>. With this parameter set to 
<code>no</code>, images will 
  +              be reduced in size, but not enlarged. The default for this 
parameter is 
  +              <code>yes</code>.
  +            </td>
  +          </tr>
           </table>
           <p>
             The following pipeline snippet
  @@ -170,6 +182,8 @@
           <br/>
           01-06-03: Renamed the expire-time -> expires parameter,
                     Fixed the statement about the byte range support, Torsten 
Curdt
  +        <br/>
  +        03-07-03: Added allow-enlarging parameter, Upayavira
         </p>
       </s1>
       <s1 title="Copyright">
  
  
  
  1.2       +20 -1     
cocoon-2.1/src/java/org/apache/cocoon/reading/ImageReader.java
  
  Index: ImageReader.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/reading/ImageReader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ImageReader.java  27 Jun 2003 20:10:43 -0000      1.1
  +++ ImageReader.java  3 Jul 2003 09:43:25 -0000       1.2
  @@ -98,6 +98,8 @@
   
       private int width;
       private int height;
  +    private boolean enlarge;
  +    private final static String ENLARGE_DEFAULT = "true";
   
       public void setup(SourceResolver resolver, Map objectModel, String src, 
Parameters par)
               throws ProcessingException, SAXException, IOException {
  @@ -106,6 +108,13 @@
   
           width = par.getParameterAsInteger("width", 0);
           height = par.getParameterAsInteger("height", 0);
  +
  +        String enlargePar = par.getParameter("allow-enlarging", 
ENLARGE_DEFAULT);
  +        if ("true".equalsIgnoreCase(enlargePar) || 
"yes".equalsIgnoreCase(enlargePar)){
  +            enlarge = true;
  +        } else {
  +            enlarge = false;
  +        }
       }
   
       /** 
  @@ -137,9 +146,19 @@
               }
           }
   
  +        if (!enlarge) {
  +            if ((nw > ow && nh <= 0) || (oh > nh && nw <=0)) {
  +                wm = 1.0d;
  +                hm = 1.0d;
  +            } else if (nw > ow) {
  +                wm = 1.0d;
  +            } else if (nh > oh) {
  +                hm = 1.0d;
  +            }
  +        }
           return new AffineTransform(wm, 0.0d, 0.0d, hm, 0.0d, 0.0d);
       }
  -    
  +
       protected void processStream() throws IOException, ProcessingException {
           if (width > 0 || height > 0) {
               if (getLogger().isDebugEnabled()) {
  
  
  

Reply via email to