• 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 Changeset
  • Next Changeset →

Changeset 822

Show
Ignore:
Timestamp:
07/25/06 19:17:05 (2 years ago)
Author:
callan
Message:

Merged bug fixes from ticket #255 (r821) into the M2 branch.

Location:
branches/3.0-M2/components/rendering/src/omeis/providers/re/data
Files:
2 modified

  • Plane2D.java (modified) (5 diffs)
  • PlaneFactory.java (modified) (1 diff)

Legend:

Unmodified
Added
Removed
  • branches/3.0-M2/components/rendering/src/omeis/providers/re/data/Plane2D.java

    r734 r822  
    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} 
  • branches/3.0-M2/components/rendering/src/omeis/providers/re/data/PlaneFactory.java

    r734 r822  
    115115                                + type.getValue() + "'"); 
    116116    } 
     117     
     118    /** 
     119     * A static helper method to retrieve pixel byte signage. 
     120     *  
     121     * @param type The pixels type for which you want to know the byte width. 
     122     * @return The number of bytes per pixel value. 
     123     */ 
     124    static boolean isTypeSigned(PixelsType type) 
     125    { 
     126        if (in(type, new String[] {"uint8", "uint16", "uint32"})) 
     127            return false; 
     128        else if (in(type, new String[] { "int8", "int16", "int32", "float", "double"})) 
     129            return true; 
     130        else 
     131            throw new RuntimeException("Unknown pixel type: '" 
     132                    + type.getValue() + "'"); 
     133    } 
     134     
    117135     
    118136    /** 

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/