Search in sources :

Example 1 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class ExecuteFilterDemoActivity method startDrawPadExecute.

private void startDrawPadExecute() {
    if (isExecuting)
        return;
    beforeDraw = System.currentTimeMillis();
    isExecuting = true;
    // 设置pad的宽度和高度.
    int padWidth = mInfo.vWidth;
    int padHeight = mInfo.vHeight;
    if (mInfo.vRotateAngle == 90 || mInfo.vRotateAngle == 270) {
        padWidth = mInfo.vHeight;
        padHeight = mInfo.vWidth;
    }
    mDrawPad = new DrawPadVideoExecute(ExecuteFilterDemoActivity.this, videoPath, padWidth, padHeight, (int) (mInfo.vBitRate * 1.5f), new IF1977Filter(getApplicationContext()), editTmpPath);
    mDrawPad.setUseMainVideoPts(true);
    /**
     * 设置DrawPad处理的进度监听, 回传的currentTimeUs单位是微秒.
     */
    mDrawPad.setDrawPadProgressListener(new onDrawPadProgressListener() {

        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            drawPadProgress(v, currentTimeUs);
        }
    });
    /**
     * 设置DrawPad处理完成后的监听.
     */
    mDrawPad.setDrawPadCompletedListener(new onDrawPadCompletedListener() {

        @Override
        public void onCompleted(DrawPad v) {
            drawPadCompleted();
        }
    });
    mDrawPad.pauseRecord();
    if (mDrawPad.startDrawPad()) {
        mainVideoLayer = mDrawPad.getMainVideoLayer();
        // 开始恢复处理.
        mDrawPad.resumeRecord();
    } else {
        new AlertDialog.Builder(this).setTitle("提示").setMessage("DrawPad开启错误.或许视频分辨率过高导致..").setPositiveButton("确定", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }).show();
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) DrawPadVideoExecute(com.lansosdk.videoeditor.DrawPadVideoExecute) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) IF1977Filter(jp.co.cyberagent.lansongsdk.gpuimage.IF1977Filter) com.lansosdk.box.onDrawPadCompletedListener(com.lansosdk.box.onDrawPadCompletedListener)

Example 2 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class ExecuteTwoVideoLayerDemoActivity method addDataLayer.

/**
 * 增加一个DataLayer, 数据图层. 数据图层是可以把外界的数据图片RGBA, 作为一个图层, 传到到DrawPad中.
 * <p>
 * 流程是: 把gif作为一个视频文件, 一帧一帧的解码,把解码得到的数据通过DataLayer传递到容器中.
 */
private void addDataLayer() {
    String gifPath = CopyDefaultVideoAsyncTask.copyFile(getApplicationContext(), "a.gif");
    gifInfo = new MediaInfo(gifPath);
    if (gifInfo.prepare()) {
        decoderHandler = BoxDecoder.decoderInit(gifPath);
        mGLRgbBuffer = IntBuffer.allocate(gifInfo.vWidth * gifInfo.vHeight);
        gifInterval = (int) (mInfo.vFrameRate / gifInfo.vFrameRate);
        dataLayer = mDrawPad.addDataLayer(gifInfo.vWidth, gifInfo.vHeight);
        /**
         * 容器中的onDrawPadThreadProgressListener监听,与 onDrawPadProgressListener不同的地方在于:
         * 此回调是在DrawPad渲染完一帧后,立即执行这个回调中的代码,不通过Handler传递出去.
         */
        mDrawPad.setDrawPadThreadProgressListener(new onDrawPadThreadProgressListener() {

            @Override
            public void onThreadProgress(DrawPad v, long currentTimeUs) {
                // TODO Auto-generated method stub
                if (dataLayer != null) {
                    if (canDrawNext()) {
                        int seekZero = -1;
                        if (decoderHandler != 0 && BoxDecoder.decoderIsEnd(decoderHandler)) {
                            seekZero = 0;
                        }
                        BoxDecoder.decoderFrame(decoderHandler, seekZero, mGLRgbBuffer.array());
                        dataLayer.pushFrameToTexture(mGLRgbBuffer);
                        mGLRgbBuffer.position(0);
                    }
                }
            }
        });
    }
}
Also used : DrawPad(com.lansosdk.box.DrawPad) MediaInfo(com.lansosdk.videoeditor.MediaInfo) com.lansosdk.box.onDrawPadThreadProgressListener(com.lansosdk.box.onDrawPadThreadProgressListener)

Example 3 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class BitmapEditDemoActivity method onClick.

@Override
public void onClick(View v) {
    switch(v.getId()) {
        case R.id.id_bmp2bmp_btnfilter:
            selectFilter();
            break;
        case R.id.id_bmp2bmp_addstick:
            if (stickView != null) {
                Bitmap bmp = null;
                if (stickCnt == 2) {
                    bmp = BitmapFactory.decodeResource(getResources(), R.drawable.stick2);
                } else if (stickCnt == 3) {
                    bmp = BitmapFactory.decodeResource(getResources(), R.drawable.stick3);
                } else if (stickCnt == 4) {
                    bmp = BitmapFactory.decodeResource(getResources(), R.drawable.stick4);
                } else {
                    bmp = BitmapFactory.decodeResource(getResources(), R.drawable.stick5);
                }
                stickCnt++;
                stickView.addBitImage(bmp);
            }
            break;
        case R.id.id_bmp2bmp_addtext:
            showInputDialog();
            break;
        case R.id.id_bmp2bmp_export_btn:
            stickView.disappearIconBorder();
            textStickView.disappearIconBorder();
            drawPadView.setOnDrawPadOutFrameListener(srcBmp.getWidth(), srcBmp.getHeight(), 1, new onDrawPadOutFrameListener() {

                @Override
                public void onDrawPadOutFrame(DrawPad v, Object obj, int type, long ptsUs) {
                    Bitmap bmp = (Bitmap) obj;
                    // 禁止再次提取图片.
                    drawPadView.setOnDrawPadOutFrameListener(0, 0, 0, null);
                    // 显示图片.
                    ivShowImg.setImageBitmap(bmp);
                    findViewById(R.id.id_bmp2bmp_showlayout).setVisibility(View.VISIBLE);
                // startShowOneBitmapActivity(DemoUtil.savePng(bmp));//也可以保存,在另外地方显示,建议异步保存,因为耗时.
                }
            });
            break;
        case R.id.id_bmp2bmp_showimg_btn:
            findViewById(R.id.id_bmp2bmp_showlayout).setVisibility(View.GONE);
            ;
            break;
        default:
            break;
    }
}
Also used : com.lansosdk.box.onDrawPadOutFrameListener(com.lansosdk.box.onDrawPadOutFrameListener) DrawPad(com.lansosdk.box.DrawPad) Bitmap(android.graphics.Bitmap)

Example 4 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class CanvasLayerDemoActivity method initDrawPad.

/**
 * Step1: 初始化 DrawPad 容器
 */
private void initDrawPad() {
    mDrawPadView.setUseMainVideoPts(true);
    // 设置使能 实时录制, 即把正在DrawPad中呈现的画面实时的保存下来,实现所见即所得的模式
    mDrawPadView.setRealEncodeEnable(480, 480, 1000000, (int) mInfo.vFrameRate, editTmpPath);
    // 设置当前DrawPad的宽度和高度,并把宽度自动缩放到父view的宽度,然后等比例调整高度.
    mDrawPadView.setDrawPadSize(480, 480, new onDrawPadSizeChangedListener() {

        @Override
        public void onSizeChanged(int viewWidth, int viewHeight) {
            // TODO Auto-generated method stub
            // 开始DrawPad的渲染线程.
            startDrawPad();
        }
    });
    mDrawPadView.setOnDrawPadProgressListener(new onDrawPadProgressListener() {

        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
            if (currentTimeUs > 20 * 1000 * 1000 && mCanvasLayer != null) {
                mDrawPadView.removeLayer(mCanvasLayer);
                mCanvasLayer = null;
            }
        }
    });
    mDrawPadView.setOnDrawPadThreadProgressListener(new onDrawPadThreadProgressListener() {

        @Override
        public void onThreadProgress(DrawPad v, long currentTimeUs) {
            Log.i(TAG, "ThreadProgress 的时间戳是:" + currentTimeUs);
            frameCnt++;
        }
    });
}
Also used : DrawPad(com.lansosdk.box.DrawPad) com.lansosdk.box.onDrawPadSizeChangedListener(com.lansosdk.box.onDrawPadSizeChangedListener) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener) com.lansosdk.box.onDrawPadThreadProgressListener(com.lansosdk.box.onDrawPadThreadProgressListener) Paint(android.graphics.Paint)

Example 5 with DrawPad

use of com.lansosdk.box.DrawPad in project LanSoEditor_advance by LanSoSdk.

the class Demo1LayerMothedActivity method initDrawPad.

/**
 * 第一步:  init DrawPad 初始化
 */
private void initDrawPad() {
    int padWidth = 480;
    int padHeight = 480;
    /**
     * 设置当前DrawPad的宽度和高度,并把宽度自动缩放到父view的宽度,然后等比例调整高度.
     */
    drawPadView.setDrawPadSize(padWidth, padHeight, new onDrawPadSizeChangedListener() {

        @Override
        public void onSizeChanged(int viewWidth, int viewHeight) {
            startDrawPad();
        }
    });
    drawPadView.setUpdateMode(DrawPadUpdateMode.AUTO_FLUSH, 25);
    drawPadView.setRealEncodeEnable(padWidth, padHeight, 1000000, (int) mInfo.vFrameRate, editTmpPath);
    drawPadView.setOnDrawPadProgressListener(new onDrawPadProgressListener() {

        @Override
        public void onProgress(DrawPad v, long currentTimeUs) {
        }
    });
}
Also used : DrawPad(com.lansosdk.box.DrawPad) com.lansosdk.box.onDrawPadSizeChangedListener(com.lansosdk.box.onDrawPadSizeChangedListener) com.lansosdk.box.onDrawPadProgressListener(com.lansosdk.box.onDrawPadProgressListener)

Aggregations

DrawPad (com.lansosdk.box.DrawPad)28 com.lansosdk.box.onDrawPadProgressListener (com.lansosdk.box.onDrawPadProgressListener)16 com.lansosdk.box.onDrawPadSizeChangedListener (com.lansosdk.box.onDrawPadSizeChangedListener)10 Paint (android.graphics.Paint)9 com.lansosdk.box.onDrawPadCompletedListener (com.lansosdk.box.onDrawPadCompletedListener)9 com.lansosdk.box.onDrawPadThreadProgressListener (com.lansosdk.box.onDrawPadThreadProgressListener)9 com.lansosdk.box.onDrawPadErrorListener (com.lansosdk.box.onDrawPadErrorListener)7 DrawPadCameraView (com.lansosdk.videoeditor.DrawPadCameraView)5 DrawPadCameraView.onViewAvailable (com.lansosdk.videoeditor.DrawPadCameraView.onViewAvailable)5 MediaInfo (com.lansosdk.videoeditor.MediaInfo)5 DrawPadCameraView.doFousEventListener (com.lansosdk.videoeditor.DrawPadCameraView.doFousEventListener)4 com.lansosdk.box.onDrawPadOutFrameListener (com.lansosdk.box.onDrawPadOutFrameListener)3 DrawPadVideoExecute (com.lansosdk.videoeditor.DrawPadVideoExecute)3 Bitmap (android.graphics.Bitmap)2 DrawPadView (com.lansosdk.videoeditor.DrawPadView)2 DrawPadView.onViewAvailable (com.lansosdk.videoeditor.DrawPadView.onViewAvailable)2 DialogInterface (android.content.DialogInterface)1 Surface (android.view.Surface)1 OnClickListener (android.view.View.OnClickListener)1 DrawPadAllExecute (com.lansosdk.box.DrawPadAllExecute)1