1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/extensibleicon/src/org/apidesign/extensibleicon/Icon2Image.java Sat Jun 14 09:53:51 2008 +0200
1.3 @@ -0,0 +1,20 @@
1.4 +package org.apidesign.extensibleicon;
1.5 +
1.6 +import java.awt.Image;
1.7 +import java.awt.image.BufferedImage;
1.8 +
1.9 +public class Icon2Image {
1.10 + private Icon2Image() {}
1.11 +
1.12 + // BEGIN: ext.icon2image
1.13 + public static Image toImage(ExtIcon icon) {
1.14 + Image img = icon.getLookup().lookup(Image.class);
1.15 + if (img != null) {
1.16 + return img;
1.17 + }
1.18 + BufferedImage buf = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
1.19 + icon.paintIcon(null, buf.getGraphics(), 0, 0);
1.20 + return buf;
1.21 + }
1.22 + // END: ext.icon2image
1.23 +}