void changeSaturation(int value) { float saturation = (value + 100) / 100f; mColorMatrix.reset(); mColorMatrix.setSaturation(saturation); mAdjustPaint.setColorFilter(new ColorMatrixColorFilter(mColorMatrix)); getViewState().onImageAdjusted(mAdjustPaint); }
void changeBrightness(int value) { float brightness = value / 2; mColorMatrix.reset(); mColorMatrix.set(new float[]{ 1, 0, 0, 0, brightness, 0, 1, 0, 0, brightness, 0, 0, 1, 0, brightness, 0, 0, 0, 1, 0 }); mAdjustPaint.setColorFilter(new ColorMatrixColorFilter(mColorMatrix)); getViewState().onImageAdjusted(mAdjustPaint); }
void changeWarmth(int value) { float warmth = (value / 220) / 2; mColorMatrix.reset(); mColorMatrix.set( new float[]{ 1, 0, 0, warmth, 0, 0, 1, 0, warmth / 2, 0, 0, 0, 1, warmth / 4, 0, 0, 0, 0, 1, 0 }); mAdjustPaint.setColorFilter(new ColorMatrixColorFilter(mColorMatrix)); getViewState().onImageAdjusted(mAdjustPaint); }
void changeContrast(int value) { float input = value / 100f; float scale = input + 1f; float contrast = (-0.5f * scale + 0.5f) * 255f; mColorMatrix.reset(); mColorMatrix.set( new float[]{ scale, 0, 0, 0, contrast, 0, scale, 0, 0, contrast, 0, 0, scale, 0, contrast, 0, 0, 0, 1, 0} ); mAdjustPaint.setColorFilter( new ColorMatrixColorFilter(mColorMatrix)); getViewState().onImageAdjusted(mAdjustPaint); }
saturationMatrix.reset(); saturationMatrix.setSaturation(saturationNum); break; brightnessMatrix.reset(); brightnessMatrix.set(new float[]{1, 0, 0, 0, brightNum, 0, 1, 0, 0, brightNum, 0, 0, 1, 0, brightNum, 0, 0, 0, 1, 0}); regulateBright = (1 - contrastNum) * 128; contrastMatrix.reset(); contrastMatrix.set(new float[]{contrastNum, 0, 0, 0, regulateBright, 0, contrastNum, 0, 0, regulateBright, mAllMatrix.reset(); mAllMatrix.postConcat(saturationMatrix); mAllMatrix.postConcat(brightnessMatrix);
mSaturationMatrix.reset(); mSaturationMatrix.setSaturation(mSaturationValue); } else if (flag == 1) mHueMatrix.reset(); mHueMatrix.setRotate(0, mHueValue); mHueMatrix.setRotate(1, mHueValue); } else if (flag == 2) mLumMatrix.reset(); mLumMatrix.setScale(mLumValue, mLumValue, mLumValue, 1); mAllMatrix.reset(); mAllMatrix.postConcat(mHueMatrix); mAllMatrix.postConcat(mSaturationMatrix);
cMatrix.reset(); return bitmap;
cMatrix.reset(); return bitmap;
break; default: mColorMatrix.reset(); mAdjustPaint.setColorFilter(new ColorMatrixColorFilter(mColorMatrix)); break;