@Override public ShortArray emptyArray(final int entities) { return new ShortArray(entities); }
/** * This has to be overwritten, otherwise two different instances exist (one in the imageplus, one in the mirror) */ @Override public void setPlane( final int no, final ShortArray plane ) { // TODO: this should work, but does not for plane 0, why??? //mirror.set( no, plane ); //imp.getStack().setPixels( plane.getCurrentStorageArray(), no + 1 ); System.arraycopy( plane.getCurrentStorageArray(), 0, mirror.get( no ).getCurrentStorageArray(), 0, plane.getCurrentStorageArray().length ); }
return dirty ? ( volatil ? ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new ShortArray( 0 ), a -> new DirtyVolatileShortArray( a.getCurrentStorageArray(), true ) ) : ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new ShortArray( 0 ), a -> new DirtyShortArray( a.getCurrentStorageArray() ) ) ) : ( volatil ? ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new ShortArray( 0 ), a -> new VolatileShortArray( a.getCurrentStorageArray(), true ) ) : ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new ShortArray( 0 ), a -> a ) ); default: return null;
@Override public void convertBytes(final ShortArray data, final byte[] bytes, final int planesRead) { final ImageMetadata iMeta = reader().getMetadata().get(0); if (isCompatible()) { final int bpp = getBitsPerElement() / 8; final int offset = planesRead * (bytes.length / bpp); final ByteBuffer bb = ByteBuffer.wrap(bytes); bb.order(iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); bb.asShortBuffer().get(data.getCurrentStorageArray(), offset, bytes.length / bpp); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel(pixelType); final int offset = planesRead * (bytes.length / bpp); for (int index = 0; index < bytes.length / bpp; index++) { final short value = (short) utils().decodeWord(bytes, index * bpp, pixelType, iMeta.isLittleEndian()); data.setValue(offset + index, value); } } }
@Override public void convertBytes(final ShortArray data, final byte[] bytes, final int planesRead) { final ImageMetadata iMeta = reader().getMetadata().get(0); if (isCompatible()) { final int bpp = getBitsPerElement() / 8; final int offset = planesRead * (bytes.length / bpp); final ByteBuffer bb = ByteBuffer.wrap(bytes); bb.order(iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); bb.asShortBuffer().get(data.getCurrentStorageArray(), offset, bytes.length / bpp); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel(pixelType); final int offset = planesRead * (bytes.length / bpp); for (int index = 0; index < bytes.length / bpp; index++) { final short value = (short) utils().decodeWord(bytes, index * bpp, pixelType, iMeta.isLittleEndian()); data.setValue(offset + index, value); } } }
@Override public ShortArray createArray( final int numEntities ) { return new ShortArray( numEntities ); } }
@Override protected SignedShortDataBuffer createDataBuffer( final ShortArray data ) { final short[] sourceArray = data.getCurrentStorageArray(); return new SignedShortDataBuffer( sourceArray, sourceArray.length ); }
@Override public ShortArray createArray( final int numEntities ) { return new ShortArray( numEntities ); } }
@Override public void mutate(final ArrayImg<ShortType, ShortArray> arg) { final short[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
@Override public ShortArray emptyArray(final int entities) { return new ShortArray(entities); }
@Override public void mutate(final ArrayImg<UnsignedShortType, ShortArray> arg) { final short[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
public GenericShortType( final short value ) { img = null; dataAccess = new ShortArray( 1 ); setShort( value ); }
@Override protected DataBufferUShort createDataBuffer( final ShortArray data ) { final short[] sourceArray = data.getCurrentStorageArray(); return new DataBufferUShort( sourceArray, sourceArray.length ); }
public GenericShortType( final short value ) { img = null; dataAccess = new ShortArray( 1 ); setShort( value ); }
@Override protected DataBufferUShort createDataBuffer( final ShortArray data ) { final short[] sourceArray = data.getCurrentStorageArray(); return new DataBufferUShort( sourceArray, sourceArray.length ); }
/** * Creates an {@link ArrayImg}<{@link ShortType}, {@link ShortArray}> * reusing a passed short[] array. */ final public static ArrayImg< ShortType, ShortArray > shorts( final short[] array, final long... dim ) { return shorts( new ShortArray( array ), dim ); }
@Override protected SignedShortDataBuffer createDataBuffer( final ShortArray data ) { final short[] sourceArray = data.getCurrentStorageArray(); return new SignedShortDataBuffer( sourceArray, sourceArray.length ); }
/** * Creates an {@link ArrayImg}<{@link UnsignedShortType}, * {@link ShortArray}> reusing a passed short[] array. */ final public static ArrayImg< UnsignedShortType, ShortArray > unsignedShorts( final short[] array, final long... dim ) { return unsignedShorts( new ShortArray( array ), dim ); }
@Override public void mutate(final ArrayImg<ShortType, ShortArray> arg) { final short[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] += value; } }
/** * Creates an {@link ArrayImg}<{@link ShortType}, {@link ShortArray}> * reusing a passed short[] array. */ final public static ArrayImg< ShortType, ShortArray > shorts( final short[] array, final long... dim ) { return shorts( new ShortArray( array ), dim ); }