Example #1
0
 /**
  * Writes an image into the path with the specified file name and the image extension.
  *
  * @param path path
  * @param fileName file name of the written image
  * @param ext extension of the file name
  * @throws IOException
  * @author DSIW
  */
 public void write(final String path, final String fileName, final String ext) throws IOException {
   final BufferedImage bimage =
       new BufferedImage(
           Images.getWidth(image), Images.getHeight(image), BufferedImage.TYPE_INT_RGB);
   final Graphics2D graphics2d = bimage.createGraphics();
   graphics2d.drawImage(image, 0, 0, this);
   ImageIO.write(
       bimage,
       ext.toLowerCase(),
       new File(path + File.separator + fileName + "." + ext.toLowerCase()));
 }
Example #2
0
 /**
  * Loads an icon from the class path.
  *
  * @param fileName picture name (not absolute path)
  * @return icon
  * @author DSIW
  */
 public static Icon loadLocalIcon(final String fileName) {
   Image image = null;
   try {
     image = new Images(fileName).getImage();
   } catch (final IOException e) {
     e.printStackTrace();
   }
   final Icon icon = Images.toImageIcon(image);
   return icon;
 }
Example #3
0
 /**
  * Resizes an image.
  *
  * @param img image to resize
  * @param width width and height of the resized image
  * @return resized image
  * @author DSIW
  */
 public static Image resize(final Image img, final int width) {
   return Images.resize(img, width, width);
 }
Example #4
0
 /**
  * @param image image
  * @return width of the image
  */
 public static int getWidth(final Image image) {
   return Images.toImageIcon(image).getIconWidth();
 }
Example #5
0
 /**
  * @param image image
  * @return height of the image
  */
 public static int getHeight(final Image image) {
   return Images.toImageIcon(image).getIconHeight();
 }