• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Change
  • Next Change →

Changeset 821 for trunk/components/rendering/src/omeis/providers/re/data/Plane2D.java

Show
Ignore:
Timestamp:
07/25/06 14:44:49 (2 years ago)
Author:
brain
Message:

Added functionality to check for signed types in the pixel data to fix a bug with large global min/max ranges.

Files:
1 modified

  • trunk/components/rendering/src/omeis/providers/re/data/Plane2D.java (modified) (5 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/components/rendering/src/omeis/providers/re/data/Plane2D.java

    r734 r821  
    3333 
    3434//Third-party libraries 
     35import java.nio.ByteBuffer; 
    3536import java.nio.ByteOrder; 
    3637import java.nio.MappedByteBuffer; 
    … …  
    9899    /** The Java type that we're using for pixel value retrieval */ 
    99100    protected int          javaType; 
     101     
     102    /** The sign of the type **/ 
     103    protected boolean      signed; 
    100104         
    101105 
    … …  
    124128        this.bytesPerPixel = PlaneFactory.bytesPerPixel(type); 
    125129        this.javaType = PlaneFactory.javaType(type); 
     130        this.signed = PlaneFactory.isTypeSigned(type); 
    126131         
    127132        log.info("Created Plane2D with dimensions " + sizeX + "x" + sizeY + "x" 
    … …  
    140145     * @return The offset. 
    141146     */ 
    142         protected abstract int calculateOffset(int x1, int x2); 
     147         protected abstract int calculateOffset(int x1, int x2); 
    143148 
    144149    /** 
    … …  
    157162                int offset = calculateOffset(x1, x2); 
    158163 
    159                 switch(javaType) 
     164                if (signed) 
    160165                { 
    161                         case PlaneFactory.BYTE: 
    162                                 return data.get(offset); 
    163                         case PlaneFactory.SHORT: 
    164                                 return data.getShort(offset); 
    165                         case PlaneFactory.INT: 
    166                                 return data.getInt(offset); 
    167                         case PlaneFactory.FLOAT: 
    168                                 return data.getFloat(offset); 
    169                         case PlaneFactory.DOUBLE: 
    170                                 return data.getDouble(offset); 
    171                 } 
     166                    switch(javaType) 
     167                    { 
     168                        case PlaneFactory.BYTE: 
     169                            return data.get(offset); 
     170                        case PlaneFactory.SHORT: 
     171                            return data.getShort(offset); 
     172                        case PlaneFactory.INT: 
     173                            return data.getInt(offset); 
     174                        case PlaneFactory.FLOAT: 
     175                            return data.getFloat(offset); 
     176                        case PlaneFactory.DOUBLE: 
     177                            return data.getDouble(offset); 
     178                    } 
     179                } else 
     180        { 
     181            switch(javaType) 
     182            { 
     183                case PlaneFactory.BYTE: 
     184                    return (short) (data.get(offset) & 0xff); 
     185                case PlaneFactory.SHORT: 
     186                    return (int) (data.getShort(offset) & 0xffff); 
     187                case PlaneFactory.INT: 
     188                    return (long) (data.getInt(offset) & 0xffffffffL); 
     189            }             
     190        }        
    172191                throw new RuntimeException("Unknown pixel type."); 
    173192        } 
    174          
    175193} 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/