OpenNoteScanner icon indicating copy to clipboard operation
OpenNoteScanner copied to clipboard

[Question] Preview of taken photo

Open graczu0x0x0x0x0 opened this issue 7 years ago • 10 comments

How can i make a preview after photo is taken.

I was trying with "FullScreenViewActivity" but fail :(

Can someone help?

graczu0x0x0x0x0 avatar Dec 04 '18 10:12 graczu0x0x0x0x0

ins't gallery button working for you? can you give more info?

allgood avatar Dec 04 '18 10:12 allgood

It's working, all fine.

I want to make a preview of image after photo is taken, sometimes you shake your hand and photo can be bad, so automatic preview after photo shoot is good idea.

graczu0x0x0x0x0 avatar Dec 04 '18 11:12 graczu0x0x0x0x0

The main idea is to be able to scan multiple pages quickly, but I understand that some images can get low quality. It should be possible to open the image viewer with the new image right after it's taken but I think that it would be best to just put a link with a thumbnail on the side of the shutter button, sometimes the thumbnail will be good enough to just continue and get the next page.

allgood avatar Dec 04 '18 11:12 allgood

Another idea is to show the image with a OK/DELETE right after its captured.

allgood avatar Dec 04 '18 11:12 allgood

Yes i was planing to make a OK / DELETE based on FullScreenViewActivity, but don't know how to force a single image view.

graczu0x0x0x0x0 avatar Dec 04 '18 11:12 graczu0x0x0x0x0

I Think that the best option is a popover on the same view, this way the workflow gets faster: take picture, aprove, next picture, without the need to reinitialize the camera. It's possible to use the element of the animation.

allgood avatar Dec 04 '18 12:12 allgood

The OK/DELETE would appear before the file is saved on the gallery

allgood avatar Dec 04 '18 12:12 allgood

I make a simple preview with this code:

` private void SimplePreviewRun(String filename, ScannedDocument document) {

    SimplePreviewRunClass runnable = new SimplePreviewRunClass(filename, document);
    runOnUiThread(runnable);
}

class SimplePreviewRunClass implements Runnable {

    //private void SimplePreviewRun(String filename, ScannedDocument document) {

    private Size imageSize;
    //private Point[] previewPoints = null;
    //public Size previewSize = null;
    public String fileName = null;
    public int width;
    public int height;
    //private Bitmap bitmap;

    private ImageLoader mImageLoader;
    private ImageSize mTargetSize;
    //private int maxTexture;
    private int mMaxTexture;

    public SimplePreviewRunClass(String filename, ScannedDocument document) {
        this.fileName = filename;
        this.imageSize = document.processed.size();
    }

    @Override
    public void run() {
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).build();
        mImageLoader = ImageLoader.getInstance();
        mImageLoader.init(config);


        TouchImageView imgDisplay;
        imgDisplay = (TouchImageView) findViewById(R.id.imgDisplay);

        mMaxTexture = Utils.getMaxTextureSize();
        Log.d("FullScreenViewActivity", "gl resolution: " + mMaxTexture);
        mTargetSize = new ImageSize(mMaxTexture, mMaxTexture);


        mImageLoader.displayImage("file:///" + fileName, imgDisplay, mTargetSize);
        imgDisplay.setVisibility(View.VISIBLE);


        Button deletePreviewBtn = findViewById(R.id.deletePreview);
        Button savePreviewBtn = findViewById(R.id.savePreview);
        deletePreviewBtn.setVisibility(View.VISIBLE);
        savePreviewBtn.setVisibility(View.VISIBLE);
    }

}

`

create two invisible buttons in main scanner view and:

` deletePreviewBtnL = (Button) findViewById(R.id.deletePreview); savePreviewBtnL = (Button) findViewById(R.id.savePreview);

    deletePreviewBtnL.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(getApplicationContext(), R.string.action_delete, Toast.LENGTH_LONG).show();
            Button deletePreviewBtn = findViewById(R.id.deletePreview);
            deletePreviewBtn.setVisibility(View.INVISIBLE);
            Button savePreviewBtn = findViewById(R.id.savePreview);
            savePreviewBtn.setVisibility(View.INVISIBLE);
            ImageView imageView = findViewById(R.id.imgDisplay);
            imageView.setVisibility(View.INVISIBLE);
            //deletePreviewBtn.setOnClickListener(null);
            //savePreviewBtn.setOnClickListener(null);
            deleteLastFile();
        }
    });

    savePreviewBtnL.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //Strin confirmationText = R.string.save_confirmation;
            //Toast.makeText(getApplicationContext(), confirmationText, Toast.LENGTH_LONG).show();
            Button deletePreviewBtn = findViewById(R.id.deletePreview);
            deletePreviewBtn.setVisibility(View.INVISIBLE);
            Button savePreviewBtn = findViewById(R.id.savePreview);
            savePreviewBtn.setVisibility(View.INVISIBLE);
            ImageView imageView = findViewById(R.id.imgDisplay);
            imageView.setVisibility(View.INVISIBLE);
            //deletePreviewBtn.setOnClickListener(null);
            //savePreviewBtn.setOnClickListener(null);
            //uploadMedia(lastFile);
            new Thread(uploadTask).start();
        }
    });

` We can make an checkbox in option to make a preview of taken photo or not.

graczu0x0x0x0x0 avatar Dec 10 '18 08:12 graczu0x0x0x0x0

Great @graczu0x0x0x0x0 , can you submit it through a pull request?

allgood avatar Dec 11 '18 11:12 allgood

Yes i will, it's my first time working with github i need to get some knowlage first.

graczu0x0x0x0x0 avatar Feb 22 '19 12:02 graczu0x0x0x0x0