mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
icon -> image
This commit is contained in:
@@ -28,9 +28,12 @@ import com.intellij.ui.IconDeferrer;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.ui.RowIcon;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
|
||||
public class IconUtil {
|
||||
@@ -178,4 +181,20 @@ public class IconUtil {
|
||||
private static FileIconPatcher[] getPatchers() {
|
||||
return FileIconPatcherHolder.ourPatchers;
|
||||
}
|
||||
|
||||
public static Image toImage(@NotNull Icon icon) {
|
||||
if (icon instanceof ImageIcon) {
|
||||
return ((ImageIcon)icon).getImage();
|
||||
}
|
||||
else {
|
||||
final int w = icon.getIconWidth();
|
||||
final int h = icon.getIconHeight();
|
||||
final BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(w, h, Color.TRANSLUCENT);
|
||||
final Graphics2D g = image.createGraphics();
|
||||
icon.paintIcon(null, g, 0, 0);
|
||||
g.dispose();
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user