当前位置: 首页>>代码示例>>Java>>正文


Java SwingFXUtils.fromFXImage方法代码示例

本文整理汇总了Java中javafx.embed.swing.SwingFXUtils.fromFXImage方法的典型用法代码示例。如果您正苦于以下问题:Java SwingFXUtils.fromFXImage方法的具体用法?Java SwingFXUtils.fromFXImage怎么用?Java SwingFXUtils.fromFXImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.embed.swing.SwingFXUtils的用法示例。


在下文中一共展示了SwingFXUtils.fromFXImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
 * Receives an image from another node.
 * @param image Input image
 */
@Override
public void update(Image image) {
    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        String result = MSE(imagePeer[0], imagePeer[1]);

        Graphics2D g2d;
        BufferedImage bImg = new BufferedImage(80 , 60, BufferedImage.TYPE_INT_RGB);
        g2d = bImg.createGraphics();
        g2d.drawString(result,5   ,bImg.getHeight()/2);
        setImage(SwingFXUtils.toFXImage(bImg,null));
        System.out.printf("PSNR: %s\n",result);
        super.update(getImage());
    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:25,代码来源:MSE.java

示例2: update

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
 * Whenever the input is changed or a new connection
 * is made this function is called.
 * @param image Current image
 */
@Override
public void update(Image image) {

    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        int mtxResult [][] = minus(ImageUtil.convertToGreyTone(imagePeer[0]), ImageUtil.convertToGreyTone(imagePeer[1]));
        setImage( ImageUtil.toImage( mtxResult ));
        System.out.println("Sub!");
        super.update(getImage());

    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:23,代码来源:ArithmeticOperatorSubt.java

示例3: writeData

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
@Override
@BackgroundThread
protected void writeData(@NotNull final VarTable vars, final @NotNull Path resultFile) throws IOException {
    super.writeData(vars, resultFile);

    final Color color = UIUtils.from(vars.get(PROP_COLOR, ColorRGBA.class));

    final int width = vars.getInteger(PROP_WIDTH);
    final int height = vars.getInteger(PROP_HEIGHT);

    final WritableImage writableImage = new WritableImage(width, height);
    final PixelWriter pixelWriter = writableImage.getPixelWriter();

    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            pixelWriter.setColor(i, j, color);
        }
    }

    final BufferedImage bufferedImage = SwingFXUtils.fromFXImage(writableImage, null);

    try (final OutputStream out = Files.newOutputStream(resultFile)) {
        ImageIO.write(bufferedImage, "png", out);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:SingleColorTextureFileCreator.java

示例4: update

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
 * Receives an image from another node.
 * @param image Input image
 */
@Override
public void update(Image image) {
    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        int mtxResult [][] = or(ImageUtil.convertToGreyTone(imagePeer[0]), ImageUtil.convertToGreyTone(imagePeer[1]));
        setImage( ImageUtil.toImage( mtxResult ));
        System.out.println("OR!");
        super.update(getImage());
    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:20,代码来源:LogicalOperatorOr.java

示例5: update

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
 * Receives an image from another node.
 * @param image Input image
 */
@Override
public void update(Image image) {
    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        String result = PSNR(imagePeer[0], imagePeer[1]);

        Graphics2D g2d;

        BufferedImage bImg = new BufferedImage(80 , 60, BufferedImage.TYPE_INT_RGB);
        g2d = bImg.createGraphics();
        g2d.drawString(result+"",5   ,bImg.getHeight()/2);
        setImage(SwingFXUtils.toFXImage(bImg,null));
        System.out.printf("PSNR: %s\n",result);
        super.update(getImage());
    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:26,代码来源:PSNR.java

示例6: saveImageCache

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
public void saveImageCache() throws ImageCacheError
{
    File dir = new File("cache/");
    if (!dir.exists())
        throw new ImageCacheError();
    for (Map.Entry<Integer, Image> i : imageCache.entrySet())
    {
        BufferedImage bi = SwingFXUtils.fromFXImage(i.getValue(), null);
        File file = new File("cache/" + i.getKey());
        if (!file.exists() && bi != null)
        {
            try
            {
                ImageIO.write(bi, "png", file);
            } catch (IOException e)
            {
                throw new ImageCacheError();
            }
        }

    }
}
 
开发者ID:Matthieu42,项目名称:Steam-trader-tools,代码行数:23,代码来源:ImageCacheHandler.java

示例7: handleFileSaveAction

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
@FXML
private void handleFileSaveAction(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    File file = fileChooser.showSaveDialog(null);
    
    if (file != null) {
        try {
            WritableImage writableImage = new WritableImage((int) drawingCanvas.getWidth(), (int) drawingCanvas.getHeight());
            drawingCanvas.snapshot(null, writableImage);
            RenderedImage renderedImage = SwingFXUtils.fromFXImage(writableImage, null);            
            ImageIO.write(renderedImage, "png", file);
        } catch (IOException ex) {
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:17,代码来源:FXMLDocumentController.java

示例8: handleFileSaveAction

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
@FXML
private void handleFileSaveAction(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    File file = fileChooser.showSaveDialog(null);
    System.out.println("Saving #" + file + "#");
    if (file != null) {
        // Stole the following part from:
        // http://java-buddy.blogspot.com/2013/04/save-canvas-to-png-file.html
        try {
            WritableImage writableImage = new WritableImage((int) drawingCanvas.getWidth(), (int) drawingCanvas.getHeight());
            drawingCanvas.snapshot(null, writableImage);
            RenderedImage renderedImage = SwingFXUtils.fromFXImage(writableImage, null);
            // hometask: make sure you can save files in any format (not just png)
            // hints: find the extension of the file from the filename, then use substring
            ImageIO.write(renderedImage, "png", file);
        } catch (IOException ex) {
            System.err.println("Couldn't save the file!");
            // hometask: throw an alert dialog from here
        }
    }
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:22,代码来源:FXMLDocumentController.java

示例9: addDirection

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
public void addDirection(String direction, Image tileImage) {
            Map<Integer, Image> temp = new HashMap<>();
            int range = Math.abs(World.MAX_ELEVATION - World.MIN_ELEVATION);
            for (int i = 0; i <= range; i++) {
                BufferedImage tile = SwingFXUtils.fromFXImage(tileImage, null);
                tile = ImageHelper.editBrightness(tile,
                        (float) i / (Math.abs(
                                World.MIN_ELEVATION - World.MAX_ELEVATION) *
                                2));
                tile = ImageHelper.editSaturation(tile,
                        (float) i / (Math.abs(
                                World.MIN_ELEVATION - World.MAX_ELEVATION) *
                                2));
//                tile = ImageHelper.editHue(tile, (float) (range - i) / range);
                temp.put(i, SwingFXUtils.toFXImage(tile, null));
            }
            directionImages.put(direction, temp);
        }
 
开发者ID:UQdeco2800,项目名称:farmsim,代码行数:19,代码来源:TileRegister.java

示例10: getBase64Encoding

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
private String getBase64Encoding() {
    String base64 = null;

    if (this.getImage() != null) {
        try {
            BufferedImage image = SwingFXUtils.fromFXImage(this.getImage(), null);
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ImageIO.write(image, "png", byteArrayOutputStream);
            base64 = new String(Base64.getEncoder().encode(byteArrayOutputStream.toByteArray()));
        } catch (IOException exception) {
            exception.printStackTrace();
        }
    }

    return base64;
}
 
开发者ID:pfolta,项目名称:Shapify,代码行数:17,代码来源:Image.java

示例11: createTask

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
@Override
protected Task<Attachments> createTask() {
    return new Task<Attachments>() {
        @Override
        protected Attachments call() throws Exception {
            final Attachments result = new Attachments();
            final Image image = imageView.getImage();
            if (image == null) return result;
            
            final BufferedImage swingImage = SwingFXUtils.fromFXImage(imageView.getImage(), null);
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final ImageFormat format = formatComboBox.getValue();
            ImageIO.write(swingImage, format.format, baos);
            baos.close();

            imageView.setImage(null);

            final String filename = Optional.ofNullable(filenameField.getText())
                    .orElse(defaultFilename()) + format.extension;
            result.add(new Attachment(filename, baos.toByteArray()));
            return result;
        }
    };
}
 
开发者ID:NoticEditorTeam,项目名称:NoticEditor,代码行数:25,代码来源:ClipboardImageImporter.java

示例12: drawROI

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/** @param gc GC for off-screen image
 *  @param roi RegionOfInterest to draw
 */
private void drawROI(final Graphics2D gc, final RegionOfInterest roi)
{
    if (! roi.isVisible())
        return;

    gc.setColor(GraphicsUtils.convert(roi.getColor()));
    final java.awt.geom.Rectangle2D rect = image_area.createIntersection(roiToScreen(roi));

    final Image image = roi.getImage();
    if (image == null)
        gc.drawRect((int)rect.getMinX(), (int)rect.getMinY(), (int)rect.getWidth(), (int)rect.getHeight());
    else
    {
        final BufferedImage awt_image = SwingFXUtils.fromFXImage(image, null);
        gc.drawImage(awt_image, (int)rect.getMinX(), (int)rect.getMinY(), (int)rect.getWidth(), (int)rect.getHeight(), null);
    }

    gc.drawString(roi.getName(), (int)rect.getMinX(), (int)rect.getMinY());
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:23,代码来源:ImagePlot.java

示例13: SaveEPS

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
public void SaveEPS(File file) {
       
       if (!file.getName().endsWith(".eps")) {
           file = new File(file.getAbsolutePath() + ".eps");
       }

       BufferedImage bufImage = SwingFXUtils.fromFXImage(image, null);
       Graphics2D g = new EpsGraphics2D();
       g.drawImage(bufImage, 0, 0, null);
       String epsString = g.toString();
       
       try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
           bw.write(epsString);
} catch (IOException ex) {
}
   }
 
开发者ID:epigenome,项目名称:iTagPlot,代码行数:17,代码来源:SaveControl.java

示例14: changed

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    if (newValue.equals(Worker.State.SUCCEEDED)) {
        if(webEngine.getDocument().getBaseURI().equals("about:blank")) return;
        //If the page loads, let's take a snapshot of it.
        WritableImage snapshot = new WritableImage((int) screenSize.getWidth(), (int) screenSize.getHeight());
        browser.snapshot(null, snapshot);
        BufferedImage renderedImage = SwingFXUtils.fromFXImage(snapshot, null);
        //Some math to get a little better thumbnail. Starting x is at 1/4 of the totale page. Goes for a width of half of the screen size to attempt and get the 'core' of the content.
        renderedImage = renderedImage.getSubimage((int)(screenSize.getWidth() /4),0,(int)( screenSize.getWidth()  / 2 ),(int) screenSize.getHeight() / 2);
        saveImage(padPath, fileName, renderedImage);
        controller.refreshListView();
        urlStage.close();
        webEngine.load(null);
    }
    else if(newValue.equals(Worker.State.FAILED)){
        //TODO: Send an error message somehow.
        urlStage.close();
    }
}
 
开发者ID:arocketman,项目名称:URL-pad,代码行数:21,代码来源:Snapshotter.java

示例15: saveScreenShot

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
    * Save a screenshot in a user-specified location.
    */
   public void saveScreenShot() {
// Save the image in memory.
WritableImage img = canvas.snapshot(new SnapshotParameters(), null);
BufferedImage buffImg = SwingFXUtils.fromFXImage(img, null);

// Open the file Chooser.
File file = fileChooser.showSaveDialog(null);

if (file != null) {
    try {
	String extension = file.getPath().substring(file.getPath().lastIndexOf('.') + 1);
	System.out.println(extension);
	ImageIO.write(buffImg, extension, file);
    } catch (IOException e) {
	e.printStackTrace();
    }
}
   }
 
开发者ID:mpeterson2,项目名称:Whiteboard,代码行数:22,代码来源:WhiteboardMenu.java


注:本文中的javafx.embed.swing.SwingFXUtils.fromFXImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。