Android image processing

Source: Internet
Author: User

1. Hue/hue--the color of the object passing
ColorMatrix huematrix=new Colormtrix ();
Huematrix.setrotate (0,hue);
Huematrix.setrotate (1,hue);
Huematrix.setrotate (2.hue);
2. Saturation-the purity of the color, from (0) to 100% saturation to describe
ColorMatrix saturationmatrix=new ColorMatrix ();
Saturationmatrix.setsaturation (saturation);
3. Brightness/lightness--the degree of light and shade relative to the color
ColorMatrix lummatrix=new ColorMatrix ();
Lummatrix.setscale (lum,lum,lun,1);
See the main code below
public class Mainactivity extends Activity implements seekbar.onseekbarchangelistener{


Private ImageView ImageView;
Private SeekBar Seekbar1,seekbar2,seekbar3;
private static int max=255;
private static int in=127;
Private MediaPlayer player;
float A,b,c;
Private Bitmap Bitmap;

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Bitmap=bitmapfactory.decoderesource (Getresources (), r.drawable.g);
imageview= (ImageView) Findviewbyid (R.id.imageview);
seekbar1= (SeekBar) Findviewbyid (R.ID.SEEKBAR1);
Seekbar2= (SeekBar) Findviewbyid (R.ID.SEEKBAR2);
seekbar3= (SeekBar) Findviewbyid (R.ID.SEEKBAR3);
Seekbar1.setonseekbarchangelistener (this);
Seekbar2.setonseekbarchangelistener (this);
Seekbar3.setonseekbarchangelistener (this);
Seekbar1.setmax (MAX);
Seekbar2.setmax (MAX);
Seekbar3.setmax (MAX);
Seekbar1.setprogress (in);
Seekbar2.setprogress (in);
Seekbar3.setprogress (in);
Imageview.setimagebitmap (bitmap);
Player=mediaplayer.create (this, R.raw.);
Player.start ();
}


@Override
public boolean Oncreateoptionsmenu (Menu menu) {
Inflate the menu; This adds items to the action bar if it is present.
Getmenuinflater (). Inflate (R.menu.main, menu);
return true;
}


@Override
public void onprogresschanged (SeekBar arg0, int arg1, Boolean arg2) {
TODO auto-generated Method Stub
Switch (Arg0.getid ()) {
Case R.ID.SEEKBAR1:
A= (arg1-in) *1.0f/in*180;
Break
Case R.ID.SEEKBAR2:
b=arg1*1.0f/in;
Break
Case R.ID.SEEKBAR3:
c=arg1*1.0f/in;
Break
}
Imageview.setimagebitmap (New Imagehelper (). Handleimageview (Bitmap, A, B, c));
}




Class Imagehelper {


public static Bitmap Handleimageview (Bitmap bm,float bug,float b,float c) {

Bitmap Bm1=bitmap.createbitmap (Bm.getwidth (), Bm.getheight (), Bitmap.Config.ARGB_8888);
Canvas canvas=new canvas (BM1);
Paint paint=new Paint (paint.anti_alias_flag);
ColorMatrix hm=new ColorMatrix ();
Hm.setrotate (0, bug);
Hm.setrotate (1, bug);
Hm.setrotate (2, bug);
ColorMatrix sm=new ColorMatrix ();
Sm.setsaturation (b);
ColorMatrix lm=new ColorMatrix ();
Lm.setscale (c, C, C, 1);
ColorMatrix imagem=new ColorMatrix ();
Imagem.postconcat (HM);
Imagem.postconcat (SM);
Imagem.postconcat (LM);
Paint.setcolorfilter (New Colormatrixcolorfilter (Imagem));
Canvas.drawbitmap (BM, 0, 0, paint);

return BM1;

}
}


}

Android image processing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.