Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes How to crop image in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to crop image in java" Watch "How to crop image in java" New topic
Author

How to crop image in java

Vivek Moyal
Ranch Hand

Joined: Nov 02, 2009
Posts: 57
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

1) Please UseCodeTags. You can edit your post to add them.

2)
How to show it to image label
image.setIcon(ima); is having error so how i can i do it

What's the error? Please TellTheDetails.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Vivek Moyal
Ranch Hand

Joined: Nov 02, 2009
Posts: 57
In crop image function what should i do after line no 43
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

ima is an Image, not an Icon. Check out what methods your "icon" variable has, then use that variable in the call to setIcon.

This would have been easier to find out if you would have posted the error as I has asked you. Now I'm actually guessing this is the problem (but it probably is).
Vivek Moyal
Ranch Hand

Joined: Nov 02, 2009
Posts: 57
I have done much work over it . I m getting the image on other frame from Jfilechooser and from that frame i have to crop the image and this image is showing in label

and now i want to crop some area of image so that i can use the image which is worth to me.

So i dont know how to crop the image in cropImage() function i m doing the croping but i dont how to do it and at last when the crop is compelete i want to put the cropped image at other label from where i can save it in database i think now this is clear so now pleasehelp me
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

ima is an Image. image is a JLabel. It's setIcon method requires an Icon. Is Image compatible with Icon? I don't think so. Is there some class or object that is? Yes there is, and you even have an instance of that: icon.

Can you find a method of icon that allows you to change its image? I'm sure you can. Once you've done that I'm sure you'll be able to set the Icon of image. After all, you then have an Icon with the cropped image.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to crop image in java