use of uk.ac.mrc.hgu.Wlz.WlzIVertex3 in project bioformats by openmicroscopy.
the class WlzServiceImpl method saveBytes.
@Override
public void saveBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException {
if (state == WLZ_SERVICE_WRITE) {
WlzIVertex3 og = new WlzIVertex3(x + bBox.xMin, y + bBox.yMin, no + bBox.zMin);
WlzIVertex2 sz = new WlzIVertex2(w, h);
try {
wlzObj = WlzObject.WlzBuildObj3B(wlzObj, og, sz, objGType, buf.length, buf);
} catch (WlzException e) {
throw new FormatException("Failed save bytes to Woolz object", e);
}
}
}
use of uk.ac.mrc.hgu.Wlz.WlzIVertex3 in project bioformats by openmicroscopy.
the class WlzServiceImpl method readBytes3DDomObj.
private byte[] readBytes3DDomObj(byte[] buf, int x, int y, int z, int w, int h) throws WlzException {
WlzIVertex3 og = new WlzIVertex3(x + bBox.xMin, y + bBox.yMin, z + bBox.zMin);
WlzIVertex3 sz = new WlzIVertex3(w, h, 1);
WlzIVertex3[] dstSz = new WlzIVertex3[1];
dstSz[0] = null;
switch(objGType) {
case WlzGreyType.WLZ_GREY_UBYTE:
{
byte[][][][] dstDat = new byte[1][][][];
WlzObject.WlzToUArray3D(dstSz, dstDat, wlzObj, og, sz, 0);
for (int idY = 0; idY < h; ++idY) {
int idYW = idY * w;
for (int idX = 0; idX < w; ++idX) {
buf[idYW + idX] = dstDat[0][0][idY][idX];
}
}
}
break;
case WlzGreyType.WLZ_GREY_SHORT:
{
short m = 0xff;
short[][][][] dstDat = new short[1][][][];
WlzObject.WlzToSArray3D(dstSz, dstDat, wlzObj, og, sz, 0);
for (int idY = 0; idY < h; ++idY) {
int idYW = idY * w;
for (int idX = 0; idX < w; ++idX) {
short p = dstDat[0][0][idY][idX];
buf[2 * (idYW + idX)] = (byte) ((p >>> 8) & m);
buf[2 * (idYW + idX) + 1] = (byte) (p & m);
}
}
}
break;
case WlzGreyType.WLZ_GREY_INT:
{
int m = 0xff;
int[][][][] dstDat = new int[1][][][];
WlzObject.WlzToIArray3D(dstSz, dstDat, wlzObj, og, sz, 0);
for (int idY = 0; idY < h; ++idY) {
int idYW = idY * w;
for (int idX = 0; idX < w; ++idX) {
int p = dstDat[0][0][idY][idX];
buf[idYW + (4 * idX)] = (byte) ((p >> 24) & m);
buf[idYW + (4 * idX) + 1] = (byte) ((p >> 16) & m);
buf[idYW + (4 * idX) + 2] = (byte) ((p >> 8) & m);
buf[idYW + (4 * idX) + 3] = (byte) (p & m);
}
}
}
break;
case WlzGreyType.WLZ_GREY_RGBA:
{
int m = 0xff;
int cOff = h * w;
int[][][][] dstDat = new int[1][][][];
WlzObject.WlzToRArray3D(dstSz, dstDat, wlzObj, og, sz, 0);
for (int idY = 0; idY < h; ++idY) {
int idYW = idY * w;
for (int idX = 0; idX < w; ++idX) {
int idYWX = idYW + idX;
int p = dstDat[0][0][idY][idX];
buf[idYWX] = (byte) ((p >> 0) & m);
buf[idYWX + cOff] = (byte) ((p >> 8) & m);
buf[idYWX + (2 * cOff)] = (byte) ((p >> 16) & m);
buf[idYWX + (3 * cOff)] = (byte) ((p >> 24) & m);
}
}
}
break;
case WlzGreyType.WLZ_GREY_ERROR:
/* Indicates no values. */
{
int w8 = (w + 7) / 8;
byte[][][][] dstDat = new byte[1][][][];
WlzObject.WlzToBArray3D(dstSz, dstDat, wlzObj, og, sz, 0);
for (int idY = 0; idY < h; ++idY) {
int idYW = idY * w;
int idYW8 = idY * w8;
for (int idX = 0; idX < w; ++idX) {
byte p = dstDat[0][0][idY][idX / 8];
byte b = (byte) (p & (0x01 << (idX % 8)));
if (b == 0) {
buf[idYW + idX] = (byte) 0x00;
} else {
buf[idYW + idX] = (byte) 0xff;
}
}
}
}
break;
default:
throw new WlzException("Unsupported pixel type");
}
return (buf);
}
Aggregations