UIBezierPath from image - ios

I have several png files that look similar to this this:
Everything is transparent but the black path. What I am trying to do is create a UIBezierPath from the non transparent part.
Edit:
So I was thinking what about creating a mask with the png then from the mask go to a UIBezierPath. Would that work?
Edit Again:
I found the solution, look at my answer.

I went a different direction. Instead of using PNGs I went with SVG and used PocketSVG to parse the file. It works great.

The process you're looking for is known as skeletonization, there's a good summary of techniques in this post:
Determine the midline of a bent, elongated region

Related

How to draw stroke within boundaries on a bitmap image in swift

I’m creating a drawing app similar to pigment on iOS.
I would like to know if there are any ideas on how to implement the drawing strokes within the limited boundaries like in the example image
I think the best approach I’ve tried is to create a clipped Bézier path and constrain drawing into that , but I’m stuck on how to generate a Bézier path from the white area I’ve selected
Can anyone explain how to do that or provide an alternative approach ?

How to create a complex SVG layer fill animation based on CAShapeLayer

As you can understand from the title of this question I am trying to achieve fill animation of CALayer(CAShapeLayer) of SVG file.
How complex should be animation you can see from the images I attached.
I decided to start just with a circle and animate it to fill a layer below. Everything works pretty well.
So, I started building UIBezierPath or something like that but it looks like I am going the wrong direction.
I would really appreciate if you can just give me different ideas how to achieve it.
For SVG I use SVGKit. Maybe by using these set of classes, I can do something.
Thank you!

Adding border to edges of opaque area of UIImage with a filter

Hello: Currently in my project, I'm using OBShapedButton to process touches on a lot of objects that overlap (it's a map with each territory its own separate object). Basically, this library prevents a touch from being processed on a transparent point on the given view.
I'm attempting to add a border effect to just the edges of the opaque part of the UIImage (and adding a semi-transparent overlay above that). Something to the effect of this:
Which can be simplified to this (example of one image):
I am currently using MGImageUtilities to color in the opaque parts of territories using this line:
[territory setImage:[[territory image] imageTintedWithColor:tint]];
The problem is that I'm not sure how to just color the borders (which can be any shape). I've looked at this link already, but haven't been able to come up with anything.
Thanks in advance for the help!
Terribly hacky, but use MGImageUtilities' UIImage+ProportionalFill with scale resizing to create a slightly larger image, UIImage+Tint to red, and stack below.
The library you are using doesn't actually specify a shape layer. It uses alpha values from the PNGs that you give it.
Could you use a different 'highlighted' or 'selected' PNG that adds the border effect you are looking for?
Otherwise, it you will have to generate a UIBezierPath from your PNG image, which sounds like a very computationally intensive operation. At that point, I might question whether this library meets your needs.

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.

CCSprite has weird white pixels around the border

I'm facing a weird problem in cocos2d for my iPhone game. I have created a PNG file as below
In cocos2d, I use CCSpriteSheet to get each ball all of the with PNG file. It works well until then.
However, the weird thing is that on the iPhone's screen, the ball has weird white pixels around the border, as shown in the below screenshot
I have done so many researches on the web. But every suggestion like using TexturePacker or reset the glBlendFunc didn't work :(
Do you have any idea?
Update: I try to used normal CCSprite with separate PNG file of only one ball, the problem is still! I guess that I have to configure the cocos2d sourcecode some how to get it worked.
I have figured out the issue. Not because of the graphic itself. It's because of the box2d create an outline for the b2Fixture on the back of the CCSprite. Here I posted a question for that specific question!
http://www.cocos2d-iphone.org/forum/topic/25368?replies=1#post-132008

Resources