Breaking News
Loading...
Friday 14 September 2012

LightingColorFilter example

08:52
android.graphics.LightingColorFilter 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 MyView.java in the post "Example of using ColorMatrixColorFilter".
 @Override
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();
MyPaint_Lighting.setColorFilter(lightingColorFilter);

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.

Related:
- Adjust lightness and darkness of ImageView, using LightingColorFilter.

0 comments:

Post a Comment

 
Toggle Footer