Java ImageIcon Scale scaleImage(ImageIcon icon)

Here you can find the source of scaleImage(ImageIcon icon)

Description

scale Image

License

Apache License

Declaration

private static ImageIcon scaleImage(ImageIcon icon) 

Method Source Code

//package com.java2s;
/* Copyright (c) 2011 Danish Maritime Authority.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.// w w w. j  av a  2s. c  om
 */

import java.awt.Image;

import javax.swing.ImageIcon;

public class Main {
    private static ImageIcon scaleImage(ImageIcon icon) {
        // Scale it?
        Image img = icon.getImage();
        Image newimg = img.getScaledInstance(444, 200,
                java.awt.Image.SCALE_SMOOTH);

        ImageIcon newIcon = new ImageIcon(newimg);

        return newIcon;
    }
}

Related

  1. scaleIcon(final ImageIcon icon)
  2. scaleIcon(ImageIcon icon, int size)
  3. scaleIcon(int width, int height, ImageIcon img)
  4. scaleIconTo(ImageIcon icon, int width, int height)
  5. scaleImage(ImageIcon i, int x, int y)
  6. scaleImage(ImageIcon src, int width, int height)
  7. scaleImageIcon(ImageIcon icon, float scale, int hints)
  8. scaleImageIcon(ImageIcon icon, int newHeight, int newWidth)
  9. scaleImageIcon(ImageIcon icon, int w, int h)