cats-oss / android-gpuimage

Android filters based on OpenGL (idea from GPUImage for iOS)
9k stars 2.27k forks source link

How to remove the black background of gpuimage #284

Open TroyRay opened 8 years ago

TroyRay commented 8 years ago

How to remove the black background of gpuimage?

JitenNumberTank commented 8 years ago

+1

DzwsGo commented 8 years ago

please

Hitexroid commented 8 years ago

it's my question too .

thinhdt commented 7 years ago

My issue . Can anyone help me ? Thanks

Seddiks commented 6 years ago

anyone found solution?

tochange commented 4 years ago

??

milan15440 commented 1 year ago

You can use set ascept ratio method on GPUImageView gpuImageView.setRatio(getDecimalEquivalent(bitmap.width,bitmap.height)) gpuImageView.setImage(bitmap)

private fun getDecimalEquivalent(width: Int, height: Int): Float { val factor = greatestCommonFactor(width, height) val widthRatio: Float = width / factor val heightRatio: Float = height / factor return widthRatio / heightRatio }

private fun greatestCommonFactor(width: Int, height: Int): Float {
    return if (height == 0) width.toFloat() else greatestCommonFactor(height, width % height)
}