小编And*_*rei的帖子

Android系统.如何在真正的大图像(位图)上写文本并保存

嗨!

是以下问题:我需要在相当大的图像上写一个长文本并将其保存在那里.

条件:

  1. 图像大小超过3000 x 2000;
  2. 不允许将图像分成多个部分,因为要在整个图像上从边到边写入文本.
  3. 补充:我不能使用位图比例或矩阵比例,因为必须在原始图像上写入文本(全尺寸).
  4. 补充:当我向用户显示图像时,我使用Bitmap缩放:options.inSampleSize = 10;没有内存不足的问题

目前的问题:

当我尝试在Bitmap中加载此图像时,会出现内存限制(VM预算).

问题:

  1. 如何在不加载到内存中的大图像上发短信?
  2. 现有的库可以吗?

代码示例:

// Step 1. Open image and load to Bitmap
Bitmap bitmap = BitmapFactory.decodeFile(fileName); // runtime Exception like "VM budget" !
// or
//Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.big_img_1); // as in previous runtime Exception like "VM budget" !
// or
//Bitmap bitmap = BitmapFactory.decodeStream(fileInputStream);  // as in previous runtime Exception like "VM budget" !


// Step 2. Write text
Paint …
Run Code Online (Sandbox Code Playgroud)

android image exception

9
推荐指数
1
解决办法
1847
查看次数

标签 统计

android ×1

exception ×1

image ×1