diff --git a/java/java-runtime/src/com/intellij/rt/debugger/ImageSerializer.java b/java/java-runtime/src/com/intellij/rt/debugger/ImageSerializer.java index ad38e2c87103..aed2473a8a0b 100644 --- a/java/java-runtime/src/com/intellij/rt/debugger/ImageSerializer.java +++ b/java/java-runtime/src/com/intellij/rt/debugger/ImageSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -23,15 +23,17 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; /** - * Created by Egor on 04.10.2014. + * @author egor */ public class ImageSerializer { public static byte[] imageToBytes(Image image) throws IOException { + //noinspection UndesirableClassUsage BufferedImage bi = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D g = bi.createGraphics(); g.drawImage(image, 0, 0, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(bi, "png", baos); + g.dispose(); return baos.toByteArray(); } @@ -42,14 +44,17 @@ public class ImageSerializer { return null; } + /** @noinspection unused*/ public static byte[] iconToBytesPreviewNormal(Icon icon) throws IOException { return iconToBytesPreview(icon, 16); } + /** @noinspection unused*/ public static byte[] iconToBytesPreviewRetina(Icon icon) throws IOException { return iconToBytesPreview(icon, 32); } + /** @noinspection unused*/ public static byte[] iconToBytes(Icon icon) throws IOException { return imageToBytes(toImage(icon)); }