开发者

Is it possible to stroke a CGImageRef using Core Graphics?

开发者 https://www.devze.com 2023-02-11 02:45 出处:网络
I have a CGImageRef to a shape with a transparent background. Is is possible to stroke the image, like you can stroke a path with CGContextStrokePath()? Alternativ开发者_开发知识库ely, can you convert

I have a CGImageRef to a shape with a transparent background. Is is possible to stroke the image, like you can stroke a path with CGContextStrokePath()? Alternativ开发者_开发知识库ely, can you convert the image to a path and stroke that?


You can use CGContextDrawTiledImage. It's not exactly what you are looking for, but as far as I know there is no built-in way to do what you want. You can use a combination of well-placed rects and clipping paths to achieve the look you are going for, however.


It turns out there's no easy way to do this, so I ended up having to iterate over each pixel (you can get a pointer to the image data using CGBitmapContextGetData()) and adjusting the RGB value of every one that was adjacent to an opaque pixel.

0

精彩评论

暂无评论...
验证码 换一张
取 消