?
Solved

Crop Image

Posted on 2004-11-20
8
Medium Priority
?
1,352 Views
Last Modified: 2008-02-01
Hey,

is it possible to Crop an image in java? I'm sure it is, but my usual, useful, online, Java reference (www.javaalmanac.com) doesn't have code on how to CROP an image..

Unless this is suppose to do it: http://www.javaalmanac.com/egs/java.awt.image/CreateTxImage.html
What does scaling/shearing do?

Anyone?

Thanks in advance!
[r.D]
0
Comment
Question by:DrWarezz
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 3

Assisted Solution

by:vikraman_b
vikraman_b earned 400 total points
ID: 12633201
0
 
LVL 17

Assisted Solution

by:Dejan Pažin
Dejan Pažin earned 400 total points
ID: 12640113

You can use CropImageFilter class, goes something like this:

  public Image cropImage(Image image, int x, int y, int width, int height)
  {
    ImageProducer source = image.getSource();

    Image result = null;
   
    ImageFilter imageFilter = new CropImageFilter(x, y, width, height);
    ImageProducer imageProducer = new FilteredImageSource(source, imageFilter);
    result = createImage(imageProducer);

    return result;
  }
0
 
LVL 92

Accepted Solution

by:
objects earned 800 total points
ID: 12640398
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Assisted Solution

by:girionis
girionis earned 400 total points
ID: 12642773
0
 
LVL 9

Author Comment

by:DrWarezz
ID: 12644367
Wow, thanks all. Sorry about the delay.. I'm going to have a play around with some of these, and get back to you all soon.

Thanks,
[r.D]
0
 
LVL 9

Author Comment

by:DrWarezz
ID: 12644393
Okay, I had a play already, and Object's method is the easiest to work with, so most points to him.. but all the solutions work, so I will split the points :-)

Thanks all,
[r.D]
0
 
LVL 35

Expert Comment

by:girionis
ID: 12644473
:)
0
 
LVL 92

Expert Comment

by:objects
ID: 12648623
(:
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn different types of Android Layout and some basics of an Android App.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question