crop image in java

Tue Nov 11, 2008 6:59 pm

crop image in java
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;

public class CropImage extends JFrame {
  Image image;
  Insets insets;

  public CropImage() {
    super("Crop Image");
    ImageIcon icon = new ImageIcon("image4.jpg");
    image = icon.getImage();
    image = createImage(new FilteredImageSource(image.
       getSource(),new CropImageFilter(75, 70, 140, 150)));
  }
  public void paint(Graphics g) {
    super.paint(g);
    if (insets == null) {
      insets = getInsets();
    }
    g.drawImage(image, insets.left, insets.top, this);
  }
  public static void main(String args[]) {
    JFrame frame = new CropImage();
    frame.setSize(250, 250);
    frame.show();
  }
}



Attachments
cropImage.gif
output if cropping image
cropImage.gif (6.18 KiB) Viewed 20915 times

Re: crop image in java

Fri Nov 25, 2011 6:49 am

Please tell me about createImage() the super("Crop Image") class........

Re: crop image in java

Sun Nov 27, 2011 1:00 am

Using it to create a new image object from original image "image4.jpg" after apply the Crop filter on it.

  Related Posts  to : crop image in java
 crop image using JQuery     -  
 JavaCV crop image     -  
 flip image in java     -  
 java image effects     -  
 image binarization in java     -  
 image processing in java     -  
 how to compress Bmp image in java...     -  
 Clip of image in java     -  
 Image Scale in java     -  
 Image Custom Filter In Java     -  

Topic Tags

Java Image