Search in sources :

Example 11 with TiffCompression

use of loci.formats.tiff.TiffCompression in project bioformats by openmicroscopy.

the class TiffCompressionCompressTest method testJPEG.

@Test
public void testJPEG() throws FormatException, IOException {
    TiffCompression compression = TiffCompression.JPEG;
    ifd.put(IFD.BITS_PER_SAMPLE, new int[] { 8 });
    CodecOptions options = compression.getCompressionCodecOptions(ifd);
    byte[] compressed = compression.compress(data, options);
    assertNotNull(compressed);
}
Also used : CodecOptions(loci.formats.codec.CodecOptions) JPEG2000CodecOptions(loci.formats.codec.JPEG2000CodecOptions) TiffCompression(loci.formats.tiff.TiffCompression) Test(org.testng.annotations.Test)

Example 12 with TiffCompression

use of loci.formats.tiff.TiffCompression in project bioformats by openmicroscopy.

the class TiffCompressionCompressTest method testDEFLATE.

@Test
public void testDEFLATE() throws FormatException, IOException {
    TiffCompression compression = TiffCompression.DEFLATE;
    CodecOptions options = compression.getCompressionCodecOptions(ifd);
    byte[] compressed = compression.compress(data, options);
    assertNotNull(compressed);
}
Also used : CodecOptions(loci.formats.codec.CodecOptions) JPEG2000CodecOptions(loci.formats.codec.JPEG2000CodecOptions) TiffCompression(loci.formats.tiff.TiffCompression) Test(org.testng.annotations.Test)

Example 13 with TiffCompression

use of loci.formats.tiff.TiffCompression in project bioformats by openmicroscopy.

the class TiffCompressionCompressTest method testJPEG_2000_ResetBlockSize.

@Test(enabled = true)
public void testJPEG_2000_ResetBlockSize() throws FormatException, IOException {
    TiffCompression compression = TiffCompression.JPEG_2000;
    JPEG2000CodecOptions opt = JPEG2000CodecOptions.getDefaultOptions();
    int v = 16;
    opt.codeBlockSize = new int[] { v, v };
    CodecOptions options = compression.getCompressionCodecOptions(ifd, opt);
    assertTrue(options instanceof JPEG2000CodecOptions);
    JPEG2000CodecOptions j2k = (JPEG2000CodecOptions) options;
    assertEquals(j2k.codeBlockSize.length, opt.codeBlockSize.length);
    for (int i = 0; i < j2k.codeBlockSize.length; i++) {
        assertEquals(j2k.codeBlockSize[i], opt.codeBlockSize[i]);
    }
    compression = TiffCompression.JPEG_2000_LOSSY;
    options = compression.getCompressionCodecOptions(ifd, opt);
    assertTrue(options instanceof JPEG2000CodecOptions);
    j2k = (JPEG2000CodecOptions) options;
    assertEquals(j2k.codeBlockSize.length, opt.codeBlockSize.length);
    for (int i = 0; i < j2k.codeBlockSize.length; i++) {
        assertEquals(j2k.codeBlockSize[i], opt.codeBlockSize[i]);
    }
    compression = TiffCompression.ALT_JPEG2000;
    options = compression.getCompressionCodecOptions(ifd, opt);
    j2k = (JPEG2000CodecOptions) options;
    assertEquals(j2k.codeBlockSize.length, opt.codeBlockSize.length);
    for (int i = 0; i < j2k.codeBlockSize.length; i++) {
        assertEquals(j2k.codeBlockSize[i], opt.codeBlockSize[i]);
    }
}
Also used : CodecOptions(loci.formats.codec.CodecOptions) JPEG2000CodecOptions(loci.formats.codec.JPEG2000CodecOptions) TiffCompression(loci.formats.tiff.TiffCompression) JPEG2000CodecOptions(loci.formats.codec.JPEG2000CodecOptions) Test(org.testng.annotations.Test)

Example 14 with TiffCompression

use of loci.formats.tiff.TiffCompression in project bioformats by openmicroscopy.

the class TiffCompressionCompressTest method testUNCOMPRESSED.

@Test
public void testUNCOMPRESSED() throws FormatException, IOException {
    TiffCompression compression = TiffCompression.UNCOMPRESSED;
    CodecOptions options = compression.getCompressionCodecOptions(ifd);
    byte[] compressed = compression.compress(data, options);
    assertNotNull(compressed);
    assertEquals(compressed.length, data.length);
}
Also used : CodecOptions(loci.formats.codec.CodecOptions) JPEG2000CodecOptions(loci.formats.codec.JPEG2000CodecOptions) TiffCompression(loci.formats.tiff.TiffCompression) Test(org.testng.annotations.Test)

Example 15 with TiffCompression

use of loci.formats.tiff.TiffCompression in project bioformats by openmicroscopy.

the class TiffCompressionCompressTest method testJPEG_2000.

@Test
public void testJPEG_2000() throws FormatException, IOException {
    TiffCompression compression = TiffCompression.JPEG_2000;
    CodecOptions options = compression.getCompressionCodecOptions(ifd);
    byte[] compressed = compression.compress(data, options);
    assertNotNull(compressed);
}
Also used : CodecOptions(loci.formats.codec.CodecOptions) JPEG2000CodecOptions(loci.formats.codec.JPEG2000CodecOptions) TiffCompression(loci.formats.tiff.TiffCompression) Test(org.testng.annotations.Test)

Aggregations

TiffCompression (loci.formats.tiff.TiffCompression)33 Test (org.testng.annotations.Test)31 CodecOptions (loci.formats.codec.CodecOptions)18 JPEG2000CodecOptions (loci.formats.codec.JPEG2000CodecOptions)18 NikonCodecOptions (loci.formats.codec.NikonCodecOptions)1 IFD (loci.formats.tiff.IFD)1 IFDList (loci.formats.tiff.IFDList)1 PhotoInterp (loci.formats.tiff.PhotoInterp)1 TiffRational (loci.formats.tiff.TiffRational)1