Search in sources :

Example 11 with OMEXMLService

use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.

the class WriterUtilities method createMetadata.

public static IMetadata createMetadata() throws DependencyException, ServiceException {
    ServiceFactory sf = new ServiceFactory();
    OMEXMLService service = sf.getInstance(OMEXMLService.class);
    IMetadata metadata = service.createOMEXMLMetadata();
    metadata.setPixelsDimensionOrder(DimensionOrder.XYZCT, 0);
    metadata.setPixelsSizeX(new PositiveInteger(SIZE_X), 0);
    metadata.setPixelsSizeY(new PositiveInteger(SIZE_Y), 0);
    metadata.setPixelsSizeT(new PositiveInteger(SIZE_T), 0);
    metadata.setPixelsSizeZ(new PositiveInteger(SIZE_Z), 0);
    metadata.setPixelsSizeC(new PositiveInteger(SIZE_C), 0);
    metadata.setPixelsType(PixelType.UINT8, 0);
    metadata.setPixelsBinDataBigEndian(true, 0, 0);
    metadata.setImageID("Image:1", 0);
    metadata.setPixelsID("Pixels:1", 0);
    metadata.setChannelID("Channel:1", 0, 0);
    metadata.setChannelSamplesPerPixel(new PositiveInteger(1), 0, 0);
    return metadata;
}
Also used : PositiveInteger(ome.xml.model.primitives.PositiveInteger) IMetadata(loci.formats.meta.IMetadata) ServiceFactory(loci.common.services.ServiceFactory) OMEXMLService(loci.formats.services.OMEXMLService)

Example 12 with OMEXMLService

use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.

the class LosslessJPEG2000Test method setUp.

@BeforeMethod
public void setUp() throws Exception {
    File temp8 = File.createTempFile("test", ".jp2");
    File temp16 = File.createTempFile("test", ".jp2");
    temp8.deleteOnExit();
    temp16.deleteOnExit();
    Location.mapId(FILE_8, temp8.getAbsolutePath());
    Location.mapId(FILE_16, temp16.getAbsolutePath());
    IMetadata metadata8;
    try {
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        metadata8 = service.createOMEXMLMetadata();
    } catch (DependencyException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    } catch (ServiceException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    }
    MetadataTools.populateMetadata(metadata8, 0, "foo", false, "XYCZT", "uint8", 1, 1, 1, 1, 1, 1);
    IFormatWriter writer8 = new JPEG2000Writer();
    writer8.setMetadataRetrieve(metadata8);
    writer8.setId(FILE_8);
    writer8.saveBytes(0, PIXELS_8);
    writer8.close();
    IMetadata metadata16;
    try {
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        metadata16 = service.createOMEXMLMetadata();
    } catch (DependencyException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    } catch (ServiceException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    }
    MetadataTools.populateMetadata(metadata16, 0, "foo", false, "XYCZT", "uint16", 1, 1, 1, 1, 1, 1);
    IFormatWriter writer16 = new JPEG2000Writer();
    writer16.setMetadataRetrieve(metadata16);
    writer16.setId(FILE_16);
    writer16.saveBytes(0, PIXELS_16);
    writer16.close();
}
Also used : IFormatWriter(loci.formats.IFormatWriter) JPEG2000Writer(loci.formats.out.JPEG2000Writer) IMetadata(loci.formats.meta.IMetadata) ServiceException(loci.common.services.ServiceException) ServiceFactory(loci.common.services.ServiceFactory) DependencyException(loci.common.services.DependencyException) File(java.io.File) OMEXMLService(loci.formats.services.OMEXMLService) FormatException(loci.formats.FormatException) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 13 with OMEXMLService

use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.

the class MissingOMEXMLServiceTest method testInstantiate.

@Test(expectedExceptions = { DependencyException.class })
public void testInstantiate() throws DependencyException {
    OMEXMLService service = sf.getInstance(OMEXMLService.class);
    assertNotNull(service);
}
Also used : OMEXMLService(loci.formats.services.OMEXMLService) Test(org.testng.annotations.Test)

Example 14 with OMEXMLService

use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.

the class OMETiffWriterLargeImageWidthTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    target = File.createTempFile("OMETiffWriterTest", ".ome.tiff");
    ServiceFactory sf = new ServiceFactory();
    OMEXMLService service = sf.getInstance(OMEXMLService.class);
    ms = service.createOMEXMLMetadata();
    ms.setImageID("Image:1", 0);
    ms.setPixelsID("Pixels:1", 0);
    ms.setPixelsDimensionOrder(DimensionOrder.XYZCT, 0);
    ms.setPixelsSizeX(new PositiveInteger(SIZE_X), 0);
    ms.setPixelsSizeY(new PositiveInteger(SIZE_Y), 0);
    ms.setPixelsSizeZ(new PositiveInteger(SIZE_Z), 0);
    ms.setPixelsSizeC(new PositiveInteger(SIZE_C), 0);
    ms.setPixelsSizeT(new PositiveInteger(SIZE_T), 0);
    ms.setPixelsType(PixelType.UINT8, 0);
    ms.setPixelsBinDataBigEndian(true, 0, 0);
    ms.setChannelID("Channel:1", 0, 0);
    ms.setChannelSamplesPerPixel(new PositiveInteger(1), 0, 0);
}
Also used : PositiveInteger(ome.xml.model.primitives.PositiveInteger) ServiceFactory(loci.common.services.ServiceFactory) OMEXMLService(loci.formats.services.OMEXMLService) BeforeClass(org.testng.annotations.BeforeClass)

Example 15 with OMEXMLService

use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.

the class OMETiffWriterBigTiffLargeImageWidthTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    target = File.createTempFile("OMETiffWriterTest", ".ome.tiff");
    ServiceFactory sf = new ServiceFactory();
    OMEXMLService service = sf.getInstance(OMEXMLService.class);
    ms = service.createOMEXMLMetadata();
    ms.setImageID("Image:1", 0);
    ms.setPixelsID("Pixels:1", 0);
    ms.setPixelsDimensionOrder(DimensionOrder.XYZCT, 0);
    ms.setPixelsSizeX(new PositiveInteger(SIZE_X), 0);
    ms.setPixelsSizeY(new PositiveInteger(SIZE_Y), 0);
    ms.setPixelsSizeZ(new PositiveInteger(SIZE_Z), 0);
    ms.setPixelsSizeC(new PositiveInteger(SIZE_C), 0);
    ms.setPixelsSizeT(new PositiveInteger(SIZE_T), 0);
    ms.setPixelsType(PixelType.UINT8, 0);
    ms.setPixelsBinDataBigEndian(true, 0, 0);
    ms.setChannelID("Channel:1", 0, 0);
    ms.setChannelSamplesPerPixel(new PositiveInteger(1), 0, 0);
}
Also used : PositiveInteger(ome.xml.model.primitives.PositiveInteger) ServiceFactory(loci.common.services.ServiceFactory) OMEXMLService(loci.formats.services.OMEXMLService) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

OMEXMLService (loci.formats.services.OMEXMLService)59 ServiceFactory (loci.common.services.ServiceFactory)57 IMetadata (loci.formats.meta.IMetadata)35 DependencyException (loci.common.services.DependencyException)28 ServiceException (loci.common.services.ServiceException)26 FormatException (loci.formats.FormatException)23 ImageReader (loci.formats.ImageReader)21 PositiveInteger (ome.xml.model.primitives.PositiveInteger)12 IOException (java.io.IOException)11 MetadataStore (loci.formats.meta.MetadataStore)7 File (java.io.File)6 Location (loci.common.Location)6 ImageWriter (loci.formats.ImageWriter)6 OMEXMLMetadata (loci.formats.ome.OMEXMLMetadata)6 Length (ome.units.quantity.Length)6 BeforeClass (org.testng.annotations.BeforeClass)6 IFormatWriter (loci.formats.IFormatWriter)5 MissingLibraryException (loci.formats.MissingLibraryException)5 OMETiffWriter (loci.formats.out.OMETiffWriter)5 ArrayList (java.util.ArrayList)4