Watermark on a UIImage with auto contrast? - iphone

I want to put a watermark on a UIImageView. I have two watermark images, a black one and a white one. I want to put the black one on the UIImageView when the area of the watermark is bright, and the white one on the UIImageView when the area of the watermark is dark. How to do that?
Any help would be appreciated.

Perhaps you should consider having a single watermark that looks ok on all backgrounds, like a transparent white with opacity or grey color with a drop shadow. This seems like less hassle than trying to programmatically determine relative brightness on an image.

Related

Set alpha on one color in UIImage

I have this PNG image: (the area in the grey borders is transparent)
I would like only the grey corners to have alpha of 0.5
If I set
[imgView setAlpha:0.5f];
Also the transparent area in the middle retrieves a semi-white color.
How can I do it?
Any reason why you don't just change the original image file? If that's not possible, you could put a white (black?) rectangle with 50% opacity below the image.
Of course there are many ways to do this but you would need to tell us more about your use case.
You should add one imageview below your desired image. and adjust alpha of that image.

Iphone Set background image into text in uitextView?/

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.

Clear image with fade border

I have two UIImageView with same frame. One imageView above second imageView now I'm erasing upper imageView using Core Graphics. My problem is that the border of eraser is very sharp I want faded border i.e. after erasing the upper image should match the lower one's pallet. See below example -
I used these two images and below is result -
As you can see in this image eraser's border is very sharp. I want to make it faded out like in the middle it should be dark then light then more light and so on i.e. we cant see the width and end of brush. And here is my - My Sample Code Let me know if my question is not clear enough.
You can have a png image like brush (dark in the middle and light in the corner) and draw the image over your image like this.
[eraser drawAtPoint:location blendMode:kCGBlendModeDestinationOut alpha:1];

transparent color to white for an UIImage

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.

iPhone - UIButton background image is cut off sometimes

I am using a custom image as the background image for my buttons. I have noticed that the edges of the buttons are cut off sometimes. My buttons vary in size but the behavior doesn't seem to be dependent on the button size. I am creating the buttons programatically. The image I am using is pretty large to cover the entire background.
Can someone please let me know what could be the issue?
More info
Setting the content mode to UIViewContentModeScaleToFill still cuts of the images. Also tried resizing the image but doesn't make a difference.
Thanks.
Did you try setting the button's dimensions to fit exactly the image?
Is the image just cropped or also blurry (cause it's being resized)? Have you toyed around with UIView's contentMode property for the button?
If you did, did you try increasing/decreasing the width or height by a pixel? I sometimes had blurry buttons even though its dimensions were exactly the image's. Adding or removing an extra pixel sometimes helped.
I finally resolved this by creating a 3x3 px image with the background color as the button's color and a 1 px border surrounding the image. Then used the UIImage method stretchableImageWithLeftCapWidth:topCapHeight: to create an image with the desired border size of 1 px.