【发布时间】:2017-10-24 07:00:09
【问题描述】:
我正在使用代码将图像转换为位图:
public Bitmap getBitmap() throws IOException {
if (!getInformation())
throw new FileNotFoundException();
if (!getStoredDimensions())
throw new InvalidObjectException(null);
RectF rect = new RectF(0, 0, storedWidth, storedHeight);
orientation.mapRect(rect);
int width = (int) rect.width();
int height = (int) rect.height();
int subSample = 1;
while (width > MAX_WIDTH || height > MAX_HEIGHT) {
width /= 2;
height /= 2;
subSample *= 2;
}
if (width == 0 || height == 0)
throw new InvalidObjectException(null);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = subSample;
Bitmap subSampled = BitmapFactory.decodeStream(resolver.openInputStream(uri), null, options);
Bitmap picture;
if (!orientation.isIdentity()) {
picture = Bitmap.createBitmap(subSampled, 0, 0, options.outWidth, options.outHeight,
orientation, false);
subSampled.recycle();
} else
picture = subSampled;
return picture;
}
我面临的问题是如何从 Pdf 、Docx 和 Doc 扩展文件转换为位图。 是否有文件转换为位图的常用功能。 我想在位图中发送到服务器文件。
【问题讨论】:
-
请分享你的观点在这里我遇到了问题