cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/generation ImageDirectoryGenerator.java
Date Thu, 10 May 2001 14:49:31 GMT
bloritsch    01/05/10 07:49:31

  Modified:    src/org/apache/cocoon/generation
                        ImageDirectoryGenerator.java
  Log:
  Fix and optimize math for Image dimension calculations.  The current implementation
  incorrectly assumes that the "byte" type is unsigned.  We will no longer have negative
  dimensions.  Not to mention the bit manipulations are quicker than the plain math
  counterparts.
  
  Revision  Changes    Path
  1.2       +7 -7      xml-cocoon2/src/org/apache/cocoon/generation/ImageDirectoryGenerator.java
  
  Index: ImageDirectoryGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/generation/ImageDirectoryGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ImageDirectoryGenerator.java	2001/05/09 20:49:41	1.1
  +++ ImageDirectoryGenerator.java	2001/05/10 14:49:27	1.2
  @@ -23,7 +23,7 @@
    * files.
    *
    * @author <a href="mailto:balld@webslingerZ.com">Donald A. Ball Jr.</a>
  - * @version $Revision: 1.1 $ $Date: 2001/05/09 20:49:41 $
  + * @version $Revision: 1.2 $ $Date: 2001/05/10 14:49:27 $
    */
   public class ImageDirectoryGenerator extends DirectoryGenerator {
   
  @@ -135,13 +135,13 @@
               || (buf[2]) != 'F' )
               throw new RuntimeException("Not a valid GIF file!");
   
  -            int w1 = (int)buf[6];
  -            int w2 = (int)buf[7];
  -            int h1 = (int)buf[8];
  -            int h2 = (int)buf[9];
  +            int w1 = ((int)this.imageHeader[6] & 0xff) | ((this.imageHeader[6] <
0) ? 0x80 : 0x00);
  +            int w2 = ((int)this.imageHeader[7] & 0xff) | ((this.imageHeader[7] <
0) ? 0x80 : 0x00);
  +            int h1 = ((int)this.imageHeader[8] & 0xff) | ((this.imageHeader[8] <
0) ? 0x80 : 0x00);
  +            int h2 = ((int)this.imageHeader[9] & 0xff) | ((this.imageHeader[9] <
0) ? 0x80 : 0x00);
   
  -            int width = w1 + (256 * w2);
  -            int height = h1 + (256 * h2);
  +            width = w1 + (w2 << 8);
  +            height = h1 + (h2 << 8);
   
               int[] dim = { width, height };
               return dim;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message