Add Image on another Image in iOS considering alpha parts [duplicate] - ios

This question already has answers here:
Overlay an image over another image in iOS
(4 answers)
Closed 9 years ago.
I have tried, compositing filters, both ATop and Over, But did not get the required Image as out put.
what I want is something like this:
NOTE: both the Image1 and Border are png Images.
Now what i am getting is either the border1 image or the image1 image, it seems they are not considering the alpha parts in border1 image, its removing the alpha channel and am left with a white background under the border image instead of image 1 peeking out.
Any idea about how to proceed? thanks in advance.

Use the UIImage converted to CIImage with data as png, with this following code
CIImage *paper1 =[CIImage imageWithData:UIImagePNGRepresentation([UIImage imageNamed:#"yourPNGImage.png"])];
This Solves the problem, since earlier times the UIImage (though in .png format) was getting converted into a jpeg format CIImage.

Related

Problem to set a custom image to TabBarItem [duplicate]

This question already has answers here:
How can I remove the blue square that overlays UITabBarItem when selected?
(3 answers)
Closed 4 years ago.
I've a image 30x30 and I want set like TabBarItem in my TabBar. But when I set the result is this:
The large blue square appears instead my image.
Did you check your image file name? Becuase I had exactly same experience and it was imge file name did not match with the name I put on storyboard
Make sure your image is single-color, preferably black and white. If there's a background, even one with a low alpha, you may get this effect. The OS is trying to make an iOS-style tab bar image (think of the ones in the Music app), which is single color. It converts the non-transparent pixels to blue, and the transparent ones to white/clear. If the entire image is non-transparent, you'll end up with that.

Importing a Sketch Image into Xcode (Using UIBarButtonItem) [duplicate]

This question already has an answer here:
UIBarButtonItem showing up as a blue square instead of the image I want (Interface Editor)
(1 answer)
Closed 6 years ago.
I am trying to put a Sketch image into a UIBarBuuttonItem. The image has a transparent background and the image is a camera that is blue with a white circle inside. I am sure I'm exporting the entire image. I am using a 1x, 2x, and 3x version of the image and when I set the image of a UIBarButtonItem in the storyboard, it only shows the blue part of the camera and not the white circle inside. If I put a UIImage in a ViewController and set it to the same image, the image shows up correctly. The image shows the difference. Thanks in advance]1
In your image in xcasset, try change it's render to Original image in attribute inspector, maybe the issue is the tint color

iOS - Save UIImage as a greyscale JPEG

In my app, I convert and process images.
from colour to greyscale, then doing operations such as histogram-equalisation, filtering, etc.
that part works fine.
my UIImage display correctly, I also save them to jpeg files and it works.
The only problem is that, although my images are now greyscales, they are still saved as RGB jpegs. that is the red, green and blue value for each pixel are the same but it still waste space to keep the duplicated value, making the file size higher than it could be.
So when i open the image file in photoshop, it is black & white but when I check "Photoshop > Image > Mode", it still says "RGB" instead of "Greyscale".
Anyone know how to tell iOS that the UIImageJPEGRepresentation call should create data with one channel per pixel instead of 4?
Thanks in advance.
You should do an explicit conversion of your image using CGColorSpaceCreateDeviceGray() as color space which is 8 bits per component, 1 channel.

Reduce image size while saving UIImage [duplicate]

This question already has answers here:
How to easily resize/optimize an image size with iOS?
(18 answers)
Closed 9 years ago.
I have image with only red and white color. In image processing, we can reduce image from 24 bit to 8 bit or something like that.
Is it possible to reduce image size? In my iPad application, I can save image as png or jpeg. But I want to reduce the size more. How should I write code?
Have you looked into the method UIImageJPEGRepresentation? Once you have your UIImage you just need to do something like:
NSData* imgData = UIImageJPEGRepresentation(myImage, 0.4); //0.4 is the compression rate.
[imgData writeToURL:myFileURL atomically:YES];

Convert apng to gif with sufficiant resolution and color depth

I want to convert some animated PNG (APNG) images to animated GIF. I can successfully convert with a utility I found on the web called apng2gif. Expertly named if I may say. The problem is it does not convert the images with sufficient color depth so the output is a little bit to pixelated and not so smooth relative to the original.
Does anyone know of any other image converters that might convert APNG to GIF with more that 16 bit color depth?
The problem is not with the converter, but with GIF format itself:
http://en.wikipedia.org/wiki/Graphics_Interchange_Format
The format supports up to 8 bits per pixel thus allowing a single image to reference a palette of up to 256 distinct colors.
If you need the GIF to blend better with the background, click on Settings button in apng2gif and then choose the background color you want.

Resources