/IconAcquisition

A tool class for obtaining high-definition images, which is used to replace FileSystemView and ShellFolder before JKD17.

Primary LanguageC++Apache License 2.0Apache-2.0

IconAcquisition

A tool class for obtaining high-definition images, which is used to replace FileSystemView and ShellFolder before JKD17.

English | 中文

Simple use example

import system.jni.JavaFXUtils;

class Test{
    public static void main(String[] args) {
        //init the class
        JavaFXUtils.init();
        //get the icon
        JavaFXUtils.getIconImageFX(new File("test.exe"));
        JavaFXUtils.getIconImageBytes(new File("test.exe"));
    }
}

Compare with the API before JDK17

This is a temporary display panel

image

Use the following code to control the API for obtaining Icon

public static Image getIcon(File file) throws IOException {
    if (file == null) {
        throw new FileNotFoundException("File is null");
    }
    try {
        return /*API*/;
    }catch (Exception e){
        log.error("Failed to get icon", e);
    }
    return null;
}

Use FileSystemView to get the icon and display it

try {
    return toFXImage(FileSystemView.getFileSystemView().getSystemIcon(file));
}catch (Exception e){
    log.error("Failed to get icon", e);
}

image

Use ShellFolder to get the icon and display it

try {
    return toFXImage(ShellFolder.getShellFolder(file).getIcon(true));
}catch (Exception e){
    log.error("Failed to get icon", e);
}

image

Use IconAcquisition to get the icon and display it

try {
    return JavaFXUtils.getIconImageFX(file,1200);
}catch (Exception e){
    log.error("Failed to get icon", e);
}

image