¡@

Home 

2014/10/15 ¤U¤È 10:15:17

iphone Programming Glossary: uigraphicsbeginimagecontext

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

gave is also correct but it suffers from the problem that it is not thread safe since you're using UIGraphicsBeginImageContext . Since the above code only uses CG functions you're all set. I also have a similar function to resize..

How to Rotate a UIImage 90 degrees?

http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees

double degrees return degrees M_PI 180 UIImage rotate UIImage src UIImageOrientation orientation UIGraphicsBeginImageContext src.size CGContextRef context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM..

Resize UIImage with aspect ratio?

http://stackoverflow.com/questions/1703100/resize-uiimage-with-aspect-ratio

I'm using this code to resize an image on the iPhone CGRect screenRect CGRectMake 0 0 320.0 480.0 UIGraphicsBeginImageContext screenRect.size value drawInRect screenRect blendMode kCGBlendModePlusDarker alpha 1 UIImage tmpValue..

How to take a screenshot programmatically

http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically

the image on the screen saved into the saved photo library iphone share improve this question UIGraphicsBeginImageContext self.window.bounds.size self.window.layer renderInContext UIGraphicsGetCurrentContext UIImage image.. display change the first line into this if UIScreen mainScreen respondsToSelector @selector scale UIGraphicsBeginImageContextWithOptions self.window.bounds.size NO UIScreen mainScreen .scale else UIGraphicsBeginImageContext self.window.bounds.size..

The simplest way to resize an UIImage?

http://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage

actually need to resize an image UIImage imageWithImage UIImage image scaledToSize CGSize newSize UIGraphicsBeginImageContext newSize In next line pass 0.0 to use the current device's pixel scaling factor and thus account for.. pixel scaling factor and thus account for Retina resolution . Pass 1.0 to force exact pixel size. UIGraphicsBeginImageContextWithOptions newSize NO 0.0 image drawInRect CGRectMake 0 0 newSize.width newSize.height UIImage newImage..

How to capture UIView to UIImage without loss of quality on retina display

http://stackoverflow.com/questions/4334233/how-to-capture-uiview-to-uiimage-without-loss-of-quality-on-retina-display

on retina devices. Does anybody know a solution for my issue UIImage imageWithView UIView view UIGraphicsBeginImageContext view.bounds.size view.layer renderInContext UIGraphicsGetCurrentContext UIImage img UIGraphicsGetImageFromCurrentImageContext.. uiimage scale retina display image capture share improve this question Switch from use of UIGraphicsBeginImageContext to UIGraphicsBeginImageContextWithOptions as documented on this page . Pass 0.0 for scale the third.. image capture share improve this question Switch from use of UIGraphicsBeginImageContext to UIGraphicsBeginImageContextWithOptions as documented on this page . Pass 0.0 for scale the third argument and you'll get a context..

UIImagePickerController camera preview is portrait in landscape app

http://stackoverflow.com/questions/538041/uiimagepickercontroller-camera-preview-is-portrait-in-landscape-app

default NSException raise NSInternalInconsistencyException format @ Invalid image orientation UIGraphicsBeginImageContext bounds.size CGContextRef context UIGraphicsGetCurrentContext if orient UIImageOrientationRight orient..

UIImage: Resize, then Crop

http://stackoverflow.com/questions/603907/uiimage-resize-then-crop

0.5 else if widthFactor heightFactor thumbnailPoint.x targetWidth scaledWidth 0.5 UIGraphicsBeginImageContext targetSize this will crop CGRect thumbnailRect CGRectZero thumbnailRect.origin thumbnailPoint thumbnailRect.size.width..

What's the easiest way to resize/optimize an image size with the iPhone SDK?

http://stackoverflow.com/questions/612131/whats-the-easiest-way-to-resize-optimize-an-image-size-with-the-iphone-sdk

this post with the relevant code UIImage imageWithImage UIImage image scaledToSize CGSize newSize UIGraphicsBeginImageContext newSize image drawInRect CGRectMake 0 0 newSize.width newSize.height UIImage newImage UIGraphicsGetImageFromCurrentImageContext..

Changing the background color of a UIAlertView?

http://stackoverflow.com/questions/883208/changing-the-background-color-of-a-uialertview

theImage stretchableImageWithLeftCapWidth 16 topCapHeight 16 CGSize theSize theAlert frame .size UIGraphicsBeginImageContext theSize theImage drawInRect CGRectMake 0 0 theSize.width theSize.height theImage UIGraphicsGetImageFromCurrentImageContext..

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

double degrees return degrees M_PI 180 The answer Daniel gave is also correct but it suffers from the problem that it is not thread safe since you're using UIGraphicsBeginImageContext . Since the above code only uses CG functions you're all set. I also have a similar function to resize and do proper aspect fill on images let me know if that's..

How to Rotate a UIImage 90 degrees?

http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees

What about something like static inline double radians double degrees return degrees M_PI 180 UIImage rotate UIImage src UIImageOrientation orientation UIGraphicsBeginImageContext src.size CGContextRef context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM context radians 90 else if orientation UIImageOrientationLeft..

Resize UIImage with aspect ratio?

http://stackoverflow.com/questions/1703100/resize-uiimage-with-aspect-ratio

UIImage with aspect ratio I'm using this code to resize an image on the iPhone CGRect screenRect CGRectMake 0 0 320.0 480.0 UIGraphicsBeginImageContext screenRect.size value drawInRect screenRect blendMode kCGBlendModePlusDarker alpha 1 UIImage tmpValue UIGraphicsGetImageFromCurrentImageContext UIGraphicsEndImageContext..

How to take a screenshot programmatically

http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically

take a screenshot programmatically I want a screenshot of the image on the screen saved into the saved photo library iphone share improve this question UIGraphicsBeginImageContext self.window.bounds.size self.window.layer renderInContext UIGraphicsGetCurrentContext UIImage image UIGraphicsGetImageFromCurrentImageContext UIGraphicsEndImageContext..

The simplest way to resize an UIImage?

http://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage

resizing options. Or you can use this utility method if you actually need to resize an image UIImage imageWithImage UIImage image scaledToSize CGSize newSize UIGraphicsBeginImageContext newSize In next line pass 0.0 to use the current device's pixel scaling factor and thus account for Retina resolution . Pass 1.0 to force exact pixel size. UIGraphicsBeginImageContextWithOptions.. newSize In next line pass 0.0 to use the current device's pixel scaling factor and thus account for Retina resolution . Pass 1.0 to force exact pixel size. UIGraphicsBeginImageContextWithOptions newSize NO 0.0 image drawInRect CGRectMake 0 0 newSize.width newSize.height UIImage newImage UIGraphicsGetImageFromCurrentImageContext UIGraphicsEndImageContext..

How to capture UIView to UIImage without loss of quality on retina display

http://stackoverflow.com/questions/4334233/how-to-capture-uiview-to-uiimage-without-loss-of-quality-on-retina-display

My code works fine for normal devices but creates blurry images on retina devices. Does anybody know a solution for my issue UIImage imageWithView UIView view UIGraphicsBeginImageContext view.bounds.size view.layer renderInContext UIGraphicsGetCurrentContext UIImage img UIGraphicsGetImageFromCurrentImageContext UIGraphicsEndImageContext return img.. UIGraphicsEndImageContext return img iphone uiimage scale retina display image capture share improve this question Switch from use of UIGraphicsBeginImageContext to UIGraphicsBeginImageContextWithOptions as documented on this page . Pass 0.0 for scale the third argument and you'll get a context with a scale factor equal.. return img iphone uiimage scale retina display image capture share improve this question Switch from use of UIGraphicsBeginImageContext to UIGraphicsBeginImageContextWithOptions as documented on this page . Pass 0.0 for scale the third argument and you'll get a context with a scale factor equal to that of the screen. UIGraphicsBeginImageContext..

UIImagePickerController camera preview is portrait in landscape app

http://stackoverflow.com/questions/538041/uiimagepickercontroller-camera-preview-is-portrait-in-landscape-app

0.0 transform CGAffineTransformRotate transform M_PI 2.0 break default NSException raise NSInternalInconsistencyException format @ Invalid image orientation UIGraphicsBeginImageContext bounds.size CGContextRef context UIGraphicsGetCurrentContext if orient UIImageOrientationRight orient UIImageOrientationLeft CGContextScaleCTM context scaleRatio..

UIImage: Resize, then Crop

http://stackoverflow.com/questions/603907/uiimage-resize-then-crop

widthFactor heightFactor thumbnailPoint.y targetHeight scaledHeight 0.5 else if widthFactor heightFactor thumbnailPoint.x targetWidth scaledWidth 0.5 UIGraphicsBeginImageContext targetSize this will crop CGRect thumbnailRect CGRectZero thumbnailRect.origin thumbnailPoint thumbnailRect.size.width scaledWidth thumbnailRect.size.height scaledHeight..

What's the easiest way to resize/optimize an image size with the iPhone SDK?

http://stackoverflow.com/questions/612131/whats-the-easiest-way-to-resize-optimize-an-image-size-with-the-iphone-sdk

this question . I had suggested the technique described in this post with the relevant code UIImage imageWithImage UIImage image scaledToSize CGSize newSize UIGraphicsBeginImageContext newSize image drawInRect CGRectMake 0 0 newSize.width newSize.height UIImage newImage UIGraphicsGetImageFromCurrentImageContext UIGraphicsEndImageContext return..

Changing the background color of a UIAlertView?

http://stackoverflow.com/questions/883208/changing-the-background-color-of-a-uialertview

UIImage theImage UIImage imageNamed @ Background.png theImage theImage stretchableImageWithLeftCapWidth 16 topCapHeight 16 CGSize theSize theAlert frame .size UIGraphicsBeginImageContext theSize theImage drawInRect CGRectMake 0 0 theSize.width theSize.height theImage UIGraphicsGetImageFromCurrentImageContext UIGraphicsEndImageContext theAlert layer..

iPhone - How do you color an image?

http://stackoverflow.com/questions/1223340/iphone-how-do-you-color-an-image

that this is actually possible. I have tried this UIImage colorizeImage UIImage baseImage color UIColor theColor UIGraphicsBeginImageContext baseImage.size CGContextRef ctx UIGraphicsGetCurrentContext CGRect area CGRectMake 0 0 baseImage.size.width baseImage.size.height.. 4. UIImage imageWithOverlayColor UIColor color CGRect rect CGRectMake 0.0f 0.0f self.size.width self.size.height if UIGraphicsBeginImageContextWithOptions CGFloat imageScale 1.0f if self respondsToSelector @selector scale The scale property is new with iOS4. imageScale.. imageScale 1.0f if self respondsToSelector @selector scale The scale property is new with iOS4. imageScale self.scale UIGraphicsBeginImageContextWithOptions self.size NO imageScale else UIGraphicsBeginImageContext self.size self drawInRect rect CGContextRef context..

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

The answer Daniel gave is also correct but it suffers from the problem that it is not thread safe since you're using UIGraphicsBeginImageContext . Since the above code only uses CG functions you're all set. I also have a similar function to resize and do proper aspect..

blend two uiimages

http://stackoverflow.com/questions/1309757/blend-two-uiimages

a foreground image where the foreground image is a transparent image with lines on it. I am trying to do it this way. UIGraphicsBeginImageContext CGSizeMake 320 480 CGContextRef context UIGraphicsGetCurrentContext create rect that fills screen CGRect bounds CGRectMake.. UIImage imageNamed @ bottom.png UIImage image UIImage imageNamed @ top.png CGSize newSize CGSizeMake width height UIGraphicsBeginImageContext newSize Use existing opacity as is bottomImage drawInRect CGRectMake 0 0 newSize.width newSize.height Apply supplied opacity..

How to Rotate a UIImage 90 degrees?

http://stackoverflow.com/questions/1315251/how-to-rotate-a-uiimage-90-degrees

inline double radians double degrees return degrees M_PI 180 UIImage rotate UIImage src UIImageOrientation orientation UIGraphicsBeginImageContext src.size CGContextRef context UIGraphicsGetCurrentContext if orientation UIImageOrientationRight CGContextRotateCTM context..

Resize UIImage with aspect ratio?

http://stackoverflow.com/questions/1703100/resize-uiimage-with-aspect-ratio

with aspect ratio I'm using this code to resize an image on the iPhone CGRect screenRect CGRectMake 0 0 320.0 480.0 UIGraphicsBeginImageContext screenRect.size value drawInRect screenRect blendMode kCGBlendModePlusDarker alpha 1 UIImage tmpValue UIGraphicsGetImageFromCurrentImageContext..

How to take a screenshot programmatically

http://stackoverflow.com/questions/2200736/how-to-take-a-screenshot-programmatically

a screenshot of the image on the screen saved into the saved photo library iphone share improve this question UIGraphicsBeginImageContext self.window.bounds.size self.window.layer renderInContext UIGraphicsGetCurrentContext UIImage image UIGraphicsGetImageFromCurrentImageContext.. 2011 for retina display change the first line into this if UIScreen mainScreen respondsToSelector @selector scale UIGraphicsBeginImageContextWithOptions self.window.bounds.size NO UIScreen mainScreen .scale else UIGraphicsBeginImageContext self.window.bounds.size..

How Do I Take a Screen Shot of a UIView?

http://stackoverflow.com/questions/2214957/how-do-i-take-a-screen-shot-of-a-uiview

iPhone app can take a screen shot of a specific UIView as a UIImage. I tried this code but all I get is a blank image. UIGraphicsBeginImageContext CGSizeMake 320 480 CGContextRef context UIGraphicsGetCurrentContext myUIView.layer drawInContext context UIImage screenShot..

The simplest way to resize an UIImage?

http://stackoverflow.com/questions/2658738/the-simplest-way-to-resize-an-uiimage

method if you actually need to resize an image UIImage imageWithImage UIImage image scaledToSize CGSize newSize UIGraphicsBeginImageContext newSize In next line pass 0.0 to use the current device's pixel scaling factor and thus account for Retina resolution ... the current device's pixel scaling factor and thus account for Retina resolution . Pass 1.0 to force exact pixel size. UIGraphicsBeginImageContextWithOptions newSize NO 0.0 image drawInRect CGRectMake 0 0 newSize.width newSize.height UIImage newImage UIGraphicsGetImageFromCurrentImageContext..

How to capture UIView to UIImage without loss of quality on retina display

http://stackoverflow.com/questions/4334233/how-to-capture-uiview-to-uiimage-without-loss-of-quality-on-retina-display

creates blurry images on retina devices. Does anybody know a solution for my issue UIImage imageWithView UIView view UIGraphicsBeginImageContext view.bounds.size view.layer renderInContext UIGraphicsGetCurrentContext UIImage img UIGraphicsGetImageFromCurrentImageContext.. return img iphone uiimage scale retina display image capture share improve this question Switch from use of UIGraphicsBeginImageContext to UIGraphicsBeginImageContextWithOptions as documented on this page . Pass 0.0 for scale the third argument and you'll.. scale retina display image capture share improve this question Switch from use of UIGraphicsBeginImageContext to UIGraphicsBeginImageContextWithOptions as documented on this page . Pass 0.0 for scale the third argument and you'll get a context with a scale factor..

Drawing waveform with AVAssetReader

http://stackoverflow.com/questions/5032775/drawing-waveform-with-avassetreader

channelCount NSInteger channelCount imageHeight float imageHeight CGSize imageSize CGSizeMake sampleCount imageHeight UIGraphicsBeginImageContext imageSize CGContextRef context UIGraphicsGetCurrentContext CGContextSetFillColorWithColor context UIColor blackColor .CGColor.. channelCount NSInteger channelCount imageHeight float imageHeight CGSize imageSize CGSizeMake sampleCount imageHeight UIGraphicsBeginImageContext imageSize CGContextRef context UIGraphicsGetCurrentContext CGContextSetFillColorWithColor context UIColor blackColor .CGColor..

UIImagePickerController camera preview is portrait in landscape app

http://stackoverflow.com/questions/538041/uiimagepickercontroller-camera-preview-is-portrait-in-landscape-app

transform M_PI 2.0 break default NSException raise NSInternalInconsistencyException format @ Invalid image orientation UIGraphicsBeginImageContext bounds.size CGContextRef context UIGraphicsGetCurrentContext if orient UIImageOrientationRight orient UIImageOrientationLeft..

UIImage: Resize, then Crop

http://stackoverflow.com/questions/603907/uiimage-resize-then-crop

targetHeight scaledHeight 0.5 else if widthFactor heightFactor thumbnailPoint.x targetWidth scaledWidth 0.5 UIGraphicsBeginImageContext targetSize this will crop CGRect thumbnailRect CGRectZero thumbnailRect.origin thumbnailPoint thumbnailRect.size.width scaledWidth..

What's the easiest way to resize/optimize an image size with the iPhone SDK?

http://stackoverflow.com/questions/612131/whats-the-easiest-way-to-resize-optimize-an-image-size-with-the-iphone-sdk

described in this post with the relevant code UIImage imageWithImage UIImage image scaledToSize CGSize newSize UIGraphicsBeginImageContext newSize image drawInRect CGRectMake 0 0 newSize.width newSize.height UIImage newImage UIGraphicsGetImageFromCurrentImageContext..

Changing the background color of a UIAlertView?

http://stackoverflow.com/questions/883208/changing-the-background-color-of-a-uialertview

theImage theImage stretchableImageWithLeftCapWidth 16 topCapHeight 16 CGSize theSize theAlert frame .size UIGraphicsBeginImageContext theSize theImage drawInRect CGRectMake 0 0 theSize.width theSize.height theImage UIGraphicsGetImageFromCurrentImageContext..