Commit e5bc85fa authored by Tobias Pietzsch's avatar Tobias Pietzsch
Browse files

support ARGBType in VirtualStackImageLoader

parent 918ad20e
......@@ -8,6 +8,7 @@ import net.imglib2.img.NativeImg;
import net.imglib2.img.basictypeaccess.volatiles.VolatileAccess;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileByteArray;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileFloatArray;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileIntArray;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileShortArray;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.type.NativeType;
......@@ -37,7 +38,7 @@ import bdv.img.cache.VolatileImgCells.CellCache;
* Use {@link #createFloatInstance(ImagePlus)},
* {@link #createUnsignedByteInstance(ImagePlus)} or
* {@link #createUnsignedShortInstance(ImagePlus)} depending on the ImagePlus
* pixel type. ARGB is currently not supported.
* pixel type.
*
* When {@link #getImage(ViewId) loading images}, the provided setup id is used
* as the channel index of the {@link ImagePlus}, the provided timepoint id is
......@@ -112,6 +113,25 @@ public abstract class VirtualStackImageLoader< T extends NativeType< T >, V exte
};
}
public static VirtualStackImageLoader< ARGBType, VolatileARGBType, VolatileIntArray > createARGBInstance( final ImagePlus imp )
{
return new VirtualStackImageLoader< ARGBType, VolatileARGBType, VolatileIntArray >(
imp, new VirtualStackVolatileARGBArrayLoader( imp ), new ARGBType(), new VolatileARGBType() )
{
@Override
protected void linkType( final CachedCellImg< ARGBType, VolatileIntArray > img )
{
img.setLinkedType( new ARGBType( img ) );
}
@Override
protected void linkVolatileType( final CachedCellImg< VolatileARGBType, VolatileIntArray > img )
{
img.setLinkedType( new VolatileARGBType( img ) );
}
};
}
private static double[][] mipmapResolutions = new double[][] { { 1, 1, 1 } };
private static AffineTransform3D[] mipmapTransforms = new AffineTransform3D[] { new AffineTransform3D() };
......
package bdv.img.virtualstack;
import ij.ImagePlus;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileIntArray;
import bdv.img.cache.CacheArrayLoader;
public class VirtualStackVolatileARGBArrayLoader implements CacheArrayLoader< VolatileIntArray >
{
private final VolatileIntArray theEmptyArray;
private final ImagePlus imp;
public VirtualStackVolatileARGBArrayLoader( final ImagePlus imp )
{
theEmptyArray = new VolatileIntArray( imp.getWidth() * imp.getHeight(), false );
this.imp = imp;
}
@Override
public VolatileIntArray loadArray( final int timepoint, final int setup, final int level, final int[] dimensions, final long[] min ) throws InterruptedException
{
final int channel = setup + 1;
final int slice = ( int ) min[ 2 ] + 1;
final int frame = timepoint + 1;
final int[] data = ( int[] ) imp.getStack().getProcessor( imp.getStackIndex( channel, slice, frame ) ).getPixels();
return new VolatileIntArray( data, true );
}
@Override
public VolatileIntArray emptyArray( final int[] dimensions )
{
return theEmptyArray;
}
@Override
public int getBytesPerElement()
{
return 4;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment