resizing image resolution

Discussion in 'iOS Programming' started by uaecasher, Dec 31, 2009.

  1. uaecasher macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #1
    hello,

    I'm wondering if anyone can tell me how to change the image resolution when it have been picked from uiimagepickercontroller ?

    thanks
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You need to create a new image that is the size you want and then draw the existing image into that image.

    There is a generic way to do it via CGBitmapContext but for the iPhone you should use UIGraphicsBeginImageContext, UIGraphicsGetCurrentContext, CGContextDrawImage, UIGraphicsGetImageFromCurrentImageContext, and UIGraphicsEndImageContext.

    Edit: I should add, CGContextDrawImage will automatically scale the image to fit whatever rect you pass it.
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    Plus, there are some open-source libraries you can search for that extend the UIImage Class to do image-resizing.
     
  4. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #4
    do you know any ?
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
  6. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #6
    Thanks, I'm wondering does that change the resolution only or actually crops the image, I know there are deferent examples but all of them seem to crop the image
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Did you read that page yet?
     
  8. uaecasher thread starter macrumors 65816

    uaecasher

    Joined:
    Jan 29, 2009
    Location:
    Stillwater, OK
    #8
    I did actually, but not quite understanding the code, so I'm reading it again ;p
     

Share This Page