how to crop image in Java?
Hello,
I'm trying to crop an image which is saved in the hardrive. But when I run the program it gives me the following error message:
java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
I checked the original image and its width= 1280 and Hight=960. It seems that the problem is when Java try to create the new cropped image!!
The following is the code:
Image image =new ImageIcon(s).getImage();
t=image.getImage();
Toolkit tk = Toolkit.getDefaultToolkit();
ImageProducer source = image.getSource();
ImageFilter extractFilter=new CropImageFilter(0,0,100,100);
Image image2 = tk.createImage(new FilteredImageSource(source,extractFilter));
Any help please.

