本文整理了Java中javafx.scene.Scene.snapshot()
方法的一些代码示例,展示了Scene.snapshot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scene.snapshot()
方法的具体详情如下:
包路径:javafx.scene.Scene
类名称:Scene
方法名:snapshot
暂无
代码示例来源:origin: us.ihmc/ihmc-javafx-toolkit
public BufferedImage snapshot()
{
WritableImage snapshot = scene.snapshot(null);
BufferedImage fromFXImage = SwingFXUtils.fromFXImage(snapshot, null);
BufferedImage pngImage = null;
byte[] imageInByte;
try
{
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ImageIO.write(fromFXImage, "png", byteArrayOutputStream);
byteArrayOutputStream.flush();
imageInByte = byteArrayOutputStream.toByteArray();
byteArrayOutputStream.close();
InputStream in = new ByteArrayInputStream(imageInByte);
pngImage = ImageIO.read(in);
}
catch (IOException e)
{
e.printStackTrace();
}
return pngImage;
}
代码示例来源:origin: stackoverflow.com
public void start(Stage primaryStage) {
Group mainGroup = new Group();
Rectangle r = new Rectangle(0, 0, 200, 200);
Stop[] stops = new Stop[] { new Stop(0, new Color(0.0, 0.0, 1.0, 1.0)),
new Stop(1, new Color(1.0, 1.0, 1.0, 0.0)) };
LinearGradient lg = new LinearGradient(0, 0, 1, 1, true, CycleMethod.NO_CYCLE, stops);
r.setFill(lg);
mainGroup.getChildren().add(r);
Scene scene = new Scene(mainGroup, 200, 200);
scene.setFill(Color.TRANSPARENT);
primaryStage.setScene(scene);
primaryStage.show();
WritableImage image = scene.snapshot(null);
PixelReader pixelReader = image.getPixelReader();
System.out.println("Color: " + pixelReader.getColor((int)image.getWidth()/2, (int)image.getHeight()/2));
}
代码示例来源:origin: stackoverflow.com
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.WritableImage ;
import javafx.scene.control.Label;
// ...
private static Image textToImage(String text) {
Label label = new Label(text);
label.setMinSize(125, 125);
label.setMaxSize(125, 125);
label.setPrefSize(125, 125);
label.setStyle("-fx-background-color: white; -fx-text-fill:black;");
label.setWrapText(true);
Scene scene = new Scene(new Group(label));
WritableImage img = new WritableImage(125, 125) ;
scene.snapshot(img);
return img ;
}
代码示例来源:origin: com.github.vatbub/common.view.reporting
imageTemp = screenshotScene.snapshot(null);
代码示例来源:origin: org.jrebirth.af/component
/**
* {@inheritDoc}
*/
@Override
protected void perform(Wave wave) throws CommandException {
final SnapshotWaveBean wb = waveBean(wave);
WritableImage image = wb.image();
if (wb.node() == null) {
final Scene scene = localFacade().globalFacade().application().scene();
image = scene.snapshot(image);
} else {
image = wb.node().snapshot(wb.parameters(), image);
}
wb.image(image);
}
内容来源于网络,如有侵权,请联系作者删除!