Search in sources :

Example 6 with CodecOptions

use of loci.formats.codec.CodecOptions in project bioformats by openmicroscopy.

the class TiffCompressionCompressTest method testLZW.

@Test
public void testLZW() throws FormatException, IOException {
    TiffCompression compression = TiffCompression.LZW;
    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 7 with CodecOptions

use of loci.formats.codec.CodecOptions 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 8 with CodecOptions

use of loci.formats.codec.CodecOptions 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 9 with CodecOptions

use of loci.formats.codec.CodecOptions 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 10 with CodecOptions

use of loci.formats.codec.CodecOptions 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)

Aggregations

CodecOptions (loci.formats.codec.CodecOptions)37 JPEG2000CodecOptions (loci.formats.codec.JPEG2000CodecOptions)18 TiffCompression (loci.formats.tiff.TiffCompression)18 Test (org.testng.annotations.Test)18 RandomAccessInputStream (loci.common.RandomAccessInputStream)9 JPEGCodec (loci.formats.codec.JPEGCodec)8 PackbitsCodec (loci.formats.codec.PackbitsCodec)6 ByteArrayHandle (loci.common.ByteArrayHandle)5 ZlibCodec (loci.formats.codec.ZlibCodec)5 UnsupportedCompressionException (loci.formats.UnsupportedCompressionException)4 JPEG2000Codec (loci.formats.codec.JPEG2000Codec)4 IOException (java.io.IOException)3 CoreMetadata (loci.formats.CoreMetadata)3 Codec (loci.formats.codec.Codec)3 FormatException (loci.formats.FormatException)2 IFormatReader (loci.formats.IFormatReader)2 MetadataStore (loci.formats.meta.MetadataStore)2 Length (ome.units.quantity.Length)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1