Results 1 to 4 of 4

Thread: Image cropping

  1. #1
    pads is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default Image cropping

    Hi All,

    I want to cut a particular shape of an image in java, for example an image which contains a man with white background, here I want to crop the man without the background. Don't want to make it as transparent image, want to cut with some coordinates. I think using the cropImageFilter we can only cut the rectangle region. Can anyone tel me how to do this?

    Thanks is advance.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    Don't want to make it as transparent image, want to cut with some coordinates
    I don't know that you can have a none rectangular image. You want to have a polygon?
    What's wrong with using transparent pixels for the jagged spots?

  3. #3
    pads is offline Member
    Join Date
    Jun 2010
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    I don't know that you can have a none rectangular image. You want to have a polygon?
    What's wrong with using transparent pixels for the jagged spots?
    can u please tel me how to convert a normal image into a transparent image?

  4. #4
    Maxideon is offline Member
    Join Date
    Jun 2010
    Posts
    28
    Rep Power
    0

    Default

    1) Create a cropped BufferedImage of type INT_RGBA or 4BYTE_ABGR. All the pixels in this new image will already be transparent black.

    2) Get a graphics object from this new BufferedImage and set the graphic's clip to the shape in question. You will have to translate the shape to the coordinate space of the new image.

    3) Draw the old image onto the new image.

    4) Dispose of graphics object.

    You can also achieve a near identical effect using just the original image if that image allows for alpha values. It just wont be cropped.

Similar Threads

  1. Replies: 1
    Last Post: 04-17-2009, 12:44 AM
  2. Replies: 14
    Last Post: 04-10-2009, 08:46 AM
  3. Image cropping in Jsf on the release of mouse
    By HarshalAuro in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 11-12-2008, 06:24 PM
  4. Canvas Image popups another image (SWT)
    By SpaceY in forum New To Java
    Replies: 2
    Last Post: 11-11-2008, 01:25 PM
  5. Replies: 0
    Last Post: 01-08-2008, 05:29 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •