Course Hero Logo

SeamCarvivng Main.txt - import javax.imageio.ImageIO;...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 2 out of 2 pages.

import javax.imageio.ImageIO;import javax.swing.*;import java.awt.*;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;public class SeamCarvingMain {// A little utility class to display images as Swing components.private static class ImagePanel extends JPanel {private final Image img;public ImagePanel(Image img, String toolTip) {this.img = img;int w = img.getWidth(this);int h = img.getHeight(this);this.setToolTipText(toolTip + " (" + w + "x" + h + ")");this.setPreferredSize(new Dimension(w, h));this.setBorder(BorderFactory.createEtchedBorder());}public void paintComponent(Graphics g) {g.drawImage(img, 0, 0, this);}}public static void main(String[] args) throws IOException {// Read the test image from the files.Image coffee = ImageIO.read(new File("coffee.jpg"));Image ilkka = ImageIO.read(new File("ilkka.jpg"));// Create a smaller version of the image.coffee = coffee.getScaledInstance(600, 450, Image.SCALE_SMOOTH);
End of preview. Want to read all 2 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
N/A
Tags
new Dimension, ilkka

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture