2

The algorithm scale down height and width of image and make it look like a center_crop image. i want to get orginal image height and width.This code is from gpu image library. please help

  private void adjustImageScaling() {
    float outputWidth = mOutputWidth;
    float outputHeight = mOutputHeight;
    if (mRotation == Rotation.ROTATION_270 || mRotation == Rotation.ROTATION_90) {
        outputWidth = mOutputHeight;
        outputHeight = mOutputWidth;
    }

    float ratio1 = outputWidth / mImageWidth;
    float ratio2 = outputHeight / mImageHeight;
    float ratioMax = Math.max(ratio1, ratio2);
    int imageWidthNew = Math.round(mImageWidth * ratioMax);
    int imageHeightNew = Math.round(mImageHeight * ratioMax);

    float ratioWidth = imageWidthNew / outputWidth;
    float ratioHeight = imageHeightNew / outputHeight;

    float[] cube = CUBE;
    float[] textureCords = TextureRotationUtil.getRotation(mRotation, mFlipHorizontal, mFlipVertical);
    if (mScaleType == GPUImage.ScaleType.CENTER_CROP) {
        float distHorizontal = (1 - 1 / ratioWidth) / 2;
        float distVertical = (1 - 1 / ratioHeight) / 2;
        textureCords = new float[]{
                addDistance(textureCords[0], distHorizontal), addDistance(textureCords[1], distVertical),
                addDistance(textureCords[2], distHorizontal), addDistance(textureCords[3], distVertical),
                addDistance(textureCords[4], distHorizontal), addDistance(textureCords[5], distVertical),
                addDistance(textureCords[6], distHorizontal), addDistance(textureCords[7], distVertical),
        };
    } else {
        cube = new float[]{
                CUBE[0] / ratioHeight, CUBE[1] / ratioWidth,
                CUBE[2] / ratioHeight, CUBE[3] / ratioWidth,
                CUBE[4] / ratioHeight, CUBE[5] / ratioWidth,
                CUBE[6] / ratioHeight, CUBE[7] / ratioWidth,
        };
    }

    mGLCubeBuffer.clear();
    mGLCubeBuffer.put(cube).position(0);
    mGLTextureBuffer.clear();
    mGLTextureBuffer.put(textureCords).position(0);
}

0 Answers0