Code example for ColorMatrix

Methods: setsetSaturation

0
 
		 
		switch(colorType){
			//컬러  
			case COLOR_TYPE_NORMAL:
				cm.set(new float[] { scale, 0, 0, 0, 0, 0, scale, 0, 0, 0, 0, 0, scale,
						0, 0, 0, 0, 0, 1, 0 }); 
				break; 
				 
			//흑백 
			case COLOR_TYPE_BLACK:
				cm.set(new float[] { scale, 0, 0, 0, 0, 0, scale, 0, 0, 0, 0, 0, scale,
						0, 0, 0, 0, 0, 1, 0 }); 
				cm.setSaturation(0);
				break; 
			 
			//채도 색상변경 
			case COLOR_TYPE_CHAEDO:
				cm.set(new ColorMatrix(new float[] { 0.5f, 0.5f, 0.5f, 0, 0, 0.5f,
						0.5f, 0.5f, 0, 0, 0.5f, 0.5f, 0.5f, 0, 0, 0, 0, 0, 1, 0, 0, 0, 
						0, 0, 0, 1, 0 })); 
				 cm.set(new float[] {
				 scale, 0, 0, 0, translate,
				 0, scale, 0, 0, translate,
				 0, 0, scale, 0, translate,
				 0, 0, 0, 1, 0 }); 
				break; 
		} 
	} 
	 
	private int colorType = 0;
	public void setColorType(int colorType){
		this.colorType = colorType;
	} 
	 
	public int getColorType(){ 
		return colorType;
	} 
 
	@Override 
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		ColorMatrix cm = new ColorMatrix();
 
		float contrast = mAngle / 180.f;
		setContrast(cm, contrast);
		setColorFilter(new ColorMatrixColorFilter(cm));
	} 
Experience pair programming with AI  Get Codota for Java