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


Java Matrix.scaleM方法代码示例

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


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

示例1: recomputeMatrix

import android.opengl.Matrix; //导入方法依赖的package包/类
/**
 * Re-computes mModelViewMatrix, based on the current values for rotation, scale, and
 * translation.
 */
private void recomputeMatrix() {
    float[] modelView = mModelViewMatrix;

    Matrix.setIdentityM(modelView, 0);
    Matrix.translateM(modelView, 0, mPosX, mPosY, 0.0f);
    if (mAngle != 0.0f) {
        Matrix.rotateM(modelView, 0, mAngle, 0.0f, 0.0f, 1.0f);
    }
    Matrix.scaleM(modelView, 0, mScaleX, mScaleY, 1.0f);
    mMatrixReady = true;
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:16,代码来源:Sprite2d.java

示例2: getLayoutMatrix

import android.opengl.Matrix; //导入方法依赖的package包/类
/**
 * Returns layout transformation matrix that applies an optional mirror effect and compensates
 * for video vs display aspect ratio.
 */
public static float[] getLayoutMatrix(
    boolean mirror, float videoAspectRatio, float displayAspectRatio) {
  float scaleX = 1;
  float scaleY = 1;
  // Scale X or Y dimension so that video and display size have same aspect ratio.
  if (displayAspectRatio > videoAspectRatio) {
    scaleY = videoAspectRatio / displayAspectRatio;
  } else {
    scaleX = displayAspectRatio / videoAspectRatio;
  }
  // Apply optional horizontal flip.
  if (mirror) {
    scaleX *= -1;
  }
  final float matrix[] = new float[16];
  Matrix.setIdentityM(matrix, 0);
  Matrix.scaleM(matrix, 0, scaleX, scaleY, 1);
  adjustOrigin(matrix);
  return matrix;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:25,代码来源:RendererCommon.java

示例3: _drawBox

import android.opengl.Matrix; //导入方法依赖的package包/类
private void _drawBox(float x, float y, float sx, float sy, float r, float g, float b, float a, int tex){
    // scale and translate
  	float[] m = new float[16];
  	Matrix.setIdentityM(m, 0);
  	Matrix.scaleM(m, 0, 2.0f*sx, 2.0f*sy, 1.0f);
  	m[3] += (1.0-2.0*x);
  	m[7] += (1.0/_ratio-2.0*y);
  	//Log.v(TAG,"RATIO IS "+_ratio);
  	float[] m2 = new float[16];      	
  	Matrix.multiplyMM(m2, 0, m, 0, mMVPMatrix, 0);
  	if (tex == -1)
  		mSquare.draw(m2, r, g, b, a);
  	else
  		mSquareTex.draw(m2,r,g,b,a,tex);
    checkGlError("draw");
}
 
开发者ID:efroemling,项目名称:bombsquad-remote-android,代码行数:17,代码来源:GLRenderer.java

示例4: getLayoutMatrix

import android.opengl.Matrix; //导入方法依赖的package包/类
/**
 * Returns layout transformation matrix that applies an optional mirror effect and compensates
 * for video vs display aspect ratio.
 */
public static void getLayoutMatrix(
        final float matrix[], boolean mirror, float videoAspectRatio, float displayAspectRatio) {
  float scaleX = 1;
  float scaleY = 1;
  // Scale X or Y dimension so that video and display size have same aspect ratio.
  if (displayAspectRatio > videoAspectRatio) {
    scaleY = videoAspectRatio / displayAspectRatio;
  } else {
    scaleX = displayAspectRatio / videoAspectRatio;
  }
  // Apply optional horizontal flip.
  if (mirror) {
    scaleX *= -1;
  }
  Matrix.setIdentityM(matrix, 0);
  Matrix.scaleM(matrix, 0, scaleX, scaleY, 1);
  adjustOrigin(matrix);
}
 
开发者ID:Piasy,项目名称:VideoCRE,代码行数:23,代码来源:RendererCommon.java

示例5: setSize

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public void setSize(int width, int height) {
    GLES20.glViewport(0, 0, width, height);
    checkError();
    Matrix.setIdentityM(mMatrices, mCurrentMatrixIndex);
    Matrix.orthoM(mProjectionMatrix, 0, 0, width, 0, height, -1, 1);
    Matrix.translateM(mMatrices, mCurrentMatrixIndex, 0, height, 0);
    Matrix.scaleM(mMatrices, mCurrentMatrixIndex, 1, -1, 1);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:10,代码来源:GLES20Canvas.java

示例6: setMatrix

import android.opengl.Matrix; //导入方法依赖的package包/类
private void setMatrix(ShaderParameter[] params, float x, float y, float width, float height) {
    Matrix.translateM(mTempMatrix, 0, mMatrices, mCurrentMatrixIndex, x, y, 0f);
    Matrix.scaleM(mTempMatrix, 0, width, height, 1f);
    Matrix.multiplyMM(mTempMatrix, MATRIX_SIZE, mProjectionMatrix, 0, mTempMatrix, 0);
    GLES20.glUniformMatrix4fv(params[INDEX_MATRIX].handle, 1, false, mTempMatrix, MATRIX_SIZE);
    checkError();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:8,代码来源:GLES20Canvas.java

示例7: updateViewPort

import android.opengl.Matrix; //导入方法依赖的package包/类
public void updateViewPort() {
    final CameraView cameraView = mCameraViewRef.get();
    if (cameraView != null) {
        final int viewWidth = cameraView.getWidth();
        final int viewHeight = cameraView.getHeight();
        final int previewWidth = cameraView.mPreviewWidth;
        final int previewHeight = cameraView.mPreviewHeight;

        //CenterCrop
        float scaleX = 1.0f;
        float scaleY = 1.0f;
        final double previewRatio = previewWidth * 1.0f / previewHeight;
        final double viewRatio = viewWidth * 1.0f / viewHeight;

        if (previewRatio < viewRatio) {
            scaleY = (float) (previewHeight * 1.0f / (previewWidth / viewRatio));
        } else {
            scaleX = (float) (previewWidth * 1.0f / (previewHeight * viewRatio));
        }

        Log.d(TAG, "scaleX:" + scaleX + ",scaleY:" + scaleY + ",previewRatio:" + previewRatio + ",viewRatio:" + viewRatio);
        Matrix.setIdentityM(mMvpMatrix, 0);
        Matrix.scaleM(mMvpMatrix, 0, scaleX, scaleY, 1.0f);

        if (cameraView.mGLSurfaceFilter != null) {
            cameraView.mGLSurfaceFilter.setMvpMatrix(mMvpMatrix);
        }

    }
}
 
开发者ID:LeonHover,项目名称:MediaCodecRecorder,代码行数:31,代码来源:CameraView.java

示例8: _drawBG

import android.opengl.Matrix; //导入方法依赖的package包/类
private void _drawBG(float r, float g, float b, float a, int tex){
  	float[] m = new float[16];
	Matrix.setIdentityM(m, 0);
  	Matrix.scaleM(m, 0, -2.0f, 2.0f, 1.0f);

  	//float[] m2 = new float[16];      	
  	//Matrix.multiplyMM(m, 0, m, 0, mMVPMatrix, 0);
  	if (tex == -1)
  		mSquare.draw(m, r, g, b, a);
  	else
  		mSquareTex.draw(m,r,g,b,a,_bgTex);
    checkGlError("draw");
}
 
开发者ID:efroemling,项目名称:bombsquad-remote-android,代码行数:14,代码来源:GLRenderer.java

示例9: getScaleMatrix

import android.opengl.Matrix; //导入方法依赖的package包/类
/**
 * Gets the matrix that will be used to scale this 3DString
 * @return float[] object
 */
public float[] getScaleMatrix() {
    Matrix.setIdentityM(this.scaleMatrix, 0);

    Matrix.scaleM(this.scaleMatrix, 0, this.getScaleX(), this.getScaleY(), this.getScaleZ());

    return this.scaleMatrix;
}
 
开发者ID:snada,项目名称:BitmapFontLoader,代码行数:12,代码来源:Bitmap3DString.java

示例10: getScaleMatrix

import android.opengl.Matrix; //导入方法依赖的package包/类
/**
 * Gets the matrix that will be used to scale this 3D char
 * @return float[] object
 */
public float[] getScaleMatrix() {
    Matrix.setIdentityM(scaleMatrix, 0);

    Matrix.scaleM(
        scaleMatrix,
        0,
        (this.bitmapChar.getWidth() * this.getScaleX()),
        (this.bitmapChar.getHeight() * this.getScaleY()),
        this.getScaleZ()
    );

    return this.scaleMatrix;
}
 
开发者ID:snada,项目名称:BitmapFontLoader,代码行数:18,代码来源:Bitmap3DChar.java

示例11: draw

import android.opengl.Matrix; //导入方法依赖的package包/类
void draw() {
    EGLDisplay mSavedEglDisplay = EGL14.eglGetCurrentDisplay();
    EGLSurface mSavedEglDrawSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    EGLSurface mSavedEglReadSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_READ);
    EGLContext mSavedEglContext = EGL14.eglGetCurrentContext();
    {
        AndroidUntil.checkGlError("draw_S");
        if (mRecorderImpl.isFirstSetup()) {
            mRecorderImpl.startSwapAsync();
            mRecorderImpl.makeCurrent();
            AndroidUntil.checkGlError("initGL_S");

            mProgram = AndroidUntil.createProgram();
            maPositionHandle = GLES20.glGetAttribLocation(mProgram, "position");
            maTextCodeHandle = GLES20.glGetAttribLocation(mProgram, "inputTextureCoordinate");
            muSamplerHandle = GLES20.glGetUniformLocation(mProgram, "uSampler");
            muPosMtxHandle = GLES20.glGetUniformLocation(mProgram, "uPosMtx");

            Matrix.scaleM(mSymmetryMtx, 0, -1, 1, 1);
            GLES20.glDisable(GLES20.GL_DEPTH_TEST);
            GLES20.glDisable(GLES20.GL_CULL_FACE);
            GLES20.glDisable(GLES20.GL_BLEND);
            AndroidUntil.checkGlError("initGL_E");
        } else {
            mRecorderImpl.makeCurrent();
        }
        GLES20.glViewport(0, 0, mVideoWidth, mVideoHeight);
        GLES20.glClearColor(0f, 0f, 0f, 1f);
        GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glUseProgram(mProgram);
        mNormalVtxBuf.position(0);
        GLES20.glVertexAttribPointer(maPositionHandle,
                3, GLES20.GL_FLOAT, false, 4 * 3, mNormalVtxBuf);
        GLES20.glEnableVertexAttribArray(maPositionHandle);
        mCameraVertexCoordinatesBuffer.position(0);
        GLES20.glVertexAttribPointer(maTextCodeHandle,
                2, GLES20.GL_FLOAT, false, 4 * 2, mCameraVertexCoordinatesBuffer);
        GLES20.glEnableVertexAttribArray(maTextCodeHandle);
        GLES20.glUniform1i(muSamplerHandle, 0);
        GLES20.glUniformMatrix4fv(muPosMtxHandle, 1, false, mNormalMtx, 0);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mFboTexId);
        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

        mRecorderImpl.swapBuffers();
        AndroidUntil.checkGlError("draw_E");
    }
    if (!EGL14.eglMakeCurrent(
            mSavedEglDisplay,
            mSavedEglDrawSurface,
            mSavedEglReadSurface,
            mSavedEglContext)) {
        throw new RuntimeException("eglMakeCurrent failed");
    }
}
 
开发者ID:wuyisheng,项目名称:libRtmp,代码行数:56,代码来源:RendererImpl.java

示例12: flip

import android.opengl.Matrix; //导入方法依赖的package包/类
/**
 * image mirror
 * @param x horizontal flip
 * @param y vertical flip
 */
public void flip(boolean x, boolean y) {
    if (x || y) {
        Matrix.scaleM(mMVPMatrix, 0, x ? -1 : 1, y ? -1 : 1, 1);
    }
}
 
开发者ID:AgoraIO,项目名称:Agora-Video-Source-Android,代码行数:11,代码来源:TextureRenderer.java

示例13: handleMessage

import android.opengl.Matrix; //导入方法依赖的package包/类
@Override
public boolean handleMessage(Message msg) {
    switch (msg.what) {
        case WINDOW_MSG_CALCULATE_MVP_MATRIX:
            Matrix.setIdentityM(mMVPMatrix, 0);
            //平铺
            float scaleX = 1.0f;
            float scaleY = 1.0f;
            final double previewRatio = mPreviewWidth * 1.0f / mPreviewHeight;
            final double viewRatio = mWidth * 1.0f / mHeight;

            if (previewRatio < viewRatio) {
                scaleY = (float) (mPreviewHeight * 1.0f / (mPreviewWidth / viewRatio));
            } else {
                scaleX = (float) (mPreviewWidth * 1.0f / (mPreviewHeight * viewRatio));
            }

            Matrix.scaleM(mMVPMatrix, 0, scaleX, scaleY, 1.0f);
            break;
        case WINDOW_MSG_ATTACH_SURFACE:
            Log.d(TAG, "WINDOW_MSG_ATTACH_SURFACE");
            Surface surface = (Surface) msg.obj;
            mGLSurface.createSurface(surface);
            mGLSurface.makeCurrent();
            break;
        case WINDOW_MSG_DETACH_SURFACE:
            Log.d(TAG, "WINDOW_MSG_DETACH_SURFACE");
            releaseGLSurface();
            break;
        case WINDOW_MSG_UPDATE:

            Log.d(TAG, "WINDOW_MSG_UPDATE");
            if (mGLSurface == null) {
                return false;
            }

            SurfaceTexture surfaceTexture = (SurfaceTexture) msg.obj;
            int textureIndex = msg.arg1;
            long presentationTime = msg.getData().getLong(UPDATE_PRESENTATION_TIME_KEY);

            surfaceTexture.getTransformMatrix(mTextureTransformMatrix);
            mGLSurface.makeCurrent();
            mGLSurfaceFilter.draw(textureIndex, mMVPMatrix, mTextureTransformMatrix);
            mGLSurface.setPresentationTime(presentationTime);
            mGLSurface.swapBuffers();

            final CallBack callBack = mCallBack;
            if (callBack != null) {
                callBack.onOffScreenWindowUpdate();
            }
            break;
    }
    return true;
}
 
开发者ID:LeonHover,项目名称:MediaCodecRecorder,代码行数:55,代码来源:OffScreenWindow.java

示例14: scaleMVPMatrix

import android.opengl.Matrix; //导入方法依赖的package包/类
public void scaleMVPMatrix(float x, float y) {
    Matrix.setIdentityM(IDENTITY_MATRIX, 0);
    Matrix.scaleM(IDENTITY_MATRIX, 0, x, y, 1f);
}
 
开发者ID:hoanganhtuan95ptit,项目名称:EditPhoto,代码行数:5,代码来源:FullFrameRect.java

示例15: scaleM

import android.opengl.Matrix; //导入方法依赖的package包/类
static void scaleM(float[] matrixData, float x, float y, float z) {
    Matrix.scaleM(matrixData, 0, x, y, z);
}
 
开发者ID:gplibs,项目名称:android-magic-surface-view,代码行数:4,代码来源:MatrixManager.java


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