How can I paint or fill an image mask in flutter? - flutter

Good community, I am trying to create a mask with the image (A).
I am using ShaderMask (https://www.youtube.com/watch?v=7sUL66pTQ7Q).
And up to here I think that everything is correct, but the complications come when I want to paint the mask.
I don't know how to continue, to be able to fill or paint the mask, as shown in the image (B).
I am using the red color to paint and fill the mask.
Any ideas? Thanks in advance

Related

Flutter - Hard color stop in linear gradient

I'm using CustomPaint to make a custom shape and I want to apply a color gradient but with hard color stops. Without color transitions.
PS:I cannot use different Paints instead of gradient because of the custom shape.
I checked the documentation and couldn't find anything. Is it impossible? Or is there any other workarounds? Thanks!
You could split your custom shape in smaller shapes and give each one its correct color. That would be one way to do it.
I have another idea. You could do it like so: Give the complete canvas of you custom paint a color, the color of your application's background. Give your custom shape Colors.transparent as its color. Then you make as many containers with the colors you want to have and put them below each other so that there overall size matches the size of your custom paint. You stack the custom paint onto these containers using Stack Widget and your custom shape will take the colors of these containers because its color is transparent. While the surrounding of your custom shape will have the color of the background of your application, because the whole custom paint is colored that way.
Okay I figured it out myself, I use Gradient.linear as the shader for custom paint. I noticed that it only blends colors when there is a big gap in stops. So I put my colors and stops like this.
Colors | Stop
Green 0.2
Green 0.201
Blue 0.5
Blue 0.501
Yellow 1
Now the color stops are hard.
Here's a preview of before and after |

how to fill color in image in particular area?

I want to fill the color in white area for Paint based application so please give me suggestion for how to do this work.
GPUImage is what you need there is a bunch of filters. In principle you need to point ios that it needs to change all whitecolors RGB(255.0,255.0,255.0) to some other color.

How can i paint inside the bouandry of the PNG image

I have an PNG image with complete transparency. It has a picture of an animal , just bordered with black color.
Now , I want to paint the image as my finger move on the ipad Screen, but paint should only appear inside the bordered region not out side.
My Thinking -----
What i am thinking is to keep the color of the image inside the boundary line, a little bit differ from the out side. Then, Get the pixel of the image and for each pixel , the color component.
Keeping all the pixels of out side the boundary in an array and check for it when finger move on the iPad screen.
I am new to the concept of core graphic and open GL so not being able to think wisely. Please help.
First you should define where is "inside" to paint on your image.
I suggest to run a flood fill algortihm on the first touched place and define de desired "inside area" pixels. Notice that you will run the flood fill at the background on the original black and white image, not for actually painting the pixels, just to figure out the target ones.
For example; we want to paint the animals face and body to different colors. When user first toucehs the face and drags over, you can do a flood fill on black and white image to find the pixels of the face and only paint the intersection of the face area and the touched area. Then, when the user picks up her finger (changes the color) and retouches on the body and you do another flood fill operation to detect the pixels of the body and so on.
It was a long description, hope it makes sense.
Here are some flood fill sources that might help:
Floodfill in objective c
https://stackoverflow.com/questions/8121348/flood-fill-algorithm-objective-c-version
How to Implement FloodFill Algorithm in iphone

Edge blending of image with alpha on iOS after masking color

I have an image that has been masked with a range of colors using
CGImageCreateWithMaskingColors()
Everything works fine, but the edge of the image (we are using a green screen for profile pictures) is pixelated. I've tried drawing the image in an image context and a bitmap context with the proper antialiasing, but the edges remain the same.
Any suggestions on how to smooth the sides of the profile after it has been masked?
You could try zooming the mask image larger by some multiple (say 2X, 3X or 4X) before creating the mask. Then a size-reduced copy of this larger mask might be better antialiased.

Coloring Image in iPhone SDK

i am developing a iphone app. i have a background image lets say an airplane with black color out lines and from color palette user can pick a color and fill the region of airplane....any help, code , suggestion will highly be appriciated
A simple fill algorithm should do. just expand from the point you are on until you meet region end pixels
see http://en.wikipedia.org/wiki/Flood_fill you can also try googling for Boundary Fill algorithm
My first though was to have a UIView and a mask image on top of that with the plane but this only works in certain situations. If the shape of the plane does not change you could also change the color and then "fill" the plan in during the drawRect using functions like CGContextAddArc and CGContextAddRect.