【问题标题】:Which Image Formats does JavaFX Support?JavaFX 支持哪些图像格式?
【发布时间】:2014-08-04 00:24:16
【问题描述】:

我正在寻找 JavaFX 支持的图像类型(最新)列表,例如PNG、JPEG、TIFF。不同的搜索引擎没有帮助......知道从哪里开始吗?

更特别的是,我对 16 位灰度图像(不同格式)和罕见的支持 jpg-lossless 标准感兴趣。

【问题讨论】:

    标签: javafx image-formats


    【解决方案1】:

    下面的列表是根据 Fireworks 和 Photoshop 允许的选项生成的,Save As: 加上一些我选择的格式,考虑到常见的并且对 ImageJ 有一些支持。

    因此并不意味着ImageJ原生支持该格式,而是意味着即使需要额外的插件也可以在ImageJ中打开。而且这个列表不是ImageJ支持的完整列表,更详细的列表(包括支持是原生的还是通过插件,请查看this page

    File Format:    bits                details         Native support      ImageJ
    

    PNG              32     fireworks format .fw.png          ✓               ✓
                     32              flat format              ✓               ✓
                     24              flat format              ✓               ✓
    

                     8               flat format              ✓               ✓
    GIF              8       2 colours (black & white)        ✓               ✓
                     8               16 colours               ✓               ✓
                     8               256 colours              ✓               ✓ 
    

    JPG              24             Quality: 100%             ✓               ✓
                     24         100% && Smoothing = 8         ✓               ✓
    JPS (JPG Stereo) 24                                       ✓               ✓
    

    MPO              24                                       ✓               ✓
    

    TIFF             32                                       ✘               ✓
                     24                                       ✘               ✓
                      8                                       ✘               ✓
    

    JPEG2000                                                  ✘               ✓
    EPS                                                       ✘               ✓
    TGA                                                       ✘               ✓
    RAW (photoshop)                                           ✘               ✓
    PSD                                                       ✘               ✓
    FITs                                                      ✘               ✓
    PGM (.pgm)                                                ✘               ✓
    PPM (.ppm)                                                ✘               ✓
    PBM (.pbm)                                                ✘               ✓
    DICOM                                                     ✘               ✓
    NiFTI                                                     ✘               ✓
    PICT                                                      ✘               ✓
    ICO                                                       ✘               ✓
    ANALYZE                                                   ✘               ✓
    MOV                                                       ✘               ✓
    SPE (.spe)                                                ✘               ✓
    PIC                                                       ✘               ✓
    AVI (.avi)                                                ✘               ✓
    CUR                                                       ✘               ✓
    PXR (Pixar)                                               ✘               ✘ 
    SCT (Scitex)                                              ✘               ✘ 
    IFF                                                       ✘               ✘ 
    WBMP                                                      ✘               ✘ 
    PDF                                                       ✘               ✘ 
    

    此测试是在 Windows 8.1 上进行的:

    java version "1.8.0_05"
    Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
    

    用于创建此列表的源代码:

    import java.io.File;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.layout.GridPane;
    import javafx.stage.Stage;
    
    public class JavaFXSupportedImages extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            File dir = new File("formats_supported_on_javaFX_folder");//Folder Path
            File[] images = dir.listFiles();
            GridPane root = new GridPane();
            int col=0, row=0;
            for(File f: images){
                Button btn = new Button(f.getName());
                try{
                    Image fximage = new Image(f.toURI().toURL().toString());
                    ImageView pic = new ImageView();
                    pic.setImage(fximage);
                    pic.setFitWidth(130);
                    pic.setFitHeight(50);
                    btn.setGraphic(pic);
                }catch(Exception e){
                    System.out.println("JavaFX doesn't support: " + btn.getText());
                }
                if(col>3){
                    col=0;
                    row++;
                }
                else
                {
                    col++;
                }
                root.add(btn, col, row);
            }
            Scene scene = new Scene(root, 300, 250);    
            primaryStage.setTitle("JavaFX Support test!");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    
    }
    

    【讨论】:

    • 非常感谢您的努力!我认为没有官方信息来源,因此直接从代码中保留它是最好的解决方案!
    猜你喜欢
    • 1970-01-01
    • 2021-01-09
    • 1970-01-01
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    • 2015-08-05
    • 2011-09-10
    相关资源
    最近更新 更多