Total members 11894 |It is currently Fri Nov 22, 2024 4:30 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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:
File comment: output if cropping image
cropImage.gif
cropImage.gif [ 6.18 KiB | Viewed 23854 times ]

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada
Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

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



Author:

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


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 3 posts ] 

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



Topic Tags

Java Image
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com