Android ColorMatrix - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ColorMatrix class.

This code example shows how to use the following methods:setSaturation
        mGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
        mGlowColorFocusedPaint.setColor(context.getTheme().resolveAttribute(
                android.R.attr.colorFocusedHighlight, value, true) ? value.data : 0xffff8e00);
        mGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
 
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0.2f);
 
        mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                Paint.FILTER_BITMAP_FLAG));
    } 
 
    public Drawable createIconDrawable(Drawable src) {
        Bitmap scaled = createIconBitmap(src);
 
        StateListDrawable result = new StateListDrawable();
 
        result.addState(new int[] { android.R.attr.state_focused },
                new BitmapDrawable(createSelectedBitmap(scaled, false)));
        result.addState(new int[] { android.R.attr.state_pressed },
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:postConcat, reset
This code example shows how to use the following methods:postConcat, setSaturation
This code example shows how to use the following methods:getArray, postConcat, setRGB2YUV
 
        int r = Color.red(color);
        int g = Color.green(color);
        int b = Color.blue(color);
 
        ColorMatrix cm = new ColorMatrix();
        ColorMatrix tmp = new ColorMatrix();
 
        cm.setRGB2YUV();
        tmp.setRotate(0, deg);
        cm.postConcat(tmp);
        tmp.setYUV2RGB();
        cm.postConcat(tmp);
 
        final float[] a = cm.getArray();
 
        int ir = Math.round(a[0] * r +  a[1] * g +  a[2] * b);
        int ig = Math.round(a[5] * r +  a[6] * g +  a[7] * b);
        int ib = Math.round(a[10] * r + a[11] * g + a[12] * b);
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:set
				Bitmap.Config.RGB_565);
		Canvas c = new Canvas(bmpGrayscale);
		Paint paint = new Paint();
		paint.setColorFilter(null);
		c.drawBitmap(bmpGrayscale, 0, 0, paint);
		ColorMatrix cm = new ColorMatrix();
		getValueBlackAndWhite(); 
		cm.set(carray);
		ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
		paint.setColorFilter(f);
		c.drawBitmap(bmpOriginal, 0, 0, paint);
		return bmpGrayscale;
	} 
 
	public static void getValueSaturation() 
	{ 
		// 高饱和度 
		carray[0] = 5;
		carray[1] = 0;
		carray[2] = 0;
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSaturation
This code example shows how to use the following methods:
        Bitmap bitmap2 = Robolectric.newInstanceOf(Bitmap.class);
        shadowOf(bitmap2).appendDescription("Bitmap Two");
 
        Canvas canvas = new Canvas(bitmap1);
        Paint paint = new Paint();
        paint.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix()));
        canvas.drawBitmap(bitmap2, new Matrix(), paint);
 
        assertEquals("Bitmap One\nBitmap Two with ColorMatrixColorFilter<1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0> transformed by matrix", shadowOf(bitmap1).getDescription());
    } 
 
    @Test 
    public void visualize_shouldReturnDescription() throws Exception { 
        Bitmap bitmap = Robolectric.newInstanceOf(Bitmap.class);
        shadowOf(bitmap).appendDescription("Bitmap One");
 
        assertEquals("Bitmap One", Robolectric.visualize(bitmap));
 
    } 
     
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSaturation
        mGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
        mGlowColorFocusedPaint.setColor(context.getTheme().resolveAttribute(
                android.R.attr.colorFocusedHighlight, value, true) ? value.data : 0xffff8e00);
        mGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
 
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0.2f);
 
        mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                Paint.FILTER_BITMAP_FLAG));
    } 
 
    public Drawable createIconDrawable(Drawable src) {
        Bitmap scaled = createIconBitmap(src);
 
        StateListDrawable result = new StateListDrawable();
 
        result.addState(new int[] { android.R.attr.state_focused },
                new BitmapDrawable(createSelectedBitmap(scaled, false)));
        result.addState(new int[] { android.R.attr.state_pressed },
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSaturation
	 *            true if the grayscale should be activated. 
	 */ 
	public void setImageGrayscale(boolean greyscale) {
		this.greyscale = greyscale;
		if (greyscale) {
			ColorMatrix matrix = new ColorMatrix();
			matrix.setSaturation(0);
			imageView.setColorFilter(new ColorMatrixColorFilter(matrix));
		} else { 
			imageView.setColorFilter(null);
		} 
	} 
 
	public boolean isOpacity() { 
		return opacity;
	} 
 
	public boolean isGreyscale() { 
		return greyscale;
	} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getArray, setRGB2YUV
		private void updateYUVfromRGB() { 
			float r = mRGB[0] / 255.0f;
			float g = mRGB[1] / 255.0f;
			float b = mRGB[2] / 255.0f;
 
			ColorMatrix cm = new ColorMatrix();
			cm.setRGB2YUV();
			final float[] a = cm.getArray();
 
			mYUV[0] = a[0] * r + a[1] * g + a[2] * b;
			mYUV[0] = pinToUnit(mYUV[0]);
			mYUV[1] = a[5] * r + a[6] * g + a[7] * b;
			mYUV[1] = pin(mYUV[1], -.5f, .5f);
			mYUV[2] = a[10] * r + a[11] * g + a[12] * b;
			mYUV[2] = pin(mYUV[2], -.5f, .5f);
		} 
 
		/** 
		 * Keep all colorspace representations in sync. 
		 */ 
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android ColorMatrix Questions & Answers:

See Code Examples for Android ColorMatrix Methods: