All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tlf.jme.jfx.injfx.transfer.impl.ImageFrameTransfer Maven / Gradle / Ivy

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