iphone Programming Glossary: cgimageref
Retrieving a pixel alpha value for a UIImage http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage CGImage from UIImageView image and created a RGBA byte array from this. Alpha is premultiplied. CGImageRef image uiImage.CGImage NSUInteger width CGImageGetWidth image NSUInteger height CGImageGetHeight image..
Resizing UIimages pulled from the Camera also ROTATES the UIimage? http://stackoverflow.com/questions/1260249/resizing-uiimages-pulled-from-the-camera-also-rotates-the-uiimage I am using this to resize it UIImage resizeImage UIImage anImage width int width height int height CGImageRef imageRef anImage CGImage CGImageAlphaInfo alphaInfo CGImageGetAlphaInfo imageRef if alphaInfo kCGImageAlphaNone.. imageRef alphaInfo CGContextDrawImage bitmap CGRectMake 0 0 width height imageRef CGImageRef ref CGBitmapContextCreateImage bitmap UIImage result UIImage imageWithCGImage ref CGContextRelease bitmap.. sourceImage self CGFloat targetWidth targetSize.width CGFloat targetHeight targetSize.height CGImageRef imageRef sourceImage CGImage CGBitmapInfo bitmapInfo CGImageGetBitmapInfo imageRef CGColorSpaceRef colorSpaceInfo..
How to Rotate a UIImage 90 degrees? http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees sourceImage anImage CGFloat targetWidth targetSize.height CGFloat targetHeight targetSize.width CGImageRef imageRef sourceImage CGImage CGBitmapInfo bitmapInfo CGImageGetBitmapInfo imageRef CGColorSpaceRef colorSpaceInfo.. bitmap 0 targetHeight CGContextDrawImage bitmap CGRectMake 0 0 targetWidth targetHeight imageRef CGImageRef ref CGBitmapContextCreateImage bitmap UIImage newImage UIImage imageWithCGImage ref CGContextRelease..
Getting thumbnail from a video url or data in IPhone SDK http://stackoverflow.com/questions/1347562/getting-thumbnail-from-a-video-url-or-data-in-iphone-sdk CMTimeMakeWithSeconds 0 30 AVAssetImageGeneratorCompletionHandler handler ^ CMTime requestedTime CGImageRef im CMTime actualTime AVAssetImageGeneratorResult result NSError error if result AVAssetImageGeneratorSucceeded..
Cropping a UIImage http://stackoverflow.com/questions/158914/cropping-a-uiimage but there is a function that you can use to get the desired results CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect.. CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect largeImage CGImage cropRect or use the UIImage wherever you like..
Core Data - Storing Images (iPhone) http://stackoverflow.com/questions/2090028/core-data-storing-images-iphone
Rounded UIView using CALayers - only some corners - How? http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how 50 1 CGContextClosePath context CGContextClip context CGContextDrawImage context rect img.CGImage CGImageRef imageMasked CGBitmapContextCreateImage context CGContextRelease context CGColorSpaceRelease colorSpace..
How do I export UIImage array as a movie? http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie remaining part is getting a pixel buffer from a CGImage CVPixelBufferRef newPixelBufferFromCGImage CGImageRef image NSDictionary options NSDictionary dictionaryWithObjectsAndKeys NSNumber numberWithBool YES kCVPixelBufferCGImageCompatibilityKey..
display image from URL retrieved from ALAsset in iPhone http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone resultblock ^ ALAsset myasset ALAssetRepresentation rep myasset defaultRepresentation CGImageRef iref rep fullResolutionImage if iref largeimage UIImage imageWithCGImage iref largeimage retain .. resultblock ^ ALAsset myasset ALAssetRepresentation rep myasset defaultRepresentation CGImageRef iref rep fullResolutionImage if iref UIImage largeimage UIImage imageWithCGImage iref delegate hiresImageAvailable..
iOS SDK - Programmatically generate a PDF file http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file 100 This code block will create an image that we then draw to the page const char picture Picture CGImageRef image CGDataProviderRef provider CFStringRef picturePath CFURLRef pictureURL picturePath CFStringCreateWithCString..
UIImagePickerController camera preview is portrait in landscape app http://stackoverflow.com/questions/538041/uiimagepickercontroller-camera-preview-is-portrait-in-landscape-app messageID 7949889 UIImage scaleAndRotateImage UIImage image int kMaxResolution 640 Or whatever CGImageRef imgRef image.CGImage CGFloat width CGImageGetWidth imgRef CGFloat height CGImageGetHeight imgRef CGAffineTransform..
iOS UIImagePickerController result image orientation after upload http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload self.size.height self.CGImage break And now we just create a new UIImage from the drawing context CGImageRef cgimg CGBitmapContextCreateImage ctx UIImage img UIImage imageWithCGImage cgimg CGContextRelease ctx..
Dispelling the UIImage imageNamed: FUD http://stackoverflow.com/questions/924740/dispelling-the-uiimage-imagenamed-fud own optimised version. I can't see it is worth the maintentace but here it is for completeness. CGImageRef originalImage uiImage.CGImage CFDataRef imageData CGDataProviderCopyData CGImageGetDataProvider originalImage.. CGDataProviderRef imageDataProvider CGDataProviderCreateWithCFData imageData CFRelease imageData CGImageRef image CGImageCreate CGImageGetWidth originalImage CGImageGetHeight originalImage CGImageGetBitsPerComponent..
Retrieving a pixel alpha value for a UIImage http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage alpha value of a pixel in a UIImageView. I have obtained the CGImage from UIImageView image and created a RGBA byte array from this. Alpha is premultiplied. CGImageRef image uiImage.CGImage NSUInteger width CGImageGetWidth image NSUInteger height CGImageGetHeight image CGColorSpaceRef colorSpace CGColorSpaceCreateDeviceRGB rawData..
Resizing UIimages pulled from the Camera also ROTATES the UIimage? http://stackoverflow.com/questions/1260249/resizing-uiimages-pulled-from-the-camera-also-rotates-the-uiimage width 400 height 533 myImageView setImage myResizedImg I am using this to resize it UIImage resizeImage UIImage anImage width int width height int height CGImageRef imageRef anImage CGImage CGImageAlphaInfo alphaInfo CGImageGetAlphaInfo imageRef if alphaInfo kCGImageAlphaNone alphaInfo kCGImageAlphaNoneSkipLast CGContextRef.. height CGImageGetBitsPerComponent imageRef 4 width CGImageGetColorSpace imageRef alphaInfo CGContextDrawImage bitmap CGRectMake 0 0 width height imageRef CGImageRef ref CGBitmapContextCreateImage bitmap UIImage result UIImage imageWithCGImage ref CGContextRelease bitmap CGImageRelease ref return result QUESTION How do I RESIZE.. to do this UIImage imageByScalingToSize CGSize targetSize UIImage sourceImage self CGFloat targetWidth targetSize.width CGFloat targetHeight targetSize.height CGImageRef imageRef sourceImage CGImage CGBitmapInfo bitmapInfo CGImageGetBitmapInfo imageRef CGColorSpaceRef colorSpaceInfo CGImageGetColorSpace imageRef if bitmapInfo kCGImageAlphaNone..
How to Rotate a UIImage 90 degrees? http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees CGSize targetSize UIImage anImage UIImage sourceImage anImage CGFloat targetWidth targetSize.height CGFloat targetHeight targetSize.width CGImageRef imageRef sourceImage CGImage CGBitmapInfo bitmapInfo CGImageGetBitmapInfo imageRef CGColorSpaceRef colorSpaceInfo CGImageGetColorSpace imageRef if bitmapInfo kCGImageAlphaNone.. CGContextRotateCTM bitmap radians 90 CGContextTranslateCTM bitmap 0 targetHeight CGContextDrawImage bitmap CGRectMake 0 0 targetWidth targetHeight imageRef CGImageRef ref CGBitmapContextCreateImage bitmap UIImage newImage UIImage imageWithCGImage ref CGContextRelease bitmap CGImageRelease ref return newImage iphone uikit uiimage..
Getting thumbnail from a video url or data in IPhone SDK http://stackoverflow.com/questions/1347562/getting-thumbnail-from-a-video-url-or-data-in-iphone-sdk TRUE asset release CMTime thumbTime CMTimeMakeWithSeconds 0 30 AVAssetImageGeneratorCompletionHandler handler ^ CMTime requestedTime CGImageRef im CMTime actualTime AVAssetImageGeneratorResult result NSError error if result AVAssetImageGeneratorSucceeded NSLog @ couldn't generate thumbnail error @ error..
Cropping a UIImage http://stackoverflow.com/questions/158914/cropping-a-uiimage elsewhere There isn't a simple class method to do this but there is a function that you can use to get the desired results CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect largeImage CGImage cropRect or use the UIImage wherever.. is a function that you can use to get the desired results CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect largeImage CGImage cropRect or use the UIImage wherever you like UIImageView setImage UIImage imageWithCGImage imageRef CGImageRelease..
Core Data - Storing Images (iPhone) http://stackoverflow.com/questions/2090028/core-data-storing-images-iphone
Rounded UIView using CALayers - only some corners - How? http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how rect CGRectMake 0 0 w h addRoundedRectToPath context rect 50 1 CGContextClosePath context CGContextClip context CGContextDrawImage context rect img.CGImage CGImageRef imageMasked CGBitmapContextCreateImage context CGContextRelease context CGColorSpaceRelease colorSpace img release return UIImage imageWithCGImage imageMasked Don't..
How do I export UIImage array as a movie? http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie in a lot of blanks but I think that the only really hard remaining part is getting a pixel buffer from a CGImage CVPixelBufferRef newPixelBufferFromCGImage CGImageRef image NSDictionary options NSDictionary dictionaryWithObjectsAndKeys NSNumber numberWithBool YES kCVPixelBufferCGImageCompatibilityKey NSNumber numberWithBool YES..
display image from URL retrieved from ALAsset in iPhone http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone self.node valueForKey kVMMediaURL ALAssetsLibraryAssetForURLResultBlock resultblock ^ ALAsset myasset ALAssetRepresentation rep myasset defaultRepresentation CGImageRef iref rep fullResolutionImage if iref largeimage UIImage imageWithCGImage iref largeimage retain ALAssetsLibraryAccessFailureBlock failureblock ^ NSError myerror..
iOS SDK - Programmatically generate a PDF file http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file 50 50 pageRect.size.width 100 pageRect.size.height 100 This code block will create an image that we then draw to the page const char picture Picture CGImageRef image CGDataProviderRef provider CFStringRef picturePath CFURLRef pictureURL picturePath CFStringCreateWithCString NULL picture kCFStringEncodingUTF8 pictureURL..
UIImagePickerController camera preview is portrait in landscape app http://stackoverflow.com/questions/538041/uiimagepickercontroller-camera-preview-is-portrait-in-landscape-app like this Code from http discussions.apple.com thread.jspa messageID 7949889 UIImage scaleAndRotateImage UIImage image int kMaxResolution 640 Or whatever CGImageRef imgRef image.CGImage CGFloat width CGImageGetWidth imgRef CGFloat height CGImageGetHeight imgRef CGAffineTransform transform CGAffineTransformIdentity CGRect bounds..
iOS UIImagePickerController result image orientation after upload http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload CGContextDrawImage ctx CGRectMake 0 0 self.size.width self.size.height self.CGImage break And now we just create a new UIImage from the drawing context CGImageRef cgimg CGBitmapContextCreateImage ctx UIImage img UIImage imageWithCGImage cgimg CGContextRelease ctx CGImageRelease cgimg return img @end share improve this answer..
Dispelling the UIImage imageNamed: FUD http://stackoverflow.com/questions/924740/dispelling-the-uiimage-imagenamed-fud Rincewind also included some example code to build your own optimised version. I can't see it is worth the maintentace but here it is for completeness. CGImageRef originalImage uiImage.CGImage CFDataRef imageData CGDataProviderCopyData CGImageGetDataProvider originalImage CGDataProviderRef imageDataProvider CGDataProviderCreateWithCFData.. CGDataProviderCopyData CGImageGetDataProvider originalImage CGDataProviderRef imageDataProvider CGDataProviderCreateWithCFData imageData CFRelease imageData CGImageRef image CGImageCreate CGImageGetWidth originalImage CGImageGetHeight originalImage CGImageGetBitsPerComponent originalImage CGImageGetBitsPerPixel originalImage CGImageGetBytesPerRow..
Retrieving a pixel alpha value for a UIImage http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage I have obtained the CGImage from UIImageView image and created a RGBA byte array from this. Alpha is premultiplied. CGImageRef image uiImage.CGImage NSUInteger width CGImageGetWidth image NSUInteger height CGImageGetHeight image CGColorSpaceRef colorSpace..
Resizing UIimages pulled from the Camera also ROTATES the UIimage? http://stackoverflow.com/questions/1260249/resizing-uiimages-pulled-from-the-camera-also-rotates-the-uiimage myResizedImg I am using this to resize it UIImage resizeImage UIImage anImage width int width height int height CGImageRef imageRef anImage CGImage CGImageAlphaInfo alphaInfo CGImageGetAlphaInfo imageRef if alphaInfo kCGImageAlphaNone alphaInfo.. 4 width CGImageGetColorSpace imageRef alphaInfo CGContextDrawImage bitmap CGRectMake 0 0 width height imageRef CGImageRef ref CGBitmapContextCreateImage bitmap UIImage result UIImage imageWithCGImage ref CGContextRelease bitmap CGImageRelease.. CGSize targetSize UIImage sourceImage self CGFloat targetWidth targetSize.width CGFloat targetHeight targetSize.height CGImageRef imageRef sourceImage CGImage CGBitmapInfo bitmapInfo CGImageGetBitmapInfo imageRef CGColorSpaceRef colorSpaceInfo CGImageGetColorSpace..
How to Rotate a UIImage 90 degrees? http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees anImage UIImage sourceImage anImage CGFloat targetWidth targetSize.height CGFloat targetHeight targetSize.width CGImageRef imageRef sourceImage CGImage CGBitmapInfo bitmapInfo CGImageGetBitmapInfo imageRef CGColorSpaceRef colorSpaceInfo CGImageGetColorSpace.. CGContextTranslateCTM bitmap 0 targetHeight CGContextDrawImage bitmap CGRectMake 0 0 targetWidth targetHeight imageRef CGImageRef ref CGBitmapContextCreateImage bitmap UIImage newImage UIImage imageWithCGImage ref CGContextRelease bitmap CGImageRelease..
Getting thumbnail from a video url or data in IPhone SDK http://stackoverflow.com/questions/1347562/getting-thumbnail-from-a-video-url-or-data-in-iphone-sdk CMTime thumbTime CMTimeMakeWithSeconds 0 30 AVAssetImageGeneratorCompletionHandler handler ^ CMTime requestedTime CGImageRef im CMTime actualTime AVAssetImageGeneratorResult result NSError error if result AVAssetImageGeneratorSucceeded NSLog @..
Cropping a UIImage http://stackoverflow.com/questions/158914/cropping-a-uiimage method to do this but there is a function that you can use to get the desired results CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect largeImage CGImage.. the desired results CGImageCreateWithImageInRect CGImageRef CGRect will help you out. Here's a short example using it CGImageRef imageRef CGImageCreateWithImageInRect largeImage CGImage cropRect or use the UIImage wherever you like UIImageView setImage..
Core Data - Storing Images (iPhone) http://stackoverflow.com/questions/2090028/core-data-storing-images-iphone
Rounded UIView using CALayers - only some corners - How? http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how context rect 50 1 CGContextClosePath context CGContextClip context CGContextDrawImage context rect img.CGImage CGImageRef imageMasked CGBitmapContextCreateImage context CGContextRelease context CGColorSpaceRelease colorSpace img release return..
How do I export UIImage array as a movie? http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie only really hard remaining part is getting a pixel buffer from a CGImage CVPixelBufferRef newPixelBufferFromCGImage CGImageRef image NSDictionary options NSDictionary dictionaryWithObjectsAndKeys NSNumber numberWithBool YES kCVPixelBufferCGImageCompatibilityKey..
display image from URL retrieved from ALAsset in iPhone http://stackoverflow.com/questions/3837115/display-image-from-url-retrieved-from-alasset-in-iphone resultblock ^ ALAsset myasset ALAssetRepresentation rep myasset defaultRepresentation CGImageRef iref rep fullResolutionImage if iref largeimage UIImage imageWithCGImage iref largeimage retain ALAssetsLibraryAccessFailureBlock.. resultblock ^ ALAsset myasset ALAssetRepresentation rep myasset defaultRepresentation CGImageRef iref rep fullResolutionImage if iref UIImage largeimage UIImage imageWithCGImage iref delegate hiresImageAvailable large..
iOS SDK - Programmatically generate a PDF file http://stackoverflow.com/questions/4362734/ios-sdk-programmatically-generate-a-pdf-file pageRect.size.height 100 This code block will create an image that we then draw to the page const char picture Picture CGImageRef image CGDataProviderRef provider CFStringRef picturePath CFURLRef pictureURL picturePath CFStringCreateWithCString NULL..
UIImagePickerController camera preview is portrait in landscape app http://stackoverflow.com/questions/538041/uiimagepickercontroller-camera-preview-is-portrait-in-landscape-app thread.jspa messageID 7949889 UIImage scaleAndRotateImage UIImage image int kMaxResolution 640 Or whatever CGImageRef imgRef image.CGImage CGFloat width CGImageGetWidth imgRef CGFloat height CGImageGetHeight imgRef CGAffineTransform transform..
iOS UIImagePickerController result image orientation after upload http://stackoverflow.com/questions/5427656/ios-uiimagepickercontroller-result-image-orientation-after-upload 0 0 self.size.width self.size.height self.CGImage break And now we just create a new UIImage from the drawing context CGImageRef cgimg CGBitmapContextCreateImage ctx UIImage img UIImage imageWithCGImage cgimg CGContextRelease ctx CGImageRelease cgimg..
Dispelling the UIImage imageNamed: FUD http://stackoverflow.com/questions/924740/dispelling-the-uiimage-imagenamed-fud code to build your own optimised version. I can't see it is worth the maintentace but here it is for completeness. CGImageRef originalImage uiImage.CGImage CFDataRef imageData CGDataProviderCopyData CGImageGetDataProvider originalImage CGDataProviderRef.. originalImage CGDataProviderRef imageDataProvider CGDataProviderCreateWithCFData imageData CFRelease imageData CGImageRef image CGImageCreate CGImageGetWidth originalImage CGImageGetHeight originalImage CGImageGetBitsPerComponent originalImage..
|