io.tlf.jme.jfx.injfx.transfer.impl.ImageFrameTransfer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jme-jfx Show documentation
Show all versions of jme-jfx Show documentation
jMonkeyEngine library for JavaFX 12+ integration.
The newest version!
package io.tlf.jme.jfx.injfx.transfer.impl;
import com.jme3.texture.FrameBuffer;
import io.tlf.jme.jfx.injfx.processor.FrameTransferSceneProcessor.TransferMode;
import io.tlf.jme.jfx.util.JfxPlatform;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
/**
* The class for transferring a frame from jME to {@link ImageView}.
*
* @author JavaSaBr
*/
public class ImageFrameTransfer extends AbstractFrameTransfer {
private WritableImage writableImage;
public ImageFrameTransfer(ImageView imageView, TransferMode transferMode, int width, int height) {
this(imageView, transferMode, null, width, height);
}
public ImageFrameTransfer(
ImageView imageView,
TransferMode transferMode,
FrameBuffer frameBuffer,
int width,
int height
) {
super(imageView, transferMode, frameBuffer, width, height);
JfxPlatform.runInFxThread(() -> imageView.setImage(writableImage));
}
@Override
protected PixelWriter getPixelWriter(
ImageView destination,
FrameBuffer frameBuffer,
int width,
int height
) {
writableImage = new WritableImage(width, height);
return writableImage.getPixelWriter();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy