iOS 8 GPUimage crash in custom photo extension - ios8

In my finishContentEditingWithCompletionHandler method for my photo editing extension I am able to correctly filter with GPUimage and save images that are NOT taken by the camera. But when I take a picture with the camera and then use my photo editing extension and hit "Done" the extension just sits there on a blank screen with the activity spinner going. Has anyone else encountered this issue? I am using GPUImage to filter my images.

I have had similar issues with my custom photo extension. Through some investigation, I found that only images with UIImageOrientation.Up would be filtered correctly and written back correctly. I ended up removing the orientation information for the UIImage and it works for me for all image orientations.
// Remove orientation information
UIGraphicsBeginImageContextWithOptions(finalFilteredImage.size, true, finalFilteredImage.scale)
finalFilteredImage.drawInRect(CGRectMake(0, 0, finalFilteredImage.size.width, finalFilteredImage.size.height))
let finalImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();

Related

How can we merge multiple image into single image in react native project

In one of my project I am using RNCamera for capturing image. Also the camera screens have custom components. One of the component showing with camera is compass image. I need to merge the compass image with the captured image.
I have tried this library react-native-view-shot. Wrapping the RNCamera inside the view shot view. But the result contains only the captured image without compass.
I have also tried react-native-images-combine. Here the second image is always positioning at the left side of the first image.
I looking for a better solution. Can anyone suggest a way to fix this in react-native. It would be great. Thank you.
Try to put both images in a View tag and each image in an own View tag. Than give “z-index” style property to put your image above.
Let me know!

Pinch to zoom gesture working perfectly on ipad2 but not on retina iPad?

The title of the question speaks itself. For more assistance I would like to tell that my app has been developed using the Apple Photo Scroller(A modification of Apple's PhotoScroller sample code to load the UIPageViewController inside a UIViewController subclass
), with multiple image galleries. The problem is the pinch-to-zoom functions perfectly on ipad2 but not on retina iPads. My images are of size 2048x1536.
Can anybody tell me why the zoom is not working on retina iPads?
I would start by checking that the contentScaleFactor is set to 1.
From PhotoScroller's TilingView.m file:
// to handle the interaction between CATiledLayer and high resolution screens, we need to
// always keep the tiling view's contentScaleFactor at 1.0. UIKit will try to set it back
// to 2.0 on retina displays, which is the right call in most cases, but since we're backed
// by a CATiledLayer it will actually cause us to load the wrong sized tiles.
//
- (void)setContentScaleFactor:(CGFloat)contentScaleFactor
{
[super setContentScaleFactor:1.f];
}
See these related questions and answers here and here for more info on contentScaleFactor.

Displaying landscape images from camera roll xcode

I'm pulling images from the camera roll to display in my app, and portrait taken pictures work just fine, but landscape images get all funky smushed together.
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
displayPhoto.image = image;
I've figured out how to check the length and width of the pictures themselves, and therefore can do an if else statement to only rotate landscape pictures... but trying to find working code to actually rotate the images is difficult. I found an answer here, but he's calling functions that don't exist, and clearly the code did not work for me :p. Any assistance would be greatly appreciated. Thanks.
u have to use
[displayPhoto setContentMode:UIViewContentModeScaleAspectFit];

Why is local image turned 90 degrees on UIWebView

I have an application that is set in landscape mode because of the content it contains. One of the things I want to do is take a picture of a piece of paper. I present the UIImagePickerController locked in portrait mode because it fits the paper size. After the user takes the picture I load that image as a background on a UIWebView. The reason I use a webview is because sometimes I need to load a .pdf there as well. Anyway, I'm setting the background using CSS. Here is the code...
//img is the path to an image.
myHtml = [NSString stringWithFormat:
#"<html><head>"
"</head>"
"<body><img src='%#'></body></html>", img];
[resume loadHTMLString:myHtml baseURL:baseURL];
The problem is, the image is displayed in landscape when the app returns to the UIWebView. Everything else is normal as far as text etc. Is there some reason that images are rotated 90 degrees to fit properly or something? I have tried pretty much everything with no luck.
The other thing is that we I retake a picture and reload the webView the old image remains.
You need to change the orientation of the image from its exif header if there is orientation info available in it. Identifying the picture orientation is the hard part, rotation of imgs can be done easily using css -webkit-transform: rotate(-90deg);
It does have to do with the exif data. While using a webkit transform may be ok for use in just the web view once, if you want to use the image later and have it always be the right orientation I'd use the categories given here:
http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
The article does a great job explaining exactly why the rotation occurs and the code does a nice job of 'fixing' the 'problem' so that you can then make use of the image without having to do extra things or worry about whether it'll be displayed correctly (even though the UIImageView takes the orientation into account).
You can resize with this to the same size it originally was, and it should fix the orientation issue.

Replicate photo booth screen flash in cocoa

I am trying to replicate a screen flash effect in a mac cocoa application similar to that of the Photo Booth.
A white layer is overlayed on the screen and the brightness of the screen fades really bright and then down again.
Can anyone give me some advice on how this can be replicated in Cocoa?
Thanks
I suggest using the CGDisplayFade API of Quartz Display Services.
It's very easy to use and no "hacking" with fake fullscreen windows or views is required.
See here: Quartz Display Services Reference
A simple implementation would look like this:
-(void)flashScreenUsingFlashColor:(NSColor *)flashColor
inDuration:(NSTimeInterval)inDuration
outDuration:(NSTimeInterval)outDuration{
CGDisplayFadeReservationToken fadeToken;
NSColor *colorToUse = [flashColor colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
CGError error = CGAcquireDisplayFadeReservation (inDuration + outDuration, &fadeToken);
if (error != kCGErrorSuccess){
NSLog(#"Error aquiring fade reservation. Will do nothing.");
return;
}
CGDisplayFade (fadeToken, inDuration, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, colorToUse.redComponent, colorToUse.greenComponent, colorToUse.blueComponent, true);
CGDisplayFade (fadeToken, outDuration, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal,colorToUse.redComponent, colorToUse.greenComponent, colorToUse.blueComponent, false);
}
You could take a look at this tutorial for creating a full screen window. Just make it white and the use Core Animation to fade it in and out. For example: [[MyFullScreenWindow animator] setAlphaValue:0.0]; will fade it out.

Resources