22 package com.realtime.crossfire.jxclient.faces;
24 import java.awt.image.BufferedImage;
26 import javax.swing.Icon;
27 import javax.swing.ImageIcon;
28 import org.jetbrains.annotations.NotNull;
57 width = srcImageIcon.getIconWidth();
58 height = srcImageIcon.getIconHeight();
60 srcData =
new int[width*
height];
61 final BufferedImage srcBufferedImage =
new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
62 srcImageIcon.paintIcon(null, srcBufferedImage.getGraphics(), 0, 0);
63 srcBufferedImage.getRGB(0, 0, width, height, srcData, 0, width);
75 final BufferedImage image =
new BufferedImage(width*2, height*2, BufferedImage.TYPE_INT_ARGB);
76 image.setRGB(0, 0, width*2, height*2, scaler.
getScaledData(), 0, width*2);
78 return new ImageIcon(image);
85 public static void main(@NotNull
final String[] args) {
86 final String srcFile =
"random_orig.png";
87 System.out.println(
"Reading: "+srcFile);
88 final ImageIcon src =
new ImageIcon(srcFile);
92 final String outFile = srcFile.substring(0, srcFile.length()-4)+
"2x.png";
93 System.out.println(
"Writing: "+outFile);
95 fileCache.
save(outFile, 0, out);
void save(@NotNull final Face face, @NotNull final ImageIcon imageIcon)
Stores an ImageIcon into the cache.the face to save the image icon to store
A simple implementation of the Scale2x algorithm for scaling raw image data.
final int width
The width of the image.
final int height
The height of the image.
A disk based cache for image files.
ImageScale2x(@NotNull final Icon srcImageIcon)
Creates a new scaler that will scale the passed image.
final int [] srcData
The src data from the image.
int [] getScaledData()
Gets the scale image data.
ImageIcon getScaledImage()
Retrieves the scaled image.
static void main(@NotNull final String[] args)
An entry point and a bit of test code.
A utility to perform the scale2x algorithm on a Java Image.