public ImageConverterChain withFilter(final ImageFilter[] filters) {
   ImageConverterChain chain = this;
   for (ImageFilter filter : filters) {
     chain = chain.withFilter(filter);
   }
   return chain;
 }
 @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());
 }
 @Nullable
 public Image load(@NotNull ImageConverterChain converters) {
   for (ImageDesc desc : this) {
     try {
       Image image = desc.load();
       if (image == null) continue;
       LOG.debug("Loaded image: " + desc);
       return converters.convert(image, desc);
     } catch (IOException ignore) {
     }
   }
   return null;
 }
  @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;
                      }
                    }));
  }
 public static Image loadFromStream(
     @NotNull final InputStream inputStream, final int scale, ImageFilter filter) {
   Image image = load(inputStream, scale);
   ImageDesc desc = new ImageDesc("", null, scale, ImageDesc.Type.UNDEFINED);
   return ImageConverterChain.create().withFilter(filter).withRetina().convert(image, desc);
 }
 @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());
 }
 @Nullable
 public Image load() {
   return load(ImageConverterChain.create());
 }