ODK收集图像质量

时间:2015-01-11 14:02:01

标签: image collect odk

现在智能手机配备了1600万像素摄像头,图像尺寸达到了5 MB。在移动数据上载它们将花费一些时间和更多数据,导致App的性能不佳。

有没有办法,ODK收集将图像问题的大小调整到指定的尺寸和质量。

这有助于提高App的性能。

1 个答案:

答案 0 :(得分:0)

查看ImageWidget.java

ODK Collect会调整大小,但您可以更改

int screenWidth = display.getWidth();
int screenHeight = display.getHeight();

到固定的最大分辨率...

    // Only add the imageView if the user has taken a picture
    if (mBinaryName != null) {
        mImageView = new ImageView(getContext());
        mImageView.setId(QuestionWidget.newUniqueId());
        Display display =
            ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
                    .getDefaultDisplay();
        int screenWidth = display.getWidth();
        int screenHeight = display.getHeight();

        File f = new File(mInstanceFolder + File.separator + mBinaryName);

        if (f.exists()) {
            Bitmap bmp = FileUtils.getBitmapScaledToDisplay(f, screenHeight, screenWidth);
            if (bmp == null) {
                mErrorTextView.setVisibility(View.VISIBLE);
            }
            mImageView.setImageBitmap(bmp);
        } else {
            mImageView.setImageBitmap(null);
        }

        mImageView.setPadding(10, 10, 10, 10);
        mImageView.setAdjustViewBounds(true);
        mImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    Collect.getInstance().getActivityLogger().logInstanceAction(this, "viewButton", 
                                    "click", mPrompt.getIndex());
                Intent i = new Intent("android.intent.action.VIEW");
                Uri uri = MediaUtils.getImageUriFromMediaProvider(mInstanceFolder + File.separator + mBinaryName);
                    if ( uri != null ) {
                    Log.i(t,"setting view path to: " + uri);
                    i.setDataAndType(uri, "image/*");
                    try {
                        getContext().startActivity(i);
                    } catch (ActivityNotFoundException e) {
                        Toast.makeText(getContext(),
                            getContext().getString(R.string.activity_not_found, "view image"),
                            Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });