Java Image generateImageVisualizationPanel(String path, int width, int height, int scaling)

Here you can find the source of generateImageVisualizationPanel(String path, int width, int height, int scaling)

Description

generate Image Visualization Panel

License

Open Source License

Declaration

public static JPanel generateImageVisualizationPanel(String path, int width, int height, int scaling) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Image;
import java.io.BufferedInputStream;

import java.io.File;
import java.io.FileInputStream;

import java.io.InputStream;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Main {
    public static JPanel generateImageVisualizationPanel(String path, int width, int height, int scaling) {
        JPanel panel = new JPanel(new BorderLayout());
        try {//from   ww w .  j a  va 2 s. co  m
            Image image = ImageIO.read(new File(path));
            // Read from an input stream
            InputStream is = new BufferedInputStream(new FileInputStream(path));
            image = ImageIO.read(is);

            ImageIcon icon = new ImageIcon(path);
            //      icon.setImage(icon.getImage().getScaledInstance(width, height, scaling));
            icon.setImage(image);
            JLabel label = new JLabel(icon);
            panel.setBackground(Color.white);
            panel.add(label, BorderLayout.CENTER);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return panel;
    }
}

Related

  1. displayImage(Image img)
  2. displayImage(Image img, String mesg, int locx, int locy, int sizex, int sizey)
  3. divideImage(Object obj, int rows, int cols)
  4. ensureImageLoaded(Image img)
  5. findImagefromClasspath(Class relToThisClass, String relImageName)
  6. getChatLogoImage(int width, int height)
  7. getChatLogoImageBig(int width, int height)
  8. getColoredImage(Color color, int width, int height)
  9. getDisabledImage(Image image)