List of usage examples for android.graphics ColorMatrix setSaturation
public void setSaturation(float sat)
From source file:edu.cloud.iot.reception.ocr.FaceRecognitionActivity.java
public Bitmap toGrayscale(Bitmap bmpOriginal) { int height = bmpOriginal.getHeight(); int width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmpGrayscale); Paint paint = new Paint(); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f);/*from w w w. j av a 2 s .co m*/ c.drawBitmap(bmpOriginal, 0, 0, paint); return bmpGrayscale; }
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 ww w . j ava2 s .co 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:image_cache.ImageWorker.java
public void toGrayscale(String buildFBFriendImageUrl, ImageView imageView) { if (buildFBFriendImageUrl == null) { return;/*from w w w . j ava2s. c om*/ } Bitmap bmpOriginal = null; if (mImageCache != null) { bmpOriginal = mImageCache.getBitmapFromMemCache(String.valueOf(buildFBFriendImageUrl)); } if (bmpOriginal != null) { // Bitmap found in memory cache imageView.setImageBitmap(bmpOriginal); imageView.setBackgroundColor(0); } else if (cancelPotentialWork(buildFBFriendImageUrl, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been // pulled from the // framework and slightly modified. Refer to the docs at the top of // the class // for more info on what was changed. task.executeOnExecutor(ImageTask.DUAL_THREAD_EXECUTOR, buildFBFriendImageUrl); } int width, height; height = bmpOriginal.getHeight(); width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); Canvas c = new Canvas(bmpGrayscale); Paint paint = new Paint(); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); imageView.setImageBitmap(bmpGrayscale); }
From source file:com.example.hudpassthrough.BluetoothChat.java
private Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight();/*from ww w . j ava 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 cm = new ColorMatrix(); cm.setSaturation(0); ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); return bmpGrayscale; }
From source file:com.farmerbb.taskbar.service.DashboardService.java
private void addPlaceholder(int cellId) { FrameLayout placeholder = (FrameLayout) cells.get(cellId).findViewById(R.id.placeholder); SharedPreferences pref = U.getSharedPreferences(this); String providerName = pref.getString("dashboard_widget_" + Integer.toString(cellId) + "_provider", "null"); if (!providerName.equals("null")) { ImageView imageView = (ImageView) placeholder.findViewById(R.id.placeholder_image); ComponentName componentName = ComponentName.unflattenFromString(providerName); List<AppWidgetProviderInfo> providerInfoList = mAppWidgetManager .getInstalledProvidersForProfile(Process.myUserHandle()); for (AppWidgetProviderInfo info : providerInfoList) { if (info.provider.equals(componentName)) { Drawable drawable = info.loadPreviewImage(this, -1); if (drawable == null) drawable = info.loadIcon(this, -1); ColorMatrix matrix = new ColorMatrix(); matrix.setSaturation(0); imageView.setImageDrawable(drawable); imageView.setColorFilter(new ColorMatrixColorFilter(matrix)); break; }//www.j a v a 2 s. c o m } } placeholder.setVisibility(View.VISIBLE); }
From source file:com.yk.notification.util.BitmapUtil.java
/** * ?// w w w. j av a 2 s . c om * * @param bitmap * * @param saturationValue * * @return ?? */ public static Bitmap saturation(Bitmap bitmap, int saturationValue) { // ?? float newSaturationValue = saturationValue * 1.0F / 127; // ColorMatrix saturationColorMatrix = new ColorMatrix(); // saturationColorMatrix.setSaturation(newSaturationValue); // Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(saturationColorMatrix)); // 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 www .j a v a 2 s . c o 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; }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
public Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight();/*from w w w .j a v a2 s . c om*/ width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmpGrayscale); Paint paint = new Paint(); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); return bmpGrayscale; }
From source file:com.aimfire.gallery.cardboard.PhotoActivity.java
public Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight();/* w w w . j a va2s .c o m*/ width = bmpOriginal.getWidth(); Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); Canvas c = new Canvas(bmpGrayscale); Paint paint = new Paint(); ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f); c.drawBitmap(bmpOriginal, 0, 0, paint); bmpOriginal.recycle(); return bmpGrayscale; }
From source file:com.ksharkapps.musicnow.ui.activities.AudioPlayerActivity.java
protected Drawable convertToGrayscale(Drawable drawable) { ColorMatrix matrix = new ColorMatrix(); matrix.setSaturation(0); ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix); drawable.setColorFilter(filter);/* ww w .j av a2s . com*/ return drawable; }