Skip to content

Instantly share code, notes, and snippets.

@HiromichiYamada
Last active August 29, 2015 14:00
Show Gist options
  • Save HiromichiYamada/11164376 to your computer and use it in GitHub Desktop.
Save HiromichiYamada/11164376 to your computer and use it in GitHub Desktop.
ALAssetから画像データへの変換
// 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