How to get UIImage from PDFDraw on Xamarin?

Question:

I am on Xamarin, and need to get a UIImage object from PDFDraw, how do I that?

Answer:

`
private UIImage ImageFromRawBGRAData(NSData data, int width, int height, bool isRetina)
{
using (CGDataProvider provider = new CGDataProvider(data))
{
int bitsPerComponent = 8;
int bitsPerPixel = 4 * bitsPerComponent;
int bytesPerRow = 4 * width;
using (var colorSpace = CGColorSpace.CreateDeviceRGB())
{
const CGBitmapFlags bitmapInfo = CGBitmapFlags.PremultipliedFirst | CGBitmapFlags.ByteOrder32Little;
const CGColorRenderingIntent renderingIntent = CGColorRenderingIntent.Default;
using (var image = new CGImage(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow,
colorSpace, bitmapInfo, provider, null, false, renderingIntent))
{
nfloat screenScale = 1;
if (isRetina && UIScreen.MainScreen.Scale > 1)
{
screenScale = UIScreen.MainScreen.Scale;
}

var myImage = new UIImage(image, screenScale, UIImageOrientation.Up);
return myImage;
}
}
}
}
`