@Override public ByteArray createArray( final int numEntities ) { return new ByteArray( numEntities ); } }
/** * 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 ByteArray plane ) { 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 ByteArray( 0 ), a -> new DirtyVolatileByteArray( a.getCurrentStorageArray(), true ) ) : ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new ByteArray( 0 ), a -> new DirtyByteArray( a.getCurrentStorageArray() ) ) ) : ( volatil ? ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new ByteArray( 0 ), a -> new VolatileByteArray( a.getCurrentStorageArray(), true ) ) : ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new ByteArray( 0 ), a -> a ) ); case CHAR: return dirty
@Override public void convertBytes(final ByteArray data, final byte[] bytes, final int planesRead) { if (isCompatible()) { final int offset = planesRead * bytes.length; System.arraycopy(bytes, 0, data.getCurrentStorageArray(), offset, bytes.length); } else { final ImageMetadata iMeta = reader().getMetadata().get(0); 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 byte value = (byte) utils().decodeWord(bytes, index * bpp, pixelType, iMeta.isLittleEndian()); data.setValue(offset + index, value); } } }
@Override public void convertBytes(final ByteArray data, final byte[] bytes, final int planesRead) { if (isCompatible()) { final int offset = planesRead * bytes.length; System.arraycopy(bytes, 0, data.getCurrentStorageArray(), offset, bytes.length); } else { final ImageMetadata iMeta = reader().getMetadata().get(0); 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 byte value = (byte) utils().decodeWord(bytes, index * bpp, pixelType, iMeta.isLittleEndian()); data.setValue(offset + index, value); } } }
@Override public ByteArray createArray( final int numEntities ) { return new ByteArray( numEntities ); } }
@Override protected DataBufferByte createDataBuffer( final ByteArray data ) { final byte[] sourceArray = data.getCurrentStorageArray(); return new DataBufferByte( sourceArray, sourceArray.length ); }
@Override public ByteArray emptyArray(final int entities) { return new ByteArray(entities); }
@Override public void mutate(final ArrayImg<ByteType, ByteArray> arg) { final byte[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
@Override public ByteArray emptyArray(final int entities) { return new ByteArray(entities); }
@Override public void mutate(final ArrayImg<UnsignedByteType, ByteArray> arg) { final byte[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
public GenericByteType( final byte value ) { img = null; dataAccess = new ByteArray( 1 ); setByte( value ); }
@Override protected SignedByteDataBuffer createDataBuffer( final ByteArray data ) { final byte[] sourceArray = data.getCurrentStorageArray(); return new SignedByteDataBuffer( sourceArray, sourceArray.length ); }
/** * Creates an {@link ArrayImg}<{@link ByteType}, {@link ByteArray}> reusing * a passed byte[] array. */ final public static ArrayImg< ByteType, ByteArray > bytes( final byte[] array, final long... dim ) { return bytes( new ByteArray( array ), dim ); }
@Override protected SignedByteDataBuffer createDataBuffer( final ByteArray data ) { final byte[] sourceArray = data.getCurrentStorageArray(); return new SignedByteDataBuffer( sourceArray, sourceArray.length ); }
@Override public ByteArray load( final ByteBuffer bytes, final int numElements ) { return new ByteArray( loadData( bytes, numElements ) ); } }
@Override public void mutate(final ArrayImg<ByteType, ByteArray> arg) { final byte[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] *= value; } }
/** * Creates an {@link ArrayImg}<{@link UnsignedByteType}, {@link ByteArray}> * reusing a passed byte[] array. */ final public static ArrayImg< UnsignedByteType, ByteArray > unsignedBytes( final byte[] array, final long... dim ) { return unsignedBytes( new ByteArray( array ), dim ); }
@Override public void mutate(final ArrayImg<UnsignedByteType, ByteArray> arg) { final byte[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] /= value; } }
/** * Creates an {@link ArrayImg}<{@link UnsignedByteType}, {@link ByteArray}> * reusing a passed byte[] array. */ final public static ArrayImg< UnsignedByteType, ByteArray > unsignedBytes( final byte[] array, final long... dim ) { return unsignedBytes( new ByteArray( array ), dim ); }