Changeset 7336


Ignore:
Timestamp:
12/06/10 13:56:23 (9 years ago)
Author:
melissa
Message:

Fixed MD5 calculations for planes whose SizeY is odd.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/test-suite/src/loci/tests/testng/OmeroOpenBytesTest.java

    r7314 r7336  
    7575 
    7676  private int planeSize; 
     77 
     78  private int topHalfSize; 
     79 
     80  private int bottomHalfSize; 
    7781 
    7882  @Parameters({"id"}) 
     
    9296    bpp = FormatTools.getBytesPerPixel(reader.getPixelType()); 
    9397    planeSize = sizeX * sizeY * bpp; 
     98    topHalfSize = (sizeY / 2) * sizeX * bpp; 
     99    bottomHalfSize = (sizeY - (sizeY / 2)) * sizeX * bpp; 
    94100  } 
    95101 
     
    154160  public void testOpenBytesHalfPlane() throws Exception { 
    155161    byte[] plane = new byte[planeSize]; 
    156     byte[] halfPlane = new byte[planeSize / 2]; 
     162    byte[] topHalfPlane = new byte[topHalfSize]; 
     163    byte[] bottomHalfPlane = new byte[bottomHalfSize]; 
    157164    String planeDigest, halfPlaneDigest; 
    158165    for (int i = 0; i < imageCount; i++) { 
    159166      // Check the digest for the first half of the plane against a full plane 
    160167      reader.openBytes(i, plane); 
    161       reader.openBytes(i, halfPlane, 0, 0, sizeX, sizeY / 2); 
    162       planeDigest = TestTools.md5(plane, 0, planeSize / 2); 
    163       halfPlaneDigest = TestTools.md5(halfPlane, 0, planeSize / 2); 
     168      reader.openBytes(i, topHalfPlane, 0, 0, sizeX, sizeY / 2); 
     169      planeDigest = TestTools.md5(plane, 0, topHalfSize); 
     170      halfPlaneDigest = TestTools.md5(topHalfPlane, 0, topHalfSize); 
    164171      if (!planeDigest.equals(halfPlaneDigest)) { 
    165172        fail(String.format("First half MD5:%d %s != %s", 
     
    167174      } 
    168175      // Check the digest for the second half of the plane against a full plane 
    169       reader.openBytes(i, halfPlane, 0, sizeY / 2, sizeX, sizeY / 2); 
    170       planeDigest = TestTools.md5(plane, planeSize / 2, planeSize / 2); 
    171       halfPlaneDigest = TestTools.md5(halfPlane, 0, planeSize / 2); 
     176      reader.openBytes(i, bottomHalfPlane, 0, sizeY / 2, sizeX, 
     177        sizeY - (sizeY / 2)); 
     178      planeDigest = TestTools.md5(plane, topHalfSize, bottomHalfSize); 
     179      halfPlaneDigest = TestTools.md5(bottomHalfPlane, 0, bottomHalfSize); 
    172180      if (!planeDigest.equals(halfPlaneDigest)) { 
    173181        fail(String.format("Second half MD5:%d %s != %s", 
Note: See TracChangeset for help on using the changeset viewer.