`
zhangziyangup
  • 浏览: 1078962 次
文章分类
社区版块
存档分类
最新评论

图片裁剪

 
阅读更多

Caijing_iPadAppDelegate *applicationDelegate = (Caijing_iPadAppDelegate *) [UIApplication sharedApplication].delegate;

Page *page = [article.pages objectAtIndex:0];

NSString *pageFile = page.landscapePage;

NSString *imagePath = [[applicationDelegate.articleDataManager.userIssue issuePath]stringByAppendingString:pageFile];

UIImage *image = [UIImage imageWithContentsOfFile:imagePath];

CGSize size = CGSizeMake(600, 600);

CGImageRef temp = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, 0, 500, 500));

image = [UIImage imageWithCGImage:temp];

// UIGraphicsBeginImageContext(size);

// [image drawInRect:CGRectMake(0, 0, 500, 500)];

// UIImage *changedImage = UIGraphicsGetImageFromCurrentImageContext();

// UIGraphicsEndPDFContext();

NSData *data = UIImageJPEGRepresentation(image, 1.0);

//NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

NSString *path = [NSHomeDirectory() stringByAppendingString:@"/tmp/1.jpg"];

[data writeToFile:path atomically:NO];


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics