当前位置: 首页>>代码示例>>Java>>正文


Java SurfaceView.getWidth方法代码示例

本文整理汇总了Java中android.view.SurfaceView.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java SurfaceView.getWidth方法的具体用法?Java SurfaceView.getWidth怎么用?Java SurfaceView.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.SurfaceView的用法示例。


在下文中一共展示了SurfaceView.getWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawFrame

import android.view.SurfaceView; //导入方法依赖的package包/类
/**
 * Draws a frame onto the SurfaceView and the encoder surface.
 * <p>
 * This will be called whenever we get a new preview frame from the camera.  This runs
 * on the UI thread, which ordinarily isn't a great idea -- you really want heavy work
 * to be on a different thread -- but we're really just throwing a few things at the GPU.
 * The upside is that we don't have to worry about managing state changes between threads.
 * <p>
 * If there was a pending frame available notification when we shut down, we might get
 * here after onPause().
 */
private void drawFrame() {
    //Log.d(TAG, "drawFrame");
    if (mEglCore == null) {
        Log.d(TAG, "Skipping drawFrame after shutdown");
        return;
    }

    // Latch the next frame from the camera.
    mDisplaySurface.makeCurrent();
    mCameraTexture.updateTexImage();
    mCameraTexture.getTransformMatrix(mTmpMatrix);

    // Fill the SurfaceView with it.
    SurfaceView sv = (SurfaceView) findViewById(R.id.continuousCapture_surfaceView);
    int viewWidth = sv.getWidth();
    int viewHeight = sv.getHeight();
    GLES20.glViewport(0, 0, viewWidth, viewHeight);
    mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
    drawExtra(mFrameNum, viewWidth, viewHeight);
    mDisplaySurface.swapBuffers();

    // Send it to the video encoder.
    if (!mFileSaveInProgress) {
        mEncoderSurface.makeCurrent();
        GLES20.glViewport(0, 0, VIDEO_WIDTH, VIDEO_HEIGHT);
        mFullFrameBlit.drawFrame(mTextureId, mTmpMatrix);
        drawExtra(mFrameNum, VIDEO_WIDTH, VIDEO_HEIGHT);
        mCircEncoder.frameAvailableSoon();
        mEncoderSurface.setPresentationTime(mCameraTexture.getTimestamp());
        mEncoderSurface.swapBuffers();
    }

    mFrameNum++;
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:46,代码来源:ContinuousCaptureActivity.java


注:本文中的android.view.SurfaceView.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。