对照片的过滤有效,但我遇到了这个问题。
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
{
// some code here...
var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
if (result.Succeeded)
{
// Email confirmation of password reset
await EmailHelper.SendReset(model.Email);
return RedirectToAction("ResetPasswordConfirmation", "Account");
}
let originalImage = CIImage(image: imageView.image)
var filter = CIFilter(name: "CIPhotoEffectMono")
filter.setDefaults()
filter.setValue(originalImage, forKey: kCIInputImageKey)
var newImage = UIImage(CIImage: filter.outputImage)
imageView.image = newImage
BSXPCMessage received error for message: Connection interrupted
然后应用程序崩溃。
我如何解决它和错误?
答案 0 :(得分:1)
试试这个:
let originalImage = CIImage(image: imageView.image)
var filter = CIFilter(name: "CIPhotoEffectMono")
filter.setValue(originalImage, forKey: kCIInputImageKey)
let context = CIContext(options:nil)
let ouputImage = context.createdCGImage(filter,fromRect:filter.extend())
var newImage = UIImage(CGImage: ouputImage)
imageView.image = newImage
答案 1 :(得分:1)
您的代码运行正常。当你调用它时,你的图像源imageView.image可能是零。你可以在游乐场试试这个:
Set F = Me.Subform.Form
Set RS = F.RecordsetClone
RS.MoveFirst
' goto first selected record
RS.Move F.SelTop - 1
' loop over all selected records
For i = 1 To F.SelHeight
' do something with fields from RS
RS.MoveNext
Next i
答案 2 :(得分:0)
Updated
let originalImage = CIImage(image: imageView.image)
var filter = CIFilter(name: "CIPhotoEffectMono")
filter.setValue(originalImage, forKey: kCIInputImageKey)
let context = CIContext(options: [kCIContextUseSoftwareRenderer: true])
let outputImage = context.createCGImage(filter.outputImage, fromRect: filter.outputImage.extent())
var newImage = UIImage(CGImage: outputImage)
imageView.image = newImage
*Based on Lamar's code.
CIContext(options: nil)
was causing BSXPCMessage received error for message: Connection interrupted
error.
SO replace:
CIContext(options: nil)
with CIContext(options: [kCIContextUseSoftwareRenderer: true])
Thanks For The Help:
Lamar
The app doesn't crash anymore.
答案 3 :(得分:0)
**I have added Black n White Effect To an Image**
UIGraphicsBeginImageContext(clickedImage.bounds.size)
clickedImage.layer.renderInContext(UIGraphicsGetCurrentContext())
var image2: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
origionalimage=image2;
var CIfilterName = "CIPhotoEffectTonal"
let ciContext = CIContext(options: nil)
let startImage = CIImage(image: image2)
let filter = CIFilter(name: CIfilterName)
filter.setDefaults()
filter.setValue(startImage, forKey: kCIInputImageKey)
let filteredImageData = filter.valueForKey(kCIOutputImageKey) as! CIImage
let filteredImageRef = ciContext.createCGImage(filteredImageData, fromRect: filteredImageData.extent())
var newImage = UIImage(CGImage: filteredImageRef)!
self.mediaData = UIImagePNGRepresentation(newImage )
self.videoThumbData = UIImageJPEGRepresentation(image2, 0.1)
self.clickedImage.image = newImage;