【问题标题】:How to Convert Images,Pdf ,Docx and Doc file to Bitmap [closed]如何将图像、Pdf、Docx 和 Doc 文件转换为位图 [关闭]
【发布时间】: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 扩展文件转换为位图。 是否有文件转换为位图的常用功能。 我想在位图中发送到服务器文件。

【问题讨论】:

  • 请分享你的观点在这里我遇到了问题

标签: android pdf docx doc


【解决方案1】:

我正在使用 Retrofit 将所有类型的文件转换为位图。通过使用此 Retrofit 非常容易且轻松地将其转换为位图 android

【讨论】:

    猜你喜欢
    • 2020-05-22
    • 1970-01-01
    • 2020-12-09
    • 1970-01-01
    • 2012-07-28
    • 1970-01-01
    • 2016-11-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多