path of UIImage for figure inside png - iphone

i have png, which have clear background with difficult figure inside, like animal. For me is necessary to get path of this figure exactly, to draw it on background image.
Can u suggest any way to do it programmatically?

Use png alpha channel to create a mask for the background image. There is a more detailed discussion about this here.

Related

How to merge an image to fill in other image with shape?

I want to merge an image to another image in one shape. Example:
1- People image
2- Shape Image:
So how to do draw that. I already implement for merging but it's not fill to that shape.
It's possible to do this using the masking functions in the Quartz 2D framework. It's a little bit more involved than using the higher level image functions of UI Kit, but Quartz 2D gives you a lot more power to do cool graphics techniques.
The relevant Apple Developer guide to this can be found here: https://developer.apple.com/library/mac/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/dq_images.html
For this example, you'd want to create a mask shape for the inside part of the shape image. There are two ways you can do this. One way is to use image editing software to create a second mask image, with the same size as your shape image, with pure black in the area where you want the people image to appear, and white where you don't want to appear. In this example, that would be the area inside the blue shape. It is important to not crop this image, or else they won't match up exactly.
The other way to create the masking image would be to do that dynamically based on the shape image, and honestly, this is the way I would do it. This would mean that you're including fewer images in your app, and if you made any changes to the shape image, you wouldn't have to recreate the mask image as well. You could do this by making a small change to the way your shape image is formatted. You would need to use a format that allows transparency - png is preferred - so that there is alpha transparency in the part of the image outside of the shape, which is white in your JPEG image. Make sure the section in the center of the image is white (really, any color that is NOT USED in the wanted part of the shape image would work, but I'll say white for this example) and that you don't have parts of it that aren't pure white after image compression.
You will then use Quartz to select the area that's white, and create a mask from that. This technique is a bit more involved, but what you need can be found in the document I linked to above. Because of this, you might start with a static masking image, and then convert to the more involved technique after you've got the code to make the first technique work.
When you have your masking image, you would create the mask itself with the function CGImageMaskCreate(::::::::). You can then apply the mask to the people image using the function CGImageCreateWithMask(::), which will give you an image with the person's portrait, with the correct shape cropped from the center.
Finally, you would display this in your app by placing the masked people image on top of the shape image, and voila, you'll have what you're looking for.
Also, keep in mind, when using the Quartz 2D framework, you'll have to make sure you release images when they are no longer needed, or else you could have memory leaks.

process brightness on specific part of image

I am creating an application in which i am displaying image view with image and processing brightness on the image using slider. I want that brightness should be done only on the selected part of image and not on the entire image.
I want the brightness should be processed only on the central part of the image without using openGl Image processing.
Please help me to solve this problem. Hey guys Please help me its important for me.
There are several ways to accomplish this. One is to overide the drawRect: UIView method and use a mask. Another is to draw the bitmap yourself in a CGContext. Yet another is with OpenGL.
What have you tried?

How to copy arbitrary path from one UIImage to another

I'm new to iPhone graphics and it's a bit daunting.
The problem: I have UIImageA, and UIImageB. Both are the same picture, except UIImageB has all the pixels values darkened.
I'd like to copy an arbitrary piece of UIImageA onto the top of UIImageB. The end result would be a dark image, with the part of the original image bright.
My guess is that I will need to:
Create a "path" that is the arbitrary shape to copy. I think I can figure this out.
Take UIImageA and somehow crop it or mask it to the path.
Copy the part of UIImageA onto UIImageB at the exact same position.
It's steps 2 and 3 that have me confused. I've seen many examples of cropping images to a rectangle, or masking images with another pre-defined image, but nothing that exactly does this.
Does anyone have any general pointers?
You could try Core Image.
You can do all that with CGImage in your environment. You can
use a bitmap or layer context and then later render it on whatever view
you wish.
There is a good Core Graphics Quartz tutorial at
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html

Can i specify a color to be transparent

I have a UIImage, the background of it is white. I want the background of this UIImage to be transparent to its parent view. Is this possible?
One word answer- No. As robin said you have to use photo editing softwares to accomplish that. it cannot be done iphone(easily)..
I am not going to suggest that it is easy, but you should take a look at CGImageCreateWithMaskingColors, which is described in the Quartz 2D Programming Guide: Bitmap Images and Image Masks
You can't specify the transparency of a color from an image, but you could make a PNG image which has a transparency in the places you want it to be transparent.

Show photo with SCRATCH OUT EFFECT by finger

I need your help to know how to create an iPhone application to show a photo with SCRATCH OUT EFFECT.
Something like the effect in this flash tutorial
http://www.tutorial5.com/content/view/115/46/
Please help.
Thanks.
You can have a look at the following post on how to create a blurred image effect, I don't think it's the best & fasted method, but it might get you started:
UIImage blur
You can implement the scratch out effect by using CoreGraphics.
Subclass UIView for the scratchable image.
Draw the scratchable image, use a mask to cut out the parts of the image that gets "scratched".
Each time the user scratches the image, make it so the mask and the image gets updated.
Full code example on github