public ARGBType( final int value ) { img = null; dataAccess = new IntArray( 1 ); set( value ); }
@Override public void convert( final T input, final ARGBType output ) { output.set( input.toARGBInt() ); } }
@Override public void setOne() { set( rgba( 1, 1, 1, 1 ) ); }
@Override public void convert( final UnsignedByteType input, final ARGBType output ) { output.set( input.get() << shift ); } }
@Override public void set( final ARGBType c ) { set( c.get() ); }
@Override public void convert( final R input, final ARGBType output ) { final double a = input.getRealDouble(); final int b = Math.min( 255, roundPositive( Math.max( 0, ( a - min ) / scale * 255.0 ) ) ); final int argb = this.alpha | ( b << 8 | b ) << 8 | b; output.set( argb ); }
/** * This is only intended to work with UnsignedByteType! We ignore index!!! */ @Override public void setValue( final int index, final byte value ) { final ARGBType t = sampler.get(); t.set( ( t.get() & mask ) | ( value << shift ) ); } }
@Override public void convert( final R input, final ARGBType output ) { final double a = input.getRealDouble(); final int argb = lut.lookupARGB( min, max, a ); output.set( argb ); }
@Override public void convert( final ARGBType input, final ARGBType output ) { output.set( convertColor( input.get() )); } }
/** * This is only intended to work with UnsignedByteType! We ignore index!!! */ @Override public void setValue( final int index, final byte value ) { final ARGBType t = sampler.get(); t.set( ( t.get() & mask ) | ( value << shift ) ); } }
@Override public void convert( final ARGBType input, final ARGBType output ) { output.set( getScaledColor( input.get() ) ); } }
@Override public void convert( final VolatileRealType< ? > input, final ARGBType output ) { if ( input.isValid() ) super.convert( input, output ); else output.set( background ); }
@Override public void convert( final VolatileARGBType input, final ARGBType output ) { output.set( getScaledColor( input.get().get() ) ); } }
@Override public void convert( final VolatileARGBType input, final ARGBType output ) { output.set( convertColor( input.get().get() )); } }
@Override public void mul( final double c ) { final int value = get(); set( rgba( red( value ) * c, green( value ) * c, blue( value ) * c, alpha( value ) * c ) ); }
@Override public void mul( final float c ) { final int value = get(); set( rgba( red( value ) * c, green( value ) * c, blue( value ) * c, alpha( value ) * c ) ); }
@Override public void div( final ARGBType c ) { final int value1 = get(); final int value2 = c.get(); set( rgba( red( value1 ) / red( value2 ), green( value1 ) / green( value2 ), blue( value1 ) / blue( value2 ), alpha( value1 ) / alpha( value2 ) ) ); }
@Override public void sub( final ARGBType c ) { final int value1 = get(); final int value2 = c.get(); set( rgba( red( value1 ) - red( value2 ), green( value1 ) - green( value2 ), blue( value1 ) - blue( value2 ), alpha( value1 ) - alpha( value2 ) ) ); }
@Override public void mul( final ARGBType c ) { final int value1 = get(); final int value2 = c.get(); set( rgba( red( value1 ) * red( value2 ), green( value1 ) * green( value2 ), blue( value1 ) * blue( value2 ), alpha( value1 ) * alpha( value2 ) ) ); }
@Test public void testMergeARBGWriting() { // setup byte[] pixels = new byte[ 4 ]; Img< UnsignedByteType > image = ArrayImgs.unsignedBytes( pixels, 4 ); // process RandomAccessibleInterval< ARGBType > arbg = Converters.mergeARGB( image, ColorChannelOrder.ARGB ); arbg.randomAccess().get().set( new ARGBType( 0x01020304 ) ); // test Assert.assertArrayEquals( new byte[] { 1, 2, 3, 4 }, pixels ); }