Crop Image

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]
LVL 9
DrWarezzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vikraman_bCommented:
0
Dejan PažinHead of SW DevelopmentCommented:

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
objectsCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

DrWarezzAuthor Commented:
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
DrWarezzAuthor Commented:
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
girionisCommented:
:)
0
objectsCommented:
(:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.