Friday, September 14, 2012

LightingColorFilter example is a colorfilter that multiplies the RGB channels by one color, and then adds a second color, pinning the result for each component to [0..255].

LightingColorFilter example

Modify onDraw() method of in the post "Example of using ColorMatrixColorFilter".
 protected void onDraw(Canvas canvas) {
  int mul = 0xFFFFFF00; //remove BLUE component
  int add = 0x0000FF00; //set GREEN full
  LightingColorFilter lightingColorFilter = new LightingColorFilter(mul, add);
  Paint MyPaint_Normal = new Paint();
  Paint MyPaint_Lighting = new Paint();
     Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
     canvas.drawBitmap(myBitmap, 400, 100, MyPaint_Normal);
     canvas.drawBitmap(myBitmap, 500, 100, MyPaint_Lighting);

download filesDownload the files.

- Adjust lightness and darkness of ImageView, using LightingColorFilter.

No comments: