I have a uiimageView containing the text like this.
I want to set the image background of the text to look like this instead.
Please help me! Thanks!
You will need to combine an image of the text with the background image (the stuff that is supposed to fill the inside of the text) using compositing. Take a look at the various blend modes you can use, or look into the use of CIFilter.
http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/doc/c_ref/CGBlendMode
https://developer.apple.com/library/mac/#documentation/graphicsimaging/Reference/CoreImageFilterReference/Reference/reference.html
The thing in the background looks like it might be a gradient. Again, you can use a CIFilter to generate that gradient, or you can use Core Graphics. So you'll composite the drawn text with its fill image, then you'll draw that over a gradient.
instead of text in black solid color, make image with transparent text and outer region as the grey gradient you want and put this image over you background image, you will get the desired result.
Related
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.
I have two identical sized images that I would like to work with. One image is in color, the other is in black and white. I need assistance on stacking the color image directly over the black and white image. After that, I would like to be able to remove sections of the top photo to reveal the image underneath.
Can someone point me in the right direction on how to accomplish this?
Here is something that may help:
http://forums.devshed.com/php-development-5/how-do-i-merge-various-images-into-one-using-gd-502604.html
Especially the part that talks about adding watermarking.
You will have to add transparent areas to the top image before combining them.
lee
I realised that all my png images are defined with a transparent color instead of white color. I never noticed because the background of my app was white but now is of a different color. And as I cannot edit each single png file to replace the transparent color to white, I am looking for a simple programmatic way of replacing on the fly the transparent color by a white color. How should I do this please?
Thanks for any help
Cheers,
geebee
If I understand what you're trying to do, I would suggest you add a white background to your UIImageViews.
self.myImageView.backgroundColor = [UIColor whiteColor];
I don't see why you can't just "edit each single png file"; it's a pretty much instant batch operation using GraphicConverter or ImageMagick or whatever.
If you really insist on compensating for this on the device when the image loads, then just draw the image onto a white opaque rectangle and use the resulting composite image.
I'd like to have a splash screen with some image animation.
The image is of the letter 'N' which needs to be filled with a single color in a fashion that makes each line (out of the 3) fill on its turn.
Is there a more elegant way than using UIImageAnimation?
EDIT:
Take this image for example: http://image.shutterstock.com/display_pic_with_logo/64282/64282,1224026572,14/stock-photo-christmas-green-snowflake-capital-letter-n-18910459.jpg
Think of that green filling as what needs to be animatedly filled.
You could use a CAShapeLayer to animate the drawing of text. I could give you an example, but to be honest Ole Begemann has an awesome example:
http://oleb.net/blog/2010/12/animating-drawing-of-cgpath-with-cashapelayer/
I want to create a dark grill texture that fades to black for a configuration screen under a page curl effect.
Garmin StreetPilot Onboard uses something like this:
http://www.pcmag.com/slideshow_viewer/0,3253,l%253D286397%2526a%253D286507%2526po%253D7,00.asp?p=n
How do I programmatically create a background such as this? I really don't want to include an image the size of the iPhone screen; this seems the lazy approach.
I would create it in two parts. First, draw a gradient using the normal quartz drawing functions. Then, add an overlay with a repeating pattern of dots. These dots could be a small PNG file that is tiled, or you could use quartz to draw them.
See the documentation for CGContextDrawLinearGradient and [UIColor initWithPatternImage:]