Resize an image file?

Discussion in 'iOS Development' started by origamitech, Feb 5, 2010.

  1. origamitech

    origamitech New Member

    Apr 14, 2009
    Likes Received:
    2G iPod touch
    I have a 320x480 PNG Image, and I want to resize that to being 512x512 with the original image just in the top-left and save it to a new file.
    I want to do this USING OBJECTIVE-C CODE, as the PNG will be loaded dynamically.

    How do I achieve this?
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Sep 19, 2007
    Likes Received:
    This should be fairly easy to figure out, so I won't tell give you the code. I will tell you how to do this though. : )

    You will need to use CoreGraphics.

    Step 1) Create a new graphics context.
    Step 2) Draw your image into the new graphics context.
    Step 3) Extract an image from the context and save, using the compression format of your choice (might I recommend png?).

    EDIT: Oh, and this will require exclusively C, since that is what CoreGraphics is written in. Maybe use Objective-C to retrieve and save the image, but that is unnecessary, and C will get the job done just fine.

Share This Page