简体   繁体   中英

How do I access image data in Xcode iOS app developer?

I am VERY new to Xcode and even iOS apps/platform in general. I have a lot of image processing experience using other development platform environments and am looking to apply this toward iOS apps. I have noticed that nothing is mentioned for Xcode in regards to accessing image data and/or directly modifying it. Many people that have made tutorials seem to use an image picker but never have I seen where they say or show how to access the image data.

An answer to this would great. Guidance would be most appreciated. Thanks.

UIImage provides the ability to display images from several different formats, but it's immutable -- you can't change the data it uses and expect to see the image change. Instead, you'll get an image in one of the underlying types and work with that. You'll probably want to read up on both Core Graphics (Quartz) and Core Image. For example, you can use UIImage 's -CGImage method to get the image as a CGImage and then use the Core Graphics CGImage...() functions to find out about the image data (format, bit depth, etc) and get the actual bits.

AVAssetLibrary can help you to modify image data.

ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc]init];
[assetsLibrary assetForURL:photoUrl resultBlock:resultBlock
                      failureBlock:nil];

Using above code you will get asset of image in result block.

ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset *photoAsset)
{        
     ALAssetRepresentation *image_representation = [photoAsset defaultRepresentation];
     //Do the stuff to get-modify image data from image_representation...
}

Hope this is what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM