Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Crop Image 
 

To crop an image, an image is defined inside the class folder. The class ImageIcon calls its method getImage() which returns the specified image.

 

Crop Image

                         

This section shows you how the image get crops.

To crop an image, an image is defined inside the class folder. The class ImageIcon calls its method getImage() which returns the specified image. The Insets class shows the border of a container which specifies the space leave at each of its edges.

To produce image data for a filtration of the original image, we take an existing image and a filter object by using the class FilteredImageSource. To crop an image, we have used the CropImageFilter class which is extended by the ImageFilter class. 

Here is the code of CropImage.java

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(7570140150)));
  }
  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(250250);
    frame.show();
  }
}

Output will be displayed as:

Download Source Code

                         

» View all related tutorials
Related Tags: c string com class orm ant form object io sed format screen font display vi metrics id render oo define

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

how to save Crop image in java script ?

Posted by ron on Monday, 12.22.08 @ 05:50am | #83044

now that i have cropped the image, how do i physically save the image to secondary storage device?

Posted by it2051229 on Sunday, 12.14.08 @ 05:47am | #82737

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.