Load images or files into DcsBuffer

With Dynamsoft Camera SDK Android Edition, you can load the memory data into DcsBuffer with the method loadData() or loadDataAsync().

Below is a simple code snippet for loadDataAsync():

 byte []data = null;
        try {
            InputStream in = new FileInputStream("/sdcard/capture.png");
            data= new byte[in.available()];
            in.read(data);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        dcsView.getIO().loadDataAsync(data, DcsVideoView.DME_IMAGE, new ILoad() {
            @Override
            public boolean onLoadProgress(int i) {
                return false;
            }

            @Override
            public void onLoadSuccess(Object o) {

            }

            @Override
            public void onLoadFailure(Object o, DcsException e) {

            }
        });

You can also load a local file into DcsBuffer with the methods loadFile() or loadFileAsync(). Below is a simple code snippet for loadFileAsync():


 dcsView.getIO().loadFileAsync("/sdcard/Download/1525834152764.jpg", DcsVideoView.DME_IMAGE, new ILoad() {
            @Override
            public boolean onLoadProgress(int i) {
                Log.d("progress",i+"");
                return true;
            }

            @Override
            public void onLoadSuccess(Object o) {
                Log.d("progress","load success");
            }

            @Override
            public void onLoadFailure(Object o, DcsException e) {
                e.printStackTrace();
            }
        });

Is this page helpful?

Leave a Reply

Your email address will not be published.