BitmapFactory在应用程序中显示一个空白屏幕

问题描述 投票:1回答:0

您好我已经尝试了堆栈上的所有解决方案,例如检查溢出并多次更改样本大小。 有没有其他方法可以在Bitmap格式的应用程序上获取图片。

protected void onPhotoTaken()
    {

        Log.i( "MakeMachine", "onPhotoTaken" );
        _taken = true;

        BitmapFactory.Options options = new BitmapFactory.Options();

        options.inSampleSize = 4;
        options.inJustDecodeBounds = false;
        Bitmap bitmap = BitmapFactory.decodeFile( _path,options);
        _image.setImageBitmap(bitmap);

        _field.setVisibility( View.GONE );

    }

无论如何任何帮助将不胜感激。 我也很乐意听到解决方法。

我的layout.xml是: -

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal|center_vertical">

    <RelativeLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="6"
        android:gravity="center_horizontal|center_vertical">

        <TextView android:id="@+id/field"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="No Image"
            android:gravity="center_horizontal"/>

        <ImageView android:id="@+id/image"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

    </RelativeLayout>

    <Button android:id="@+id/button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Take Photo"
        android:layout_weight="1"/>
</LinearLayout>

我也尝试了在线项目https://github.com/priyankvex/Easy-Ocr-Scanner-Android,但它对我不起作用。 我希望有人可以提供帮助。 这个stackoverflow问题的答案也提出了我完全相同的Android解决方案:SD卡显示图像,但它对我不起作用

java android ocr android-bitmap bitmapfactory
© www.soinside.com 2019 - 2024. All rights reserved.