How Change Kciinputbrightnesskey Using Slider Value in Swift, I'm Getting Either White or Black Picture Whatever Value the Slider Get

How change kCIInputBrightnessKey using slider value in Swift, I'm getting either white or black picture whatever value the slider get

The reason is that the filter works every time in the result image produced from the previous slider changed value , here because of this line

let beginImage = CIImage(image: self.myImageView.image!)

so you need to reset the imageView's image top of the function by adding this line

self.myImageView.image = UIImage(named:"girl")

//

 @IBAction func changeContrast(_ sender: UISlider) {
self.myImageView.image = UIImage(named:"girl")
let beginImage = CIImage(image: self.myImageView.image!)
self.filter = CIFilter(name: "CIColorControls")
self.filter?.setValue(beginImage, forKey: kCIInputImageKey)
self.filter.setValue(sender.value, forKey: kCIInputBrightnessKey)
print("Current value of the slider - \(sender.value)")
self.filteredImage = self.filter?.outputImage
self.myImageView.image = UIImage(cgImage: self.context.createCGImage(self.filteredImage!, from: (self.filteredImage?.extent)!)!)
}

Sample Image

Also minimum slider value should be 0 and maximum 1

CIColorControls & UISlider w/ Swift 4

The problem is this line:

previewImage.image = UIImage(ciImage: filteredImage)

You cannot magically make a UIImage out of a CIImage by using that initializer. Your image view is coming out empty because you are effectively setting its image to nil by doing that. Instead, you must render the CIImage. See, for example, my answer here.

(Apple claims that the image view itself will render the CIImage in this configuration, but I've never seen that claim verified.)

However, we might go even further and point out that if the goal is to allow the user to move a slider and change the brightness of the image in real time, your approach is never going to work. You cannot use a UIImageView at all to display an image that will do that, because every time the slider is moved, we must render again, and that is really really slow. Instead, you should be using a Metal view to render into (as described in my answer here); that is the way to respond in real time to a CIFilter governed by a slider.

Find two consecutive rows

Assuming the rows have sequential IDs, something like this may be what you're looking for:

select top 1 * 
from
Bills b1
inner join Bills b2 on b1.id = b2.id - 1
where
b1.IsEstimate = 1 and b2.IsEstimate = 1
order by
b1.BillDate desc


Related Topics



Leave a reply



Submit