List of usage examples for android.graphics ColorMatrix setScale
public void setScale(float rScale, float gScale, float bScale, float aScale)
From source file:Main.java
public static Bitmap toSepia(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight();//ww w . ja va 2 s. c om width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); Canvas c = new Canvas(bmpGrayscale); Paint paint = new Paint(); ColorMatrix grMatrix = new ColorMatrix(); grMatrix.setSaturation(0); ColorMatrix scMatrix = new ColorMatrix(); scMatrix.setScale(1f, .85f, .72f, 1.0f); grMatrix.setConcat(scMatrix, grMatrix); ColorMatrixColorFilter f = new ColorMatrixColorFilter(grMatrix); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); return bmpGrayscale; }
From source file:Main.java
public static Bitmap handleImageEffect(Bitmap bm, float hue, float saturation, float lum) { Bitmap bmp = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); Paint paint = new Paint(); ColorMatrix hueMatrix = new ColorMatrix(); hueMatrix.setRotate(0, hue);//from w ww .j av a 2 s . c o m hueMatrix.setRotate(1, hue); hueMatrix.setRotate(2, hue); ColorMatrix saturationMatrix = new ColorMatrix(); saturationMatrix.setSaturation(saturation); ColorMatrix lumMatrix = new ColorMatrix(); lumMatrix.setScale(lum, lum, lum, 1); ColorMatrix imageMatrix = new ColorMatrix(); imageMatrix.postConcat(hueMatrix); imageMatrix.postConcat(saturationMatrix); imageMatrix.postConcat(lumMatrix); paint.setColorFilter(new ColorMatrixColorFilter(imageMatrix)); canvas.drawBitmap(bm, 0, 0, paint); return bmp; }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
static void setBackground(View v, Bitmap bm) { if (bm == null) { v.setBackgroundResource(0);// ww w .ja v a 2 s.c o m return; } int vwidth = v.getWidth(); int vheight = v.getHeight(); int bwidth = bm.getWidth(); int bheight = bm.getHeight(); float scalex = (float) vwidth / bwidth; float scaley = (float) vheight / bheight; float scale = Math.max(scalex, scaley) * 1.3f; Bitmap.Config config = Bitmap.Config.ARGB_8888; Bitmap bg = Bitmap.createBitmap(vwidth, vheight, config); Canvas c = new Canvas(bg); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setFilterBitmap(true); ColorMatrix greymatrix = new ColorMatrix(); greymatrix.setSaturation(0); ColorMatrix darkmatrix = new ColorMatrix(); darkmatrix.setScale(.3f, .3f, .3f, 1.0f); greymatrix.postConcat(darkmatrix); ColorFilter filter = new ColorMatrixColorFilter(greymatrix); paint.setColorFilter(filter); Matrix matrix = new Matrix(); matrix.setTranslate(-bwidth / 2, -bheight / 2); // move bitmap center to origin matrix.postRotate(10); matrix.postScale(scale, scale); matrix.postTranslate(vwidth / 2, vheight / 2); // Move bitmap center to view center c.drawBitmap(bm, matrix, paint); v.setBackgroundDrawable(new BitmapDrawable(bg)); }
From source file:com.derrick.movies.MovieDetailsActivity.java
private ColorMatrix geColorMatrix() { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.setSaturation(2);//from w w w .j a v a 2 s .com ColorMatrix colorScale = new ColorMatrix(); colorScale.setScale(1, 1, 0.8f, 1); colorMatrix.postConcat(colorScale); return colorMatrix; }
From source file:com.bar.foldinglayout.sample.FoldingLayoutActivity.java
@SuppressLint("NewApi") @Override//from w ww . j a v a2s . c om protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fold); mImageView = (ImageView) findViewById(R.id.image_view); mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING); mImageView.setScaleType(ImageView.ScaleType.FIT_XY); mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image)); if (IS_ISC) { //mTextureView = new TextureView(this); //mTextureView.setSurfaceTextureListener(mSurfaceTextureListener); } mAnchorSeekBar = (SeekBar) findViewById(R.id.anchor_seek_bar); mFoldLayout = (FoldingLayout) findViewById(R.id.fold_view); mFoldLayout.setFoldListener(mOnFoldListener); mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener); mItemSelectedListener = new ItemSelectedListener(); mDefaultPaint = new Paint(); mSepiaPaint = new Paint(); ColorMatrix m1 = new ColorMatrix(); ColorMatrix m2 = new ColorMatrix(); m1.setSaturation(0); m2.setScale(1f, .95f, .82f, 1.0f); m1.setConcat(m2, m1); mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1)); }
From source file:com.example.android.foldinglayout.FoldingLayoutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fold); mImageView = (ImageView) findViewById(R.id.image_view); mImageView.setPadding(ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING, ANTIALIAS_PADDING); mImageView.setScaleType(ImageView.ScaleType.FIT_XY); mImageView.setImageDrawable(getResources().getDrawable(R.drawable.image)); if (hasApiLevel(Build.VERSION_CODES.ICE_CREAM_SANDWICH)) { initTextureView();//from w w w.ja v a 2 s . c o m } mAnchorSeekBar = (SeekBar) findViewById(R.id.anchor_seek_bar); mFoldLayout = (FoldingLayout) findViewById(R.id.fold_view); mFoldLayout.setBackgroundColor(Color.BLACK); mFoldLayout.setFoldListener(mOnFoldListener); mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop(); mAnchorSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener); mScrollGestureDetector = new GestureDetector(this, new ScrollGestureDetector()); mItemSelectedListener = new ItemSelectedListener(); mDefaultPaint = new Paint(); mSepiaPaint = new Paint(); ColorMatrix m1 = new ColorMatrix(); ColorMatrix m2 = new ColorMatrix(); m1.setSaturation(0); m2.setScale(1f, .95f, .82f, 1.0f); m1.setConcat(m2, m1); mSepiaPaint.setColorFilter(new ColorMatrixColorFilter(m1)); }
From source file:com.yk.notification.util.BitmapUtil.java
/** * ?/* w w w .j a v a 2 s . c om*/ * * @param bitmap * * @param lumValue * * @return ?? */ public static Bitmap lum(Bitmap bitmap, int lumValue) { // ?? float newlumValue = lumValue * 1.0F / 127; // ColorMatrix lumColorMatrix = new ColorMatrix(); // lumColorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1); // Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(lumColorMatrix)); // Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); // canvas.drawBitmap(bitmap, 0, 0, paint); return newBitmap; }
From source file:com.yk.notification.util.BitmapUtil.java
/** * ???/*from w w w . ja va2 s .co m*/ * * @param bitmap * * @param lumValue * * @param hueValue * * @param saturationValue * * @return ???? */ public static Bitmap lumAndHueAndSaturation(Bitmap bitmap, int lumValue, int hueValue, int saturationValue) { // ?? float newSaturationValue = saturationValue * 1.0F / 127; // ?? float newlumValue = lumValue * 1.0F / 127; // ?? float newHueValue = (hueValue - 127) * 1.0F / 127 * 180; // ColorMatrix colorMatrix = new ColorMatrix(); // colorMatrix.setSaturation(newSaturationValue); // colorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1); // colorMatrix.setRotate(0, newHueValue); // colorMatrix.setRotate(1, newHueValue); // ? colorMatrix.setRotate(2, newHueValue); // Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); // Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(newBitmap); // canvas.drawBitmap(bitmap, 0, 0, paint); return newBitmap; }