Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to crop image in java

 
Vivek Moyal
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vivek Moyal
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In crop image function what should i do after line no 43
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic