Flutter change transparency of png image with finger touch - flutter

I have a png image with transparent areas and opaque areas.
I want to be able to draw with my finger, with GestureDetector for example, on that image to be able to add transparency in the opaque areas and add opaque areas in the transparent areas. Both. For example with a button that allows you to switch between erase and paint modes.
The objective is that it can represent two images on the screen, inside a stack, one after the other. The back image is completely opaque and the front image has areas with transparency and you can paint over it as I mentioned before. In this way, as you add transparent areas in the front image, what is in the back image will be revealed. And conversely, you can add opacity to the image so that the image behind is hidden by the image in front.
I've tried CustonPaint but it's very difficult since you would have to add the image with drawImage, and do a lot of complicated steps. And I couldn't change the transparency of the image either, also, even if I could, with CustonPaint if you draw a lot, the screen slows down.

Related

Incorrect white matte behind antialiasing on imported sprites

I'm importing a sprite into Unity, and adding it to a Screen Space Overlay canvas to use for a UI.
The image I'm importing looks exactly as I want it, but in Unity the anti-aliased edges look like they're going to a white background color, instead of just fading over whatever is actually behind them.
I'm using these import settings:
I'm using a default UI/Image component to add it to the canvas.
This is the image I'm importing - it's a 32 bit PNG exported from Fireworks: (also shown over a black background)
Just to confirm, this looks fine everywhere else in Unity, preview panels, pickers etc. I am packing this sprite using the built in Sprite Packer if that changes anything.
And the final result:
How can I get rid of these artifacts on the corners?
The problem was the RGB values of the transparent pixels. By default they are white, and any scaling operations cause this white color to be blended with the partially transparent pixels.
I essentially made a slightly larger version of the button background shape, put it in a layer behind everything, and then wrote back into the alpha channel making it transparent. This means that the neighboring pixels are then the same color as the partially transparent ones.
The end result:

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

Free bitmaps for iOS custom buttons and sliders?

First, I'm not talking about icon libraries or mockup tools/libraries.
I'm familiar with various icon libraries that people have created, but other than the stuff from the example code like UICatalog, I'm wondering if anyone knows of anyone who has created free libraries of custom button bitmaps (stretchable button images), slider handle/track bitmaps, etc Basically bitmaps to customize the look of standard controls for those controls (like buttons and sliders) that allow you to specify such bitmaps.
I'm also interested in any photoshop tutorials/templates on/for creating stretchable custom button images, bitmaps for slider parts, etc. (Afraid I'm not a huge PS god or anything.)
Anyone know of any resources like this for fancying up the standard controls?
I've been able to find several stretchable buttons by searching through my collections of sample code for: "stretchableImageWithLeftCapWidth"
From the Apple sample code, the UICatalog, BubbleLevel, iPhoneMultichannelMixerTest, avTouch, AQOffilineRenderTest, and TouchCells sample code all contain buttons with stretchable images.
Hope this helps!
Stretchable buttons is no problem - there's nothing special you need to do in Photoshop. Just make the image of the button stretchable and set the radius to that of any rounded corners you have on the button graphic.
Slider parts - I'm pretty sure you'd have to make your own UIControl from scratch.
To make a button in Photoshop, create a new file with transparent background, select the Shape tool, rectangle near the bottom of the tools, drag out a rectangle. Size doesn't matterâ„¢. For a rounded rectangle, click and hold the same tool, choose the rounded rect shape and set a corner radies (same radius as in stretchableImage later).
Double-click the layer right of the layer name to get the layer style popup. Check Color Overlay and set the color you want. Check Inner Bevel and make its size somewhere below half the height of the rectangle - I think 90 degrees for the Global Angle works well. A lower opacity and larger size makes the bevel look less chunky.
Ctrl-click (option-click) the graphics rectangle in your layer to select the button's outline. Deselect the bottom half of it by using the marquee tool (M) at the top of the tools. Select a light gray foreground color, nearly white. Create a new layer with the square icon under the layer list (Windows->Layers if not visible). Fill the selection of the new layer with the paint bucket, and drag down opacity for the layer until the 'matte laquer' effect of it looks right.
A simple button, but that's the gist of it.

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.

How can I 'shine' a png on the iPhone in the same way that the app launcher does?

I want to show users what their square flat .png image will look like when converted to a normal 'shined' icon by the app launcher.
e.g. round corners and glassy effect.
Thanks
For in-application representation of the 'shine' on an icon, you can create a custom UIView that draws the shine gradient, using the code here (adjusting the gradient colors to match Apple's). When you want to apply the 'shine' to the preview icon, just overlay this custom UIView on top of its UIImageView (or whatever you're hosting it in).
The rectangular clipping could be a little trickier. If you have a solid black background, you could overlay a frame UIImageView that has a black area with a rounded rectangular transparent region in its center. You can also do this in a more general-purpose manner via Core Graphics by drawing your image and the gloss into a view, then using CGContextClip with a rounded rectangle to carve out the rounded interior.