开发者

How do I create a CGlayer that has an image drawn to it?

I just need to know hot to create a CGLayer t开发者_StackOverflowhat has an image drawn to it. I am not completely understanding the documentation entirely. Thanks


A while ago I posted a blog post on a similar topic, available here:

Drawing UIImages right side up using CoreGraphics

In that post, I show how to draw a UIImage so that's it's grayscale. Part of that includes creating a new layer with a gray colorspace (so it draws in shades of gray), and then extracting the CGContextRef from the CGLayer, pushing it to the context stack, drawing the UIImage, and then popping the context stack. The UIImage draws onto the topmost CGContextRef, which will be the context that corresponds to your CGLayer.

There are probably other ways to do this, but this is how I've done it in the past, and it's always worked great for me.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜