本文整理汇总了C#中CGBitmapContext.SetRenderingIntent方法的典型用法代码示例。如果您正苦于以下问题:C# CGBitmapContext.SetRenderingIntent方法的具体用法?C# CGBitmapContext.SetRenderingIntent怎么用?C# CGBitmapContext.SetRenderingIntent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGBitmapContext
的用法示例。
在下文中一共展示了CGBitmapContext.SetRenderingIntent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetThumbImage
/// <summary>
/// Returns thumb image object for page
/// </summary>
/// <param name="thumbContentSize">Thumb content size</param>
/// <param name="pageNumber">Page number for what will created image object</param>
/// <returns>Page image object</returns>
private static UIImage GetThumbImage(float thumbContentSize, int pageNumber)
{
if ((pageNumber <= 0) || (pageNumber > PDFDocument.PageCount)) {
return null;
}
// Calc page view size
var pageSize = PageContentView.GetPageViewSize(pageNumber);
if (pageSize.Width % 2 > 0) {
pageSize.Width--;
}
if (pageSize.Height % 2 > 0) {
pageSize.Height--;
}
// Calc target size
var targetSize = new Size((int)pageSize.Width, (int)pageSize.Height);
// Draw page on CGImage
CGImage pageImage;
using (CGColorSpace rgb = CGColorSpace.CreateDeviceRGB()) {
using (var context = new CGBitmapContext(null, targetSize.Width, targetSize.Height, 8, 0, rgb, CGBitmapFlags.ByteOrder32Little | CGBitmapFlags.NoneSkipFirst)) {
using (var pdfPage = PDFDocument.GetPage(pageNumber)) {
// Draw page on custom CGBitmap context
var thumbRect = new RectangleF(0.0f, 0.0f, targetSize.Width, targetSize.Height);
context.SetFillColor(1.0f, 1.0f, 1.0f, 1.0f);
context.FillRect(thumbRect);
context.ConcatCTM(pdfPage.GetDrawingTransform(CGPDFBox.Crop, thumbRect, 0, true));
context.SetRenderingIntent(CGColorRenderingIntent.Default);
context.InterpolationQuality = CGInterpolationQuality.Default;
context.DrawPDFPage(pdfPage);
// Create CGImage from custom CGBitmap context
pageImage = context.ToImage();
}
}
}
return UIImage.FromImage(pageImage);
}