@Nullable
 public static Image loadFromResource(@NonNls @NotNull String path, @NotNull Class aClass) {
   return ImageDescList.create(
           path,
           aClass,
           UIUtil.isUnderDarcula(),
           UIUtil.isRetina() || JBUI.scale(1.0f) >= 1.5f,
           true)
       .load(ImageConverterChain.create().withRetina());
 }
    public static ImageDescList create(
        @NotNull String file,
        @Nullable Class cls,
        boolean dark,
        boolean retina,
        boolean allowFloatScaling) {
      ImageDescList vars = new ImageDescList();
      if (retina || dark) {
        final String name = FileUtil.getNameWithoutExtension(file);
        final String ext = FileUtilRt.getExtension(file);

        float scale = calcScaleFactor(allowFloatScaling);

        // TODO: allow SVG images to freely scale on Retina

        if (Registry.is("ide.svg.icon") && dark) {
          vars.add(
              new ImageDesc(
                  name + "_dark.svg", cls, UIUtil.isRetina() ? 2f : scale, ImageDesc.Type.SVG));
        }

        if (Registry.is("ide.svg.icon")) {
          vars.add(
              new ImageDesc(
                  name + ".svg", cls, UIUtil.isRetina() ? 2f : scale, ImageDesc.Type.SVG));
        }

        if (dark && retina) {
          vars.add(new ImageDesc(name + "@2x_dark." + ext, cls, 2f, ImageDesc.Type.PNG));
        }

        if (dark) {
          vars.add(new ImageDesc(name + "_dark." + ext, cls, 1f, ImageDesc.Type.PNG));
        }

        if (retina) {
          vars.add(new ImageDesc(name + "@2x." + ext, cls, 2f, ImageDesc.Type.PNG));
        }
      }
      vars.add(new ImageDesc(file, cls, 1f, ImageDesc.Type.PNG, true));
      return vars;
    }
  @Nullable
  public static Image loadFromUrl(
      @NotNull URL url, boolean allowFloatScaling, ImageFilter[] filters) {
    final float scaleFactor = calcScaleFactor(allowFloatScaling);

    // We can't check all 3rd party plugins and convince the authors to add @2x icons.
    // (scaleFactor > 1.0) != isRetina() => we should scale images manually.
    // Note we never scale images on Retina displays because scaling is handled by the system.
    final boolean scaleImages = (scaleFactor > 1.0f) && !UIUtil.isRetina();

    // For any scale factor > 1.0, always prefer retina images, because downscaling
    // retina images provides a better result than upscaling non-retina images.
    final boolean loadRetinaImages = UIUtil.isRetina() || scaleImages;

    return ImageDescList.create(
            url.toString(), null, UIUtil.isUnderDarcula(), loadRetinaImages, allowFloatScaling)
        .load(
            ImageConverterChain.create()
                .withFilter(filters)
                .withRetina()
                .with(
                    new ImageConverter() {
                      public Image convert(Image source, ImageDesc desc) {
                        if (source != null && scaleImages && desc.type != ImageDesc.Type.SVG) {
                          if (desc.path.contains("@2x"))
                            return scaleImage(
                                source,
                                scaleFactor
                                    / 2.0f); // divide by 2.0 as Retina images are 2x the
                                             // resolution.
                          else return scaleImage(source, scaleFactor);
                        }
                        return source;
                      }
                    }));
  }
 @Nullable
 public static Image loadFromUrl(URL url, boolean dark, boolean retina, ImageFilter[] filters) {
   return ImageDescList.create(url.toString(), null, dark, retina, true)
       .load(ImageConverterChain.create().withFilter(filters).withRetina());
 }