編輯:關於android開發
package net.hnjdzy.imagecolor; import android.os.Bundle; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; import android.graphics.Matrix; import android.graphics.Paint; import android.view.Menu; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; public class MainActivity extends Activity { private ImageView iv; private SeekBar sb1,sb2,sb3; private Canvas canvas; private Paint paint; private ColorMatrix cm; private Matrix matrix; private Bitmap b1,b2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv = (ImageView) findViewById(R.id.imageView1); sb1 = (SeekBar) findViewById(R.id.seekBar1); sb2 = (SeekBar) findViewById(R.id.seekBar2); sb3 = (SeekBar) findViewById(R.id.seekBar3); b1 = BitmapFactory.decodeResource(getResources(), R.drawable.fq); b2 = Bitmap.createBitmap(b1.getWidth(), b1.getHeight(), b1.getConfig()); canvas = new Canvas(b2); paint = new Paint(); paint.setColor(Color.BLACK); matrix = new Matrix(); paint.setAntiAlias(true); //顏色矩陣 cm = new ColorMatrix(); paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(b1, matrix, paint); iv.setImageBitmap(b2); //改變RGB中R的值 sb1.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { int progress = seekBar.getProgress(); cm.set(new float[]{ progress/128.0f,0,0,0,0, 0,1,0,0,0, 0,0,1,0,0, 0,0,0,1,0 }); paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(b1, matrix, paint); iv.setImageBitmap(b2); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub } }); //改變RGB中G的值 sb2.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { int progress = seekBar.getProgress(); cm.set(new float[]{ 1,0,0,0,0, 0,progress/128.0f,0,0,0, 0,0,1,0,0, 0,0,0,1,0 }); paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(b1, matrix, paint); iv.setImageBitmap(b2); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub } }); //改變RGB中B的值 sb3.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { int progress = seekBar.getProgress(); cm.set(new float[]{ 1,0,0,0,0, 0,1,0,0,0, 0,0,progress/128.0f,0,0, 0,0,0,1,0 }); paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(b1, matrix, paint); iv.setImageBitmap(b2); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub } }); } }
Android上傳圖片之調用系統拍照和從相冊選擇圖片 Android上傳圖片之調用系統拍照和從相冊選擇圖片 前言: 萬丈高樓平底起,萬事起於微末。不知不覺距離上篇博文已近
Android工程師進階之路 :《Android開發進階:從小工到專家》上市啦! 封面 目錄1 目錄2
初涉RxAndroid結合Glide實現多圖片加載操作 什麼是RxJava或者RxAndroid我就不多廢話了,理論知識一大堆人給我們做好了,只要自己肯去看就能理解,我這
安卓應用的界面編程(3),安卓應用界面編程第二組UI組件:TextView及其子類 1. TextView(不允許用戶編輯文本內容)直接繼承了View,同時是EditTe