Rank: Newbie
Groups: Registered
Joined: 6/9/2018(UTC) Posts: 8
|
You are correct, the blurry issue lies in the WPF rendering. The LCD flag was already activated. I had tried running experiments with the flag on and off, without significant results. There is in fact an issue with the Rendering procedure: Points/Pixels conversions compute larger Bitmaps sizes than what is really being displayed on screen. This results in Downsampling and Blurry text when it is scaled back to fit the screen. It is especially prominent when rendering small Zoom factors, since Bitmap scaling is rather efficient and doesn't produce much artifact with larger fonts sizes. Here is a quick hack which produces correct results (find image comparison at the end): PdfViewer.csCode:protected virtual bool DrawPage(DrawingContext drawingContext, PdfPage page, Rect actualRect)
{
if (actualRect.Width <= 0 || actualRect.Height <= 0)
return true;
//int width = Helpers.PointsToPixels(actualRect.Width);
//int height = Helpers.PointsToPixels(actualRect.Height);
//if (width <= 0 || height <= 0)
// return true;
//var pageRect = new Int32Rect(
// Helpers.PointsToPixels(actualRect.X),
// Helpers.PointsToPixels(actualRect.Y), width, height);
var pageRect = new Int32Rect(
(int)actualRect.X,
(int)actualRect.Y,
(int)actualRect.Width,
(int)actualRect.Height);
return _prPages.RenderPage(page,
pageRect,
PageRotation(page),
RenderFlags,
UseProgressiveRender);
}
Helper.csCode:public static void DrawImageUnscaled(DrawingContext drawingContext,
WriteableBitmap wpfBmp,
double x,
double y)
{
drawingContext.DrawImage(wpfBmp,
new Rect(x,
y,
/*PixelsToPoints*/(wpfBmp.PixelWidth),
/*PixelsToPoints*/(wpfBmp.PixelHeight)));
}
I put together an image comparison (click) of Chrome Rendering, Original WPF Rendering (blurry), Bitmap Rendering (Page > Bitmap > PNG file) (non-blurry), and fixed WPF Rendering (equivalent to Bitmap). In addition to the blurry issue now identified, if you zoom on the Image comparison above, you will note that Chrome uses colors for its font rendering. Because of their intensity, as opposed to Greyscale only, it produces a thinner and more pleasant rendering. How could we activate this feature ? Kind regards, Alexis
|