List of usage examples for android.graphics ColorMatrix setSaturation
public void setSaturation(float sat)
From source file:com.f2prateek.dfg.core.GenerateFrameService.java
@Override public void startingImage(Bitmap screenshot) { // Create the large notification icon int imageWidth = screenshot.getWidth(); int imageHeight = screenshot.getHeight(); int iconSize = resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); final int shortSide = imageWidth < imageHeight ? imageWidth : imageHeight; // Check for if config is null, http://crashes.to/s/dd0857c8648 Bitmap preview = Bitmap.createBitmap(shortSide, shortSide, screenshot.getConfig() == null ? Bitmap.Config.ARGB_8888 : screenshot.getConfig()); Canvas c = new Canvas(preview); Paint paint = new Paint(); ColorMatrix desat = new ColorMatrix(); desat.setSaturation(0.25f); paint.setColorFilter(new ColorMatrixColorFilter(desat)); Matrix matrix = new Matrix(); matrix.postTranslate((shortSide - imageWidth) / 2, (shortSide - imageHeight) / 2); c.drawBitmap(screenshot, matrix, paint); c.drawColor(0x40FFFFFF);//from w w w. j a va2s . c om Bitmap croppedIcon = Bitmap.createScaledBitmap(preview, iconSize, iconSize, true); Intent nullIntent = new Intent(this, MainActivity.class); nullIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationBuilder = new NotificationCompat.Builder(this) .setTicker(resources.getString(R.string.screenshot_saving_ticker)) .setContentTitle(resources.getString(R.string.screenshot_saving_title)) .setSmallIcon(R.drawable.ic_stat_app_notification) .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(preview)) .setContentIntent(PendingIntent.getActivity(this, 0, nullIntent, 0)) .setWhen(System.currentTimeMillis()).setProgress(0, 0, true).setLargeIcon(croppedIcon); Notification n = notificationBuilder.build(); n.flags |= Notification.FLAG_NO_CLEAR; notificationManager.notify(DFG_NOTIFICATION_ID, n); }
From source file:com.sspai.dkjt.service.GenerateFrameService.java
@Override public void startingImage(Bitmap screenshot) { // Create the large notification icon int imageWidth = screenshot.getWidth(); int imageHeight = screenshot.getHeight(); int iconSize = resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); final int shortSide = imageWidth < imageHeight ? imageWidth : imageHeight; // Check for if config is null, http://crashes.to/s/dd0857c8648 Bitmap preview = Bitmap.createBitmap(shortSide, shortSide, screenshot.getConfig() == null ? Bitmap.Config.ARGB_8888 : screenshot.getConfig()); Canvas c = new Canvas(preview); Paint paint = new Paint(); ColorMatrix desat = new ColorMatrix(); desat.setSaturation(0.25f); paint.setColorFilter(new ColorMatrixColorFilter(desat)); Matrix matrix = new Matrix(); matrix.postTranslate((shortSide - imageWidth) / 2, (shortSide - imageHeight) / 2); c.drawBitmap(screenshot, matrix, paint); c.drawColor(0x40FFFFFF);/* ww w .j a v a 2 s . c o m*/ Bitmap croppedIcon = Bitmap.createScaledBitmap(preview, iconSize, iconSize, true); Intent nullIntent = new Intent(this, MainActivity.class); nullIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationBuilder = new NotificationCompat.Builder(this) .setTicker(resources.getString(R.string.screenshot_saving_ticker)) .setContentTitle(resources.getString(R.string.screenshot_saving_title)) .setSmallIcon(R.drawable.ic_actionbar_logo) .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(preview)) .setContentIntent(PendingIntent.getActivity(this, 0, nullIntent, 0)) .setWhen(System.currentTimeMillis()).setProgress(0, 0, true).setLargeIcon(croppedIcon); Notification n = notificationBuilder.build(); n.flags |= Notification.FLAG_NO_CLEAR; notificationManager.notify(DFG_NOTIFICATION_ID, n); }
From source file:com.example.zhangyangjing.roundcornerimageview.BezelImageView.java
public BezelImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Attribute initialization final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView, defStyle, 0); mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress, mDesaturateOnPress); mCornerRadius = a.getDimension(R.styleable.BezelImageView_cornerRadius, mCornerRadius); a.recycle();//from w w w . jav a 2 s . c om mDesaturatePaint = new Paint(); mMaskedPaint = new Paint(); mMaskedPaint.setAntiAlias(true); mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); // Always want a cache allocated. mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); if (mDesaturateOnPress) { // Create a desaturate color filter for pressed state. ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); mDesaturateColorFilter = new ColorMatrixColorFilter(cm); } }
From source file:com.me.harris.listviewitemanimations._01_activityAnim.ActivityAnimations.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animations); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w ww .j a v a 2s . c o m getSupportActionBar().setTitle(""); handleStatusBar(); // Grayscale filter used on all thumbnails ColorMatrix grayMatrix = new ColorMatrix(); grayMatrix.setSaturation(0); ColorMatrixColorFilter grayscaleFilter = new ColorMatrixColorFilter(grayMatrix); mGridLayout = (GridLayout) findViewById(R.id.gridLayout); mGridLayout.setColumnCount(3); mGridLayout.setUseDefaultMargins(true); // add all photo thumbnails to layout Resources resources = getResources(); ArrayList<PictureData> pictures = mBitmapUtils.loadPhotos(resources); for (int i = 0; i < pictures.size(); ++i) { PictureData pictureData = pictures.get(i); BitmapDrawable thumbnailDrawable = new BitmapDrawable(resources, pictureData.thumbnail); thumbnailDrawable.setColorFilter(grayscaleFilter); ImageView imageView = new ImageView(this); imageView.setOnClickListener(thumbnailClickListener); imageView.setImageDrawable(thumbnailDrawable); mPicturesData.put(imageView, pictureData); mGridLayout.addView(imageView); } }
From source file:gowtham.com.desknote.MyListener.java
private Bitmap toGrayscale(Bitmap bmpOriginal) { int width, height; height = bmpOriginal.getHeight();//from w ww . j av a 2s. 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:owne.android.envmonitor.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f); mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); }/* w w w. jav a2s . c o m*/ mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(action); mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); } }); container.addView(item); } }
From source file:no.android.proxime.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f); mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); }//from ww w.ja v a 2s . co m mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(action); mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
static void setBackground(View v, Bitmap bm) { if (bm == null) { v.setBackgroundResource(0);/*from w w w . j a v a2s .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.odoo.followup.orm.widgets.BezelImageView.java
private void otherInit() { // Other initialization mBlackPaint = new Paint(); mBlackPaint.setColor(0xff000000);/*from www . j av a 2s .co m*/ mMaskedPaint = new Paint(); mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); // Always want a cache allocated. mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); if (mDesaturateOnPress) { // Create a desaturate color filter for pressed state. ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); mDesaturateColorFilter = new ColorMatrixColorFilter(cm); } }
From source file:com.buddi.client.dfu.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f); mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); }// w w w . j a va2 s.c om mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); try { startActivity(action); } catch (final ActivityNotFoundException e) { Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show(); } mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }