How can I write a YUV frame data into a CGContext?
Please help me,
Thanks a lot.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The general road map of what you need to do along with some pseudo-code looks like this:
First create a CG bitmap context to draw into. The list of pixel formats for is available here. As you can see on iOS your only real options are some flavor of RGB with 16 bpp or 32 bpp and an alpha channel. There are more options on Mac OS X but you will still want to use some flavor of RGB.
Convert your YUV frame data into RGB and write the RGB data into the data buffer for the CG bitmap context. You can get formulas for how to do this on the Wikipedia page for YUV.
Convert the CG bitmap context into a CG image.
Draw the CG image to the CG context.