ciimage

Getting a CGImage from CIImage

房东的猫 提交于 2019-11-30 17:17:27
I have a UIImage which is loaded from a CIImage with: tempImage = [UIImage imageWithCIImage:ciImage]; The problem is I need to crop tempImage to a specific CGRect and the only way I know how to do this is by using CGImage . The problem is that in the iOS 6.0 documentation I found this: CGImage If the UIImage object was initialized using a CIImage object, the value of the property is NULL. A. How to convert from CIImage to CGImage? I'm using this code but I have a memory leak (and can't understand where): +(UIImage*)UIImageFromCIImage:(CIImage*)ciImage { CGSize size = ciImage.extent.size;

Can't extract UIImage from CIImage with CIFilter

泪湿孤枕 提交于 2019-11-30 08:52:35
问题 I have this new iOS 8 Swift project and in one of its view controllers I have to set the image. However, I wanna change the contrast of the image using CIFilter before sending it to the view: So this is my code: view = UIImageView(frame:CGRectMake(0, 0, 200, 200)) var lecturePicture = UIImage(named: "placeholder") var beginImage = lecturePicture?.CIImage var controlsFilter = CIFilter(name: "CIColorControls") controlsFilter.setValue(beginImage, forKey: kCIInputImageKey) controlsFilter.setValue

How to blur an existing image in a UIImageView with Swift?

谁说胖子不能爱 提交于 2019-11-30 04:51:07
The setup is simple. A ViewController with UIImageView that has an image assigned. A UIButton that when clicked blurs the image in the UIImageView. import UIKit class ViewController: UIViewController { @IBOutlet weak var bg: UIImageView! @IBAction func blur(_ sender: Any) { let inputImage = CIImage(cgImage: (bg.image?.cgImage)!) let filter = CIFilter(name: "CIGaussianBlur") filter?.setValue(inputImage, forKey: "inputImage") filter?.setValue(10, forKey: "inputRadius") let blurred = filter?.outputImage bg.image = UIImage(ciImage: blurred!) } } When the button is clicked the screen just turns

Interpret XMP-Metadata in ALAssetRepresentation

南楼画角 提交于 2019-11-29 20:24:53
When a user makes some changes (cropping, red-eye removal, ...) to photos in the built-in Photos.app on iOS, the changes are not applied to the fullResolutionImage returned by the corresponding ALAssetRepresentation . However, the changes are applied to the thumbnail and the fullScreenImage returned by the ALAssetRepresentation . Furthermore, information about the applied changes can be found in the ALAssetRepresentation 's metadata dictionary via the key @"AdjustmentXMP" . I would like to apply these changes to the fullResolutionImage myself to preserve consistency. I've found out that on

CIImage memory leak

拥有回忆 提交于 2019-11-29 12:01:43
I'm using the below method to blur some images. Using instruments the CIImage's are leaking. I tried wrapping them in an @autoreleasepool, but no luck. Any ideas? -(UIImage *)blurImage:(UIImage *)image withStrength:(float)strength { @autoreleasepool { CIContext *context = [CIContext contextWithOptions:nil]; CIImage *inputImage = [[CIImage alloc] initWithCGImage:image.CGImage]; CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"]; [filter setValue:inputImage forKey:@"inputImage"]; [filter setValue:[NSNumber numberWithFloat:strength] forKey:@"inputRadius"]; CIImage *result = [filter

Cropping CIImage

陌路散爱 提交于 2019-11-29 07:57:30
I have a class that takes an UIImage , initializes a CIImage with it like so: workingImage = CIImage.init(image: baseImage!) Then the image is used to cut out 9 neighbouring squares in a 3x3 pattern out of it - in a loop: for x in 0..<3 { for y in 0..<3 { croppingRect = CGRect(x: CGFloat(Double(x) * sideLength + startPointX), y: CGFloat(Double(y) * sideLength + startPointY), width: CGFloat(sideLength), height: CGFloat(sideLength)) let tmpImg = (workingImage?.cropping(to: croppingRect))! } } Those tmpImgs are inserted into a table and later used, but thats besides the point. This code works on

Swift Cannot remove CIFIlter from UIImage

↘锁芯ラ 提交于 2019-11-28 14:29:05
been working on swift for a bit now and having trouble tackling this Core Image Framework. I was able to successfully create a CIFilter over an image however I'm not sure how to delete it. The Image Is placed over a UIView which resembles that of snapchat's camera screen and then there is an imageview which is a subview of the uiview that the image is previewed on. BTW Using The most up to date version of Xcode and iOS as well. Here is the code for when the black and white filter is applied: @IBAction func BW_Flt_Bt_Tapped(sender: UIButton) { let beginImage = CIImage(image: imagePreview.image!

CIDetector isn't releasing memory

和自甴很熟 提交于 2019-11-28 12:15:23
I'm using CIDetector as follows multiple times: -(NSArray *)detect:(UIImage *)inimage { UIImage *inputimage = inimage; UIImageOrientation exifOrientation = inimage.imageOrientation; NSNumber *orientation = [NSNumber numberWithInt:exifOrientation]; NSDictionary *imageOptions = [NSDictionary dictionaryWithObject:orientation forKey:CIDetectorImageOrientation]; CIImage* ciimage = [CIImage imageWithCGImage:inputimage.CGImage options:imageOptions]; NSDictionary *detectorOptions = [NSDictionary dictionaryWithObject:orientation forKey:CIDetectorImageOrientation]; NSArray* features = [self.detector

Unable to convert CIImage to UIImage in Swift 3.0

别说谁变了你拦得住时间么 提交于 2019-11-28 09:54:11
I am making image form QR Code by using following code: func createQRFromString(str: String) -> CIImage? { let stringData = str.dataUsingEncoding(NSUTF8StringEncoding) let filter = CIFilter(name: "CIQRCodeGenerator") filter?.setValue(stringData, forKey: "inputMessage") filter?.setValue("H", forKey: "inputCorrectionLevel") return filter?.outputImage } And Then I am adding to UIImageView Like this: if let img = createQRFromString(strQRData) { let somImage = UIImage(CIImage: img, scale: 1.0, orientation: UIImageOrientation.Down) imgviewQRcode.image = somImage } Now I need to save this to a JPEG

CIImage memory leak

a 夏天 提交于 2019-11-28 05:50:33
问题 I'm using the below method to blur some images. Using instruments the CIImage's are leaking. I tried wrapping them in an @autoreleasepool, but no luck. Any ideas? -(UIImage *)blurImage:(UIImage *)image withStrength:(float)strength { @autoreleasepool { CIContext *context = [CIContext contextWithOptions:nil]; CIImage *inputImage = [[CIImage alloc] initWithCGImage:image.CGImage]; CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"]; [filter setValue:inputImage forKey:@"inputImage"];