iPhone SDK - CGBitmapContextCreate

Posted by nax_ on Stack Overflow See other posts from Stack Overflow or by nax_
Published on 2011-03-20T18:16:16Z Indexed on 2011/03/20 19:18 UTC
Read the original article Hit count: 301

Hi,

I would like to create an image of my own. I already know its width (320*2 = 640) and height (427).

So I have some raw data :

unsigned char *rawImg = malloc(height * width * 4 *2 );

Then, I will fill it :)

Then, I have to do something like that to get a bitmap and return a (UIImage *) :

ctx = CGBitmapContextCreate(rawImg,width*2,height,8,
    ???,
    ???,
    kCGImageAlphaPremultipliedLast); 

UIImage * imgFinal = [UIImage imageWithCGImage:CGBitmapContextCreateImage(ctx)];
CGContextRelease(ctx); 



return imgFinal;

But I don't know how to create my context ctx, as you can see with the "???", even tough I read the documentation...

Please help ! Thanks :)

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiimage