gpt4 book ai didi

c# - 如何提高使用 Pdfium 的图像质量

转载 作者:行者123 更新时间:2023-11-30 18:15:34 50 4
gpt4 key购买 nike

我使用下面的代码片段将 pdf 页面提取为图像,但是在更改位图的大小时,图像中的文本内容不清晰,很模糊您能否提出提高渲染图像质量的解决方案。

var data = bitmapImage.LockBits(
new Rectangle(0, 0, Width, Height),
ImageLockMode.ReadWrite,
bitmapImage.PixelFormat
);

int bytes = Math.Abs(data.Stride) * bitmapImage.Height;

var createdpages = PdfiumViewer.FPDFBitmap_CreateEx(
Width,
Height,
4,
data.Scan0,
bitmapImage.Width * 4
);

PdfiumViewer.FPDFBitmap_FillRect(
createdpages, 0, 0,
Width,
Height,
0xFFFFFFFF
);

PdfiumViewer.FPDF_RenderPageBitmap(
createdpages,
pages, 0, 0,
Width,
Height, 0, 0
);

请提供渲染图像清晰度的解决方案

最佳答案

pdfium 以 300 dpi 呈现页面。如果图像模糊,很可能是 pdf 中的图像 dpi 较低。

您可以尝试减小输出的高度和宽度以使图像不那么模糊,减少缩放量以适应渲染位图中的小图像。

关于c# - 如何提高使用 Pdfium 的图像质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47893582/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com