Search in sources :

Example 6 with WlzException

use of uk.ac.mrc.hgu.Wlz.WlzException in project bioformats by openmicroscopy.

the class WlzServiceImpl method setupWrite.

@Override
public void setupWrite(int orgX, int orgY, int orgZ, int pixSzX, int pixSzY, int pixSzZ, int pixSzC, int pixSzT, double voxSzX, double voxSzY, double voxSzZ, int gType) throws FormatException {
    bBox = new WlzIBox3();
    bBox.xMin = orgX;
    bBox.yMin = orgY;
    bBox.zMin = orgZ;
    bBox.xMax = orgX + pixSzX - 1;
    bBox.yMax = orgY + pixSzY - 1;
    bBox.zMax = orgZ + pixSzZ - 1;
    voxSz = new WlzDVertex3(voxSzX, voxSzY, voxSzZ);
    if ((bBox.xMax < bBox.xMin) || (bBox.yMax < bBox.yMin) || (bBox.zMax < bBox.zMin) || (pixSzC <= 0) || (pixSzT <= 0)) {
        throw new FormatException("Invalid image size (" + (bBox.xMax - bBox.xMin + 1) + ", " + (bBox.yMax - bBox.yMin + 1) + ", " + (bBox.zMax - bBox.zMin + 1) + ", " + pixSzC + ", " + pixSzT + ")");
    }
    switch(gType) {
        case FormatTools.UINT8:
            objGType = WlzGreyType.WLZ_GREY_UBYTE;
            break;
        case FormatTools.INT16:
            objGType = WlzGreyType.WLZ_GREY_SHORT;
            break;
        case FormatTools.INT32:
            objGType = WlzGreyType.WLZ_GREY_INT;
            break;
        case FormatTools.FLOAT:
            objGType = WlzGreyType.WLZ_GREY_FLOAT;
            break;
        case FormatTools.DOUBLE:
            objGType = WlzGreyType.WLZ_GREY_DOUBLE;
            break;
        default:
            throw new FormatException("Invalid image value type");
    }
    if (bBox.zMax == bBox.zMin) {
        objType = WlzObjectType.WLZ_2D_DOMAINOBJ;
    } else {
        objType = WlzObjectType.WLZ_3D_DOMAINOBJ;
    }
    try {
        wlzObj = WlzObject.WlzMakeEmpty();
    } catch (WlzException e) {
        throw new FormatException("Failed to create Woolz object", e);
    }
}
Also used : WlzIBox3(uk.ac.mrc.hgu.Wlz.WlzIBox3) WlzException(uk.ac.mrc.hgu.Wlz.WlzException) FormatException(loci.formats.FormatException) WlzDVertex3(uk.ac.mrc.hgu.Wlz.WlzDVertex3)

Aggregations

WlzException (uk.ac.mrc.hgu.Wlz.WlzException)6 FormatException (loci.formats.FormatException)3 IOException (java.io.IOException)2 WlzDVertex3 (uk.ac.mrc.hgu.Wlz.WlzDVertex3)2 WlzIVertex2 (uk.ac.mrc.hgu.Wlz.WlzIVertex2)2 WlzIVertex3 (uk.ac.mrc.hgu.Wlz.WlzIVertex3)2 WlzFileInputStream (uk.ac.mrc.hgu.Wlz.WlzFileInputStream)1 WlzIBox3 (uk.ac.mrc.hgu.Wlz.WlzIBox3)1 WlzObject (uk.ac.mrc.hgu.Wlz.WlzObject)1