From aa2cd57b2b5e9bd834a9eaedad7d3e02d7f5aa20 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 17 May 2016 14:15:40 +0200 Subject: [PATCH] fix IAE --- platform/util/src/com/intellij/util/ImageLoader.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/util/src/com/intellij/util/ImageLoader.java b/platform/util/src/com/intellij/util/ImageLoader.java index ee3c767a3f35..7df12ec5091e 100644 --- a/platform/util/src/com/intellij/util/ImageLoader.java +++ b/platform/util/src/com/intellij/util/ImageLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -294,8 +294,13 @@ public class ImageLoader implements Serializable { @NotNull private static Image scaleImage(Image image, float scale) { - int width = (int)(scale * image.getWidth(null)); - int height = (int)(scale * image.getHeight(null)); + int w = image.getWidth(null); + int h = image.getHeight(null); + if (w <= 0 || h <= 0) { + return image; + } + int width = (int)(scale * w); + int height = (int)(scale * h); // Using "QUALITY" instead of "ULTRA_QUALITY" results in images that are less blurry // because ultra quality performs a few more passes when scaling, which introduces blurriness // when the scaling factor is relatively small (i.e. <= 3.0f) -- which is the case here.