Image processing 如何将平面图像或缓冲图像(JAI)转换为图像(JavaFX)
在使用JAI操作后,我试图更改ImageView实例中表示的图像。JAI可以输出平面图像、渲染图像(非awt)或缓冲图像(非awt),但这些类型对于ImageView构造无效Image processing 如何将平面图像或缓冲图像(JAI)转换为图像(JavaFX),image-processing,javafx,jai,Image Processing,Javafx,Jai,在使用JAI操作后,我试图更改ImageView实例中表示的图像。JAI可以输出平面图像、渲染图像(非awt)或缓冲图像(非awt),但这些类型对于ImageView构造无效 import java.awt.image.renderable.ParameterBlock; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.ScrollPane; impor
import java.awt.image.renderable.ParameterBlock;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.Interpolation;
public class A11 extends Application{
int zoom = 100;
ImageView img = new ImageView();
Image src = new Image("file.bmp");
public static void main(String args[]){
launch(args); // start application
}
@Override
public void start(Stage window){
ParameterBlock pb = new ParameterBlock();
pb.addSource(src); // source Image
pb.add(zoom/100); // xScale
pb.add(zoom/100); // yScale
pb.add(0.0F); // xTranslate
pb.add(0.0F); // yTranslate
pb.add(Interpolation.getInstance(Interpolation.INTERP_BICUBIC));
PlanarImage dest = JAI.create("scale", pb, null);
// NEED TO CONVERT 'dest' TO 'destImage' HERE
ImageView frame = new ImageView(destImage);
ScrollPane pane = new ScrollPane(frame);
window.setScene(new Scene(pane,800,600));
window.show();
}
}
您是否经常使用
buffereImage
不仅仅是awt
类?似乎没有在api中列出该名称的类型,例如PlanarImage.getAsBufferedImage
返回java.awt.image.BufferedImage
。在这种情况下,您可以简单地使用SwingFXUtils
。(但确实创建了3个对象。)啊哈!我相信你是对的,先生