Filling an image with color - ios

I have an image and would like to fill it with color. The image is a flat bubble like the iOS 7 message app bubble. Basically, I want to use it as a shape. How can I do this?

I dont get your question to be honest :)
If you want a picture filled with color, either fill the picture in photoshop, and then use it in your code afterwards.
Otherwise make a circle with a div :) And just use background-color: black; or whatever color you want.

Related

Mql4 Color Transparency in Rectangle Object

Is it possible to add in color transparency to an object? Eg. I want to make a rectangle and instead of making it while #ffffff i wanted to make it transparent.
I was wondering if anyone can show me some example code to do this?
Thank you
It's not immediately obvious from the ObjectCreate description. You have to make the object appear in the foreground and disable the filling as per the following code:
ObjectCreate(0,"Rectangle",OBJ_RECTANGLE,0,Time[10],Open[10],Time[0],Open[0]);
ObjectSetInteger(0,"Rectangle",OBJPROP_COLOR,clrBlack);
ObjectSetInteger(0,"Rectangle",OBJPROP_FILL,false);
ObjectSetInteger(0,"Rectangle",OBJPROP_BACK,false);

How do I set tint color only for non white parts of the UIImage?

Simple I have UIImageView icon with two people and it looks like this:
but when I set tintColor to red it looks like this:
Is there any way to avoid covering every non zero-alpha pixel? I need to show the tie really there. One time I need people red, other time green.
The icon is simple png file. Rounded circle is simple background color of UIImageView. So the part of the image with tie cannot be zero-alpha.
Is there any way to achieve such effect WITHOUT creating images for every color?
This was similar to another idea I had been playing around with, so I did a little more fiddling...
Starting with these 3 images:
and then using them as .withRenderingMode(.alwaysTemplate) to give the desired colors... and then layering them via CALayer to get:
and an "exploded" view for clarity...
Create an image where the "people" are 100% transparent - effectively "holes" in the image.
Set the background color of the UIImageView to be the "fill" color.
You can still mask it with a circle (CAShapeLayer, for example), if you don't want a white bounding-box as part of the image.
Original images:
https://i.stack.imgur.com/eFrmB.png
https://i.stack.imgur.com/2GNDX.png
Use the CISpotColor filter:
https://developer.apple.com/library/content/documentation/GraphicsImaging/Reference/CoreImageFilterReference/#//apple_ref/doc/filter/ci/CISpotColor
This allows you to specify a color in your image that is to be changed into another color. Thus, since you know the original color of the tie and the background, you can change either of them, or both, in a single move.

How do you create a 'blurred text' image effect in iOS?

I want to create a text shaped blur effect to an image as shown below:
Another example:
I have found an answer on blurring a UILabel answer: How to blur UILabel text.
But the effect is not correct.
So, How can I create a blurred text image effect that I can render into an image as a watermark in Swift?
Somebody help me! Thanks very much!
By the way, the answers about UIVisualEffectView is not correct.
The effect using UIVisualEffectView is like:
Besides, I also want to apply this kind of blur effect into photo's watermark.
So, any help?
You're going to need a two stage approach to get the desired effect:
Generate a black and white image of the text (black background, white text). The standard string in Swift has a Draw method. There's another Answer that has more detail on this.
Pass this 'text' image and your source image into the CIMaskedVariableBlur filter from CoreImage.
Basically, your 'text' image will act as the mask for the blur filter. Where the mask is lighter, the blur is stronger, and where the mask is black, no blur is applied.

I want to draw custom shape like apple shape on UIView

I am trying to make Apple kind of shape for progressHUD. I have option to use .png Image but I cant because I have to fill the apple Shape with different colour depends of percentage status.. I am using UIView to draw this shape...
I want suggestion how to draw apple kind of shape easily?
And How we can fill half colour with different colour?
I have option to use .png Image but I cant
Yes, you can. — Get hold of some apple-shaped artwork. Use it as a mask - it punches a hole in a view. Now put another view behind it, with a color. Now the apple appears to be that color, because that color is being seen through the apple-shaped hole. Now put another view behind it, with a different color, and move it up or across the right amount so as to divide what's seen through the apple into two colors.
Using that approach, it took me about 30 seconds to create this result (using your apple-shaped artwork as a .png image!):

how to fill solid color into the shape of a transparent PNG file with actionscript3?

For example, I have a transparent png file, the shape is a car.
In the png file, I only draw the white border shape.
Outside and inside the border are all transparent.
I want to use actionscript3 code to show the car object with different color, it means only fill color inside the border, and for the outside of the border, keep transparent.
How to do that?
So far, the simplest workaround is to prepare many images with PhotoShop, but it's not good enough for me. When I have many shapes and use many colors, I've to prepare many many images.
Add more details:
(Because I'm using white border, you may not see the basic png file if your background of browser is white)
Change my boarder of shape to black, hope this is helpful to understand my question.
Since you're working with loaded images/pixels you can make use of BitmapData's floodFill() which pretty much does what you need. There's an example in bellow the method description as well.
It does pretty much what you need, although in some cases it might not be perfect. It's worth having a look at Jan's optimizing the floodFill() method article which goes more in depth.
A simple solution is to use multiple layers. The top layer would contain just the border. The lower layer would contain just the car with no border. You can adjust the colour of the car layer using a ColorTransform or ColorMatrixFilter.

Resources