Hi all,I'm trying to move app from Android to iOS but I'm finding some difficulties with image transformation...The app is about image filtering and I found all the equivalent codes for brightness, saturation, contrast, etc. ColorMatrix but I have problems trying to colorize the image.In Android I used the next code:public static Bitmap doNalaFilter (Bitmap src) {
Bitmap bmBrown0 = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
Canvas cBrown0 = new Canvas(bmBrown0);
Paint paintBrown0 = new Paint();
paintBrown0.setColorFilter(new LightingColorFilter(Color.WHITE, 0x800000));
cBrown0.drawBitmap(src, 0, 0, paintBrown0);
Bitmap bmBrown = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
Canvas cBrown = new Canvas(bmBrown);
cBrown.drawBitmap(src, 0, 0, null);
Paint paintBrown = new Paint();
paintBrown.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
cBrown.drawBitmap(bmBrown0, 0, 0, paintBrown);
return bmBrown;
}Which results in a new image with high brown tones.In Swift I'm trying the next code:func nalaFilter() -> UIImage? {
let inImage = CIImage (image: self)
let SRGBImage = inImage?.applyingFilter("CILinearToSRGBToneCurve")
dynamic let brownMatrix = CIFilter (name: "CIMultiplyBlendMode")
let brownRect = CGRect (
x: (SRGBImage?.extent.origin.x)!,
y: (SRGBImage?.extent.origin.y)!,
width: (SRGBImage?.extent.size.width)!,
height: (SRGBImage?.extent.size.height)!)
let brownColor = CIColor (red: 128.0/255.0, green: 0.0, blue: 0.0)
let brownOverlay = CIImage (color: brownColor)
let brownCroppedImage = brownOverlay.cropped(to: brownRect)
brownMatrix?.setValue(SRGBImage, forKey: kCIInputImageKey)
brownMatrix?.setValue(brownCroppedImage, forKey: kCIInputBackgroundImageKey)
let brownOutImage = brownMatrix?.outputImage
let linearImage = brownOutImage?.applyingFilter("CISRGBToneCurveToLinear")
let cgImage = CIContext().createCGImage(linearImage!, from: linearImage!.extent)
return UIImage (cgImage: cgImage!)
}Which results in the original image with like a really really dark brown crystal on it...I can't find the equivalent code and it's so frustrating because I've tryed even all CICategoryCompositeOperation in my brownMatrix.Thanks in advance!
Post
Replies
Boosts
Views
Activity
I'm trying to implement IAP to my app preparing all the code in Swift based in non consumable purchases. Before launching the update I'm thinking about offer like a free reward to some users who help me to promote the app...
For example: My app is based on free filters for photo editing and I would like to implement some new filters to be purchased by 0,99€. Once launched the updated, I'm thinking about asking some Instagramers to promote the app and give to them these filters by free as reward.
Does anyone know if it's possible or permitted on App Store Connect? And if is any code adaptation required in order to prepare the app?
Thank you in advance!