00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package com.realtime.crossfire.jxclient.util;
00023
00024 import java.awt.image.BufferedImage;
00025 import java.io.File;
00026 import java.io.IOException;
00027 import javax.imageio.ImageIO;
00028 import javax.swing.Icon;
00029 import javax.swing.ImageIcon;
00030 import org.jetbrains.annotations.NotNull;
00031
00036 public class Images {
00037
00041 private Images() {
00042 }
00043
00050 public static void saveImageIcon(@NotNull final File outputFile, @NotNull final Icon imageIcon) {
00051 final BufferedImage bufferedImage = new BufferedImage(imageIcon.getIconWidth(), imageIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
00052 imageIcon.paintIcon(null, bufferedImage.getGraphics(), 0, 0);
00053 try {
00054 ImageIO.write(bufferedImage, "png", outputFile);
00055 } catch (final IOException ex) {
00056 System.err.println("Cannot write cache file "+outputFile+": "+ex.getMessage());
00057 }
00058 }
00059
00060 }