Why images in XIB are different? - iphone

At left there's the original image (after imported in Xcode), at right the image inside UIImageView. It's more dark.
Why this? It's a very annoying problem.

Man! Its just an illusion.
Don't ask "magic" related questions here. Ask only program related questions ;-)
Both images are of same color. They look different because their background colors are different. Use Photoshop or some other tool to find the colors of those two. They should be the same.

Its because the background colours are different and the stroke on the image is the same / similar colour to the background.
Change the background colour of the view to white, and it will look normal.

Related

Create tintable image with solid colour, so that it can adapt Dark and Light modes

I need to create UIImage (bitmap?) filled with a solid colour so that it can be tinted and thus support Dark and Light mode changes
Is there a way to do this in Swift?
Not the best way, but a quick and dirty way to do this would be make a UIView with a background the color you want and then use one of the many ways to go UIView -> UIImage.
This stack overflow question here does exactly that:
How to convert a UIView to an image
Furthermore, looking at that code will give you some insights on how to do it the right way, with lower level graphics functions if you like.

php gd library to reveal background image

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 want to exchange a particular color inside an image with another color. Is there any possible way?

I have one image with multiple colors.
I want to change a specific color with the alternate color that i have pre-decided.
Is there any algorithms to modify the image and save it?
Help is appreciated.
Thank you very much.
See the selected answer to this question:
How to make one color transparent on a UIImage?
It also shows turning red pixels green, which applies to your question.
Definatly yes.
Look here
Bitmap Images and Image Masks
Look in that page for: "Masking with color"

Loupe Magnification with White Text & Clear Background on Iphone

You guys helped so much with my last question, I figured I'd give you a shot at another. I have written an app with a theme that uses a dark blue glassy background and white / gray text and labels. The textfields in my app have clearcolor backgrounds and white texts and everything shows up very well. My only concern is that when you hold down a touch in a text box to get the magnification loupe, of course the white text shows up on a white background... which you can not read. Anybody got any ideas on how to implement a usable loupe here?
Unfortunately, the only "public" way I know how to change the loupe background is by setting textField.backgroundColor
I assume that since you're setting your backgrounds as clearColor, the magnifier defaults to white background, so the only way is to set your backgroundColor as something not clear.
I'm also assuming that since you did mention that you set your backgrounds a clear, that having it not be clear is not an option. So two ways I can think up in my mind about how to get around this is:
Assuming that the magnification lopue gets its background color by calling the backgroundColor implementation (and not some other obscure private API method): override the backgroundColor method and return a solid color.
Create your own loupe (probably not feasible)
I figured out a simple work around that achieved the desired effect. I also went through the full process of making my own loupe but since there is clear documentation on making your own loupe (see kiyoshi's answer), and this other method is ridiculously simple, I decided to document it here. It is basically just faking the clear background so that the white text shows up in the loupe. The background I am using for the view looks like blue smoke on a darker blue background:
alt text http://img231.imageshack.us/img231/9835/beforestatex.jpg
I took a screenshot of the simulator with the textfield visible and a black background so it would show up better:
alt text http://img193.imageshack.us/img193/9023/blackfieldx.jpg
Then I took that screenshot and made it semi transparent in photoshop, and overlayed my original background image to find exactly where the textfield appeared on the background:
alt text http://img266.imageshack.us/img266/9493/transparencyfullscreenx.jpg
Then I copied the exact pixels that would be used as the background of the textfield into a new PNG and saved that and set it as the the background image:
alt text http://img41.imageshack.us/img41/3450/textboxback.png
forwardToField.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:#"textboxback.png"]];
Keep in mind that the image will be repeated as a pattern within the loupe... so if you don't want to see the edges, simply make sure your textfield is larger than the loupe height and width.
Before:
alt text http://img196.imageshack.us/img196/2672/beforex.jpg
After:
alt text http://img23.imageshack.us/img23/2182/afterxd.jpg
I hope this helps somebody out there!
Actually its pretty feasible to create your own loop. Haven't tried subitting to apple yet so don't know how they feel about it.
Basic idea is override touches, use a timer to see how long the user has been touching the screen. The loupe is just a UIView that grabs as an image the view behind it and magnifies it.
Check out this article from Craftymind here
The article has you cache the entire image behind which is definitely faster, for rendering the loupe, but if you have stuff (i.e. textFields) that are constantly changing I've been able to render the loope image real-time without too much of a performance hit.

Changing color of part of an image

I have a png image file that is partly opaque and partly transparent. I display it in a UIImageView as a mask of sorts over another UIImageView layered behind it (as a sibling subview of a common superview). It gives me perfect borders around something painted using a finger on the lower UIImageView in my stack of UIImageViews. Perhaps there are better ways to do this, but I am new-ish, and this is the best way I came up with thus far. None the less, my app is in the App Store and now I want to enhance it to provide more images to use as the mask of sorts over the finger painting. But I don't want to bloat my bundle size by adding more static mask images as I did for the initial implementation. Not to mention I don't want to spend lots of time in photoshop making 100 masks. I'd rather programmatically change the color of the mask, without affecting the clear portion in the middle, which is not a simple regtangle or circle, but rather a complex shape. So my question is this: How can I change the colored portion of my loaded image without affecting the clear color portion in the middle? Is there a reasonably easy way to do this? Essentially I want to do what is described in this post (How would I tint an image programmatically on the iPhone?) without affecting the clear portion of my image. Thanks for any insights.
Have a look at the Tinted Image sample project. Try out the different modes until you get the effect you want.