Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MultiResolutionRenderer from bigdataviewer-core #268

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions src/main/java/bdv/fx/viewer/render/MultiResolutionRendererFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
import net.imglib2.Interval;
import net.imglib2.Volatile;
import net.imglib2.img.array.ArrayImg;
import net.imglib2.img.basictypeaccess.IntAccess;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.type.numeric.ARGBType;
import net.imglib2.ui.RenderTarget;
import net.imglib2.ui.Renderer;
import net.imglib2.ui.TransformListener;

/**
* A {@link Renderer} that uses a coarse-to-fine rendering scheme. First, a small {@link ArrayImg} at a fraction of
Expand Down Expand Up @@ -88,29 +91,54 @@ public class MultiResolutionRendererFX extends MultiResolutionRendererGeneric<Bu
{

public static class MakeWritableImage
implements MultiResolutionRendererGeneric.ImageGenerator<BufferExposingWritableImage>
implements RenderOutputImage.Factory<BufferExposingWritableImage>
{

@Override
public BufferExposingWritableImage create(final int width, final int height)
public RenderOutputImage create(final int width, final int height)
{
try
{
return new BufferExposingWritableImage(width, height);
return new MyRenderOutputImage(new BufferExposingWritableImage(width, height));
} catch (final Exception e)
{
throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
}
}

@Override
public BufferExposingWritableImage create(final int width, final int height, final BufferExposingWritableImage
other)
{
// TODO can we somehow re-use smaller image?
public RenderOutputImage create(int width, int height, RenderOutputImage other) {
return create(width, height);
}
}

public static class MyRenderOutputImage implements RenderOutputImage<BufferExposingWritableImage> {

private final BufferExposingWritableImage image;

public MyRenderOutputImage(BufferExposingWritableImage image) {
this.image = image;
}

@Override
public int width() {
return (int) image.getWidth();
}

@Override
public int height() {
return (int) image.getHeight();
}

@Override
public ArrayImg<ARGBType, IntAccess> asArrayImg() {
return image.asArrayImg();
}

@Override
public BufferExposingWritableImage unwrap() {
return image;
}
}

public MultiResolutionRendererFX(
Expand All @@ -136,11 +164,7 @@ public MultiResolutionRendererFX(
useVolatileIfAvailable,
accumulateProjectorFactory,
cacheControl,
BufferExposingWritableImage::asArrayImg,
new MakeWritableImage(),
img -> (int) img.getWidth(),
img -> (int) img.getHeight()
new MakeWritableImage()
);
}

}
Loading