Java ImageIcon getThumbImage(ImageIcon myLoadedImageIcon, int thumbHeight, int thumbWidth)

Here you can find the source of getThumbImage(ImageIcon myLoadedImageIcon, int thumbHeight, int thumbWidth)

Description

get Thumb Image

License

Open Source License

Declaration

public static ImageIcon getThumbImage(ImageIcon myLoadedImageIcon, int thumbHeight, int thumbWidth) 

Method Source Code

//package com.java2s;
/**/*from  w  ww  . ja  va2  s  .c o m*/
 * ComicDB - overview you comics
 * Copyright (C) 2006  Daniel Moos
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 * St, Fifth Floor, Boston, MA 02110, USA
 */

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;

public class Main {
    public static ImageIcon getThumbImage(ImageIcon myLoadedImageIcon, int thumbHeight, int thumbWidth) {

        Image myImage = myLoadedImageIcon.getImage();
        //        int scaledX = (int) (scaleFactor * myImage.getWidth(null));
        //        int scaledY = (int) (scaleFactor * myImage.getHeight(null));
        BufferedImage thumbImage = new BufferedImage(thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics2D = thumbImage.createGraphics();
        graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        graphics2D.drawImage(myImage, 0, 0, thumbWidth, thumbHeight, null);
        graphics2D.dispose();
        //        Image scaledImage  = myImage.getScaledInstance(thumbWidth, thumbHeight, Image.SCALE_SMOOTH);
        return new ImageIcon(thumbImage);
    }
}

Related

  1. getDisabledIcon(ImageIcon icon)
  2. getHeight(ImageIcon imagen)
  3. getOpenSwingImage(String name, ImageIcon defaultIcon)
  4. getRenderedImage(ImageIcon icon)
  5. getSizeOfImage(ImageIcon imgIn)
  6. getThumbnail(ImageIcon src, int maxWidth)
  7. grabRGB(ImageIcon icon)
  8. iconDefaultSize(ImageIcon imag)
  9. imageFlip(int w, int h, ImageIcon... icons)