---
title: "iPhone快速参考：从一个图片截取部分区域生成新的小图"
author: "tiger888"
date: "2011-03-28T22:26:14Z"
tags: []
categories: ["移动开发"]
slug: "iphone"
draft: false
lastmod: "2011-03-28T22:27:44Z"
id: 977976
url: "https://tiger888.iteye.com/blog/977976"
---

UIImage \*image = \[\[UIImage alloc] initWithData:data];//大图

    CGRect imageRect = CGRectMake(0.0, 0.0, image.size.width, image.size.height);

 

    CGSize itemSize = CGSizeMake(w,h);

 

    UIGraphicsBeginImageContext(itemSize);

    \[image drawInRect:imageRect];

    UIImage \*smallimage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();