I have a Bytearray
unsigned char *outputData = (unsigned char *)malloc(sizeof(unsigned char) * w * h * 4);
outputData[y * h * 4 + x * 4 + 0] = all; //a
CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();
CGContextRef bitmapContext=CGBitmapContextCreate(outputData, w, h, 8, 4*w, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrderDefault);
CFRelease(colorSpace);
free(outputData);
CGImageRef cgImage=CGBitmapContextCreateImage(bitmapContext);
CGContextRelease(bitmapContext);
UIImage * newimage = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);