Last active
August 29, 2015 14:00
-
-
Save HiromichiYamada/11164376 to your computer and use it in GitHub Desktop.
ALAssetから画像データへの変換
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Getting Raw Data from ALAsset. | |
// ALAsset* asset = ... | |
ALAssetRepresentation *rep = [asset defaultRepresentation]; | |
Byte *buffer = (Byte*)malloc( (size_t)rep.size ); | |
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:(NSUInteger)rep.size error:nil]; | |
NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES]; | |
// UIImage from ALAsset. | |
// ALAsset* asset = ... | |
ALAssetRepresentation *rep = [asset defaultRepresentation]; | |
UIImage *imageOrg = [UIImage imageWithCGImage:rep.fullScreenImage | |
scale:rep.scale | |
orientation:0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment