colormatrixfilter

Using CIColorMatrix filter in Swift

痴心易碎 提交于 2020-12-10 04:55:22
问题 The following Swift func is supposed to tint a greyscale image 'greyImage' using specified 'tintColor': import UIKit func colorizeImage(greyImage : UIImage, tintColor : UIColor) -> UIImage? { let colorMatrixFilter = CIFilter(name: "CIColorMatrix") var r:CGFloat = 0 var g:CGFloat = 0 var b:CGFloat = 0 var a:CGFloat = 0 tintColor.getRed(&r, green:&g, blue:&b, alpha:&a) colorMatrixFilter.setDefaults() colorMatrixFilter.setValue(greyImage, forKey:"inputImage") //kCIInputImageKey)

Using CIColorMatrix filter in Swift

让人想犯罪 __ 提交于 2020-12-10 04:52:43
问题 The following Swift func is supposed to tint a greyscale image 'greyImage' using specified 'tintColor': import UIKit func colorizeImage(greyImage : UIImage, tintColor : UIColor) -> UIImage? { let colorMatrixFilter = CIFilter(name: "CIColorMatrix") var r:CGFloat = 0 var g:CGFloat = 0 var b:CGFloat = 0 var a:CGFloat = 0 tintColor.getRed(&r, green:&g, blue:&b, alpha:&a) colorMatrixFilter.setDefaults() colorMatrixFilter.setValue(greyImage, forKey:"inputImage") //kCIInputImageKey)

Saving Bitmap drawn on Canvas

◇◆丶佛笑我妖孽 提交于 2019-12-25 02:19:34
问题 In my application I extended the ImageView and overriden its onDraw() method. I am using a color filter to manipulate the bitmap for adding some effects like invert, grayscale etcc. After drawing the bitmap I am trying to save it but I am only able to save the original bitmap with no added effects. Here is the code for onDraw() and save method: protected void onDraw(Canvas canvas) { Paint paint = mPaint; //cmf is the color matrix filter paint.setColorFilter(cmf); if(mBitmap != null) { canvas

how do I color all pixels that are NOT transparent to black

冷暖自知 提交于 2019-12-11 00:26:28
问题 I am using ColorMatixFilter on an Image in Flex. I am really close to getting want I need out of the filter. Basically any PNG file the user uploads I want all pixels that are not transparent to be colored black. I have a function that sets the "brightness" already so I just through a really large negative number at it like -1000 and it does the job but the problem is any pixels that have any alpha to them, say 0.9 or below all end up being white when I encode my PNG file on the server later.

Adjusting Lightness using ColorMatrix

人盡茶涼 提交于 2019-12-05 06:38:23
问题 I'm trying to adjust the lightness of an image (You can see this option in Photoshop when trying to adjust the Hue, also lightness and brightness are two different features) using ColorMatrix but am lost on which values to change to achive this. Currently I'm able to change the Hue using this code public static void adjustHue(ColorMatrix cm, float value) { value = cleanValue(value, 180f) / 180f * (float) Math.PI; if (value == 0) { return; } float cosVal = (float) Math.cos(value); float sinVal

Adjusting Lightness using ColorMatrix

牧云@^-^@ 提交于 2019-12-04 12:21:55
I'm trying to adjust the lightness of an image (You can see this option in Photoshop when trying to adjust the Hue, also lightness and brightness are two different features) using ColorMatrix but am lost on which values to change to achive this. Currently I'm able to change the Hue using this code public static void adjustHue(ColorMatrix cm, float value) { value = cleanValue(value, 180f) / 180f * (float) Math.PI; if (value == 0) { return; } float cosVal = (float) Math.cos(value); float sinVal = (float) Math.sin(value); float lumR = 0.213f; float lumG = 0.715f; float lumB = 0.072f; float[] mat