android - 从android的存储中获取位图时图像质量丢失
问题描述
从内部存储中获取图像文件并在 imageView 上显示时,我遇到了位图图像质量问题。如何使用位图显示具有原始质量的图像文件。
这是我的代码
fun renderPdf(renderer: PdfRenderer, pagesBitmap: MutableList<Bitmap>, dir: File) {
try {
for (i in 0 until PAGE_COUNT) {
val document: PDDocument = PDDocument.load(dir)
val pdfRenderer = PDFRenderer(document)
val bim = pdfRenderer.renderImage(i, 3.5f, Bitmap.Config.ARGB_8888!!)
pagesBitmap.add(bim!!)
document.close()
// Save the render result to an image
val path: String =
Environment.getExternalStorageDirectory().toString() + "/.AOF/aof_$i.jpg"
val renderFile = File(path)
val fileOut = FileOutputStream(renderFile)
pagesBitmap[i].compress(Bitmap.CompressFormat.JPEG, 100, fileOut)
fileOut.close()
}
ivForm.pagesBitmap = pagesBitmapFiles
ivForm.displayPDFDocument()
renderer.close()
} catch (e: IOException) {
Log.e("PdfBox-Android-Sample", "Exception thrown while rendering file", e)
} finally {
callDocumentType()
}
}
解决方案
推荐阅读
- go - Trace Golang 中的数据存储调用
- javascript - 我该怎么做才能让它打印输出
- azure-functions - 为什么我的队列触发的 Azure 函数应用没有横向扩展?
- azure-webjobs - 从触发转换为连续?
- reactjs - 我想每 3 秒更新一次,而不使用 react apollo refetch
- entity-framework - 如何使用实体框架工作 mvc 实现存储库模式
- reactjs - 动态呈现列
- awk - awk 意外结果
- javascript - 如何在 react.js 中将对象传递给 Formik 表单
- r - 带有虚拟变量的 GARCH 建模