const size_t Width = 1080; const size_t Height = 1080; const size_t Area = Width * Height; const size_t channles = 4; // rgba std::vector<uint8_t> output(Area*channles); uint8_t *outputdata = output.data(); // create the bitmap context: const size_t BitsPerComponent = 8; const size_t BytesPerRow=((BitsPerComponent * Width) / 8) * channles; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef gtx = CGBitmapContextCreate(outputdata, Width, Height, BitsPerComponent, BytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast); // create the image: CGImageRef toCGImage = CGBitmapContextCreateImage(gtx); UIImage *image = [[UIImage alloc] initWithCGImage:toCGImage]; [self.imageView setImage:image];