2009-05-01から1ヶ月間の記事一覧

UIImageをNSDataにする (iPhone Cocoa)

セーブするためには、UIImageをNSDataに変換する必要がある。 以下の方法で変換できる。 NSData *data = UIImagePNGRepresentation(image); CGFloat compressionQuality = 0.8; NSData *data = UIImageJPEGRepresentation(image, compressionQuality);

UIImageの拡大縮小(iPhone cocoa)

30x40のサイズにする場合。 CGRect newRect = CGRectMake(0, 0, 30, 40); UIGraphicsBeginImageContext(newRect.size); [image drawInRect:rect]; UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();