最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android編程實(shí)現(xiàn)圖片的顏色處理功能示例

 更新時(shí)間:2018年02月07日 11:20:36   作者:飄走的我  
這篇文章主要介紹了Android編程實(shí)現(xiàn)圖片的顏色處理功能,涉及Android拖動條的使用及圖形顏色處理相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Android編程實(shí)現(xiàn)圖片的顏色處理功能。分享給大家供大家參考,具體如下:

先看效果圖:

圖片的顏色處理的基本步驟:

1.先拿到一張?jiān)瓐D
2.拿到一張和原圖一樣的紙
3.把紙固定在畫板上
4.顏色的取值
5.進(jìn)度條的拖動與監(jiān)聽

代碼編寫:

布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="青--紅" />
  <SeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/red_seekbar"/>
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="青--綠" />
  <SeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/green_seekbar"/>
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="青--藍(lán)" />
  <SeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/blue_seekbar"/>
  <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/im"
    android:src="@drawable/img_small_1"/>
</LinearLayout>

activity:

public class MainActivity extends Activity implements OnSeekBarChangeListener{
  private SeekBar red_sb,green_sb,blue_sb;
  private ImageView imageView;
  private Canvas canvas;
  private Paint paint;
  private Bitmap baseBitmap,copyBitmap;
  private float red_vector,green_vector,blue_vector;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    red_sb=(SeekBar) findViewById(R.id.red_seekbar);
    green_sb=(SeekBar) findViewById(R.id.green_seekbar);
    blue_sb=(SeekBar) findViewById(R.id.blue_seekbar);
    imageView=(ImageView) findViewById(R.id.im);
    red_sb.setOnSeekBarChangeListener(this);
    green_sb.setOnSeekBarChangeListener(this);
    blue_sb.setOnSeekBarChangeListener(this);
  }
  @Override
  public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    // TODO Auto-generated method stub
  }
  @Override
  public void onStartTrackingTouch(SeekBar seekBar) {
    // TODO Auto-generated method stub
  }
  @Override
  public void onStopTrackingTouch(SeekBar seekBar) {
    // TODO Auto-generated method stub
    int progress=seekBar.getProgress();
    float count=progress/50f;//使拖動條的取值為0f-2f,滿足我們的取值要求
    switch (seekBar.getId()) {
    case R.id.red_seekbar:
      this.red_vector=count;
      break;
    case R.id.green_seekbar:
      this.green_vector=count;
      break;
    case R.id.blue_seekbar:
      this.blue_vector=count;
      break;
    default:
      break;
    }
    //主題代碼
    baseBitmap=BitmapFactory.decodeResource(getResources(), R.drawable.img_small_1);
    copyBitmap=Bitmap.createBitmap(baseBitmap.getWidth(), baseBitmap.getHeight(), baseBitmap.getConfig());
    canvas=new Canvas(copyBitmap);
    Matrix matrix=new Matrix();
    paint=new Paint();
    //vector:取值范圍(0-2)
    float[] colors=new float[]{
        red_vector,0,0,0,0,
        0,green_vector,0,0,0,
        0,0,blue_vector,0,0,
        0,0,0,1,0};
    paint.setColorFilter(new ColorMatrixColorFilter(colors));
    canvas.drawBitmap(baseBitmap, matrix, paint);
    imageView.setImageBitmap(copyBitmap);
  }
}

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android圖形與圖像處理技巧總結(jié)》、《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

希望本文所述對大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • Android實(shí)現(xiàn)可滑動的自定義日歷控件

    Android實(shí)現(xiàn)可滑動的自定義日歷控件

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)可滑動的自定義日歷控件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • 淺析Android中g(shù)etWidth()和getMeasuredWidth()的區(qū)別

    淺析Android中g(shù)etWidth()和getMeasuredWidth()的區(qū)別

    這篇文章主要介紹了淺析Android中g(shù)etWidth()和getMeasuredWidth()的區(qū)別 ,getMeasuredWidth()獲取的是view原始的大小,getWidth()獲取的是這個view最終顯示的大小,具體區(qū)別介紹大家參考下本文
    2018-04-04
  • Android開發(fā)退出程序的方法匯總

    Android開發(fā)退出程序的方法匯總

    Android程序有很多Activity,比如說主窗口A,調(diào)用了子窗口B,子窗口B又調(diào)用子窗口C,back返回子窗口B后,在B中如何關(guān)閉整個Android應(yīng)用程序呢? 下面腳本之家小編就給大家介紹android開發(fā)退出程序的幾種方法,感興趣的朋友參考下吧
    2016-03-03
  • android自定義滾動上下回彈scollView

    android自定義滾動上下回彈scollView

    這篇文章主要為大家詳細(xì)介紹了android自定義滾動上下回彈scollView,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Android應(yīng)用中設(shè)置alpha值來制作透明與漸變效果的實(shí)例

    Android應(yīng)用中設(shè)置alpha值來制作透明與漸變效果的實(shí)例

    這篇文章主要介紹了Android應(yīng)用中設(shè)置alpha值來制作透明與漸變效果的實(shí)例,展示了基礎(chǔ)的透明漸變動畫的編寫方法,需要的朋友可以參考下
    2016-04-04
  • Android 編程下的計(jì)時(shí)器代碼

    Android 編程下的計(jì)時(shí)器代碼

    在安卓 APP 的手機(jī)號注冊邏輯中,經(jīng)常會有將激活碼發(fā)送到手機(jī)的環(huán)節(jié),這個環(huán)節(jié)中絕大多數(shù)的應(yīng)用考慮到網(wǎng)絡(luò)延遲或服務(wù)器壓力以及短信服務(wù)商的延遲等原因,會給用戶提供一個重新獲取激活碼的按鈕
    2013-08-08
  • Android 捕獲運(yùn)行時(shí)異常詳解

    Android 捕獲運(yùn)行時(shí)異常詳解

    這篇文章主要介紹了Android 捕獲運(yùn)行時(shí)異常詳解的相關(guān)資料,需要的朋友可以參考下
    2017-04-04
  • Android實(shí)現(xiàn)自定義圓角對話框Dialog的示例代碼

    Android實(shí)現(xiàn)自定義圓角對話框Dialog的示例代碼

    項(xiàng)目中多處用到對話框,本篇文章主要介紹了Android實(shí)現(xiàn)圓角對話框Dialog的示例代碼,有興趣的可以了解一下。
    2017-03-03
  • Android使用Service實(shí)現(xiàn)IPC通信的2種方式

    Android使用Service實(shí)現(xiàn)IPC通信的2種方式

    這篇文章主要介紹了Android使用Service實(shí)現(xiàn)IPC通信的2種方式,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • Android WebView通過動態(tài)的修改js去攔截post請求參數(shù)實(shí)例

    Android WebView通過動態(tài)的修改js去攔截post請求參數(shù)實(shí)例

    這篇文章主要介紹了Android WebView通過動態(tài)的修改js去攔截post請求參數(shù)實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03

最新評論

克什克腾旗| 克什克腾旗| 荣成市| 大宁县| 江源县| 宜川县| 临澧县| 南雄市| 顺昌县| 和静县| 鲁甸县| 阳新县| 密云县| 胶南市| 金昌市| 大名县| 江都市| 雷波县| 千阳县| 隆子县| 昂仁县| 南华县| 西华县| 玛纳斯县| 武陟县| 五常市| 安吉县| 朝阳县| 陈巴尔虎旗| 武胜县| 永川市| 浦东新区| 武义县| 新巴尔虎左旗| 象州县| 贵德县| 芷江| 阜新| 尼木县| 子洲县| 岢岚县|