編輯:關於Android編程
activity_main.xml:
see the MainActivity.java:
package com.example.photocolorchange; import android.os.Bundle; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.ColorFilter; 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 iv1; private SeekBar sb1,sb2,sb3,sb4; private Bitmap alertBitmap; private Canvas canvas; private Paint paint; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv1 = (ImageView)findViewById(R.id.iv); final Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.shuishou); alertBitmap = Bitmap.createBitmap(bitmap1.getWidth(),bitmap1.getHeight(),bitmap1.getConfig()); paint = new Paint(); canvas = new Canvas(alertBitmap); final Matrix matrix = new Matrix(); final ColorMatrix cm = new ColorMatrix(); paint.setColorFilter(new ColorMatrixColorFilter(cm)); paint.setAntiAlias(true); canvas.drawBitmap(bitmap1, matrix, paint); iv1.setImageBitmap(alertBitmap); sb1 = (SeekBar) findViewById(R.id.sb1); sb2 = (SeekBar) findViewById(R.id.sb2); sb3 = (SeekBar) findViewById(R.id.sb3); sb4 = (SeekBar) findViewById(R.id.sb4); //RED 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(bitmap1, matrix, paint); } @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 } }); //GREEN 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(bitmap1, matrix, paint); iv1.setImageBitmap(alertBitmap); } @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 } }); //BLUE 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(bitmap1, matrix, paint); iv1.setImageBitmap(alertBitmap); } @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 } }); //sensitometry sb4.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,progress/128.0f,0,0,0, 0,0,progress/128.0f,0,0, 0,0,0,1,0, }); // cm.setSaturation(progress/128.0f); //saturability paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(bitmap1, matrix, paint); iv1.setImageBitmap(alertBitmap); } @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 } }); } @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; } }
對稱加密是最快速、最簡單的一種加密方式,加密(encryption)與解密(decryption)用的是同樣的密鑰(secret key)。常用的對稱加密方式為:DES,
凱撒密碼1. 介紹凱撒密碼作為一種最為古老的對稱加密體制,在古羅馬的時候都已經很流行,他的基本思想是:通過把字母移動一定的位數來實現加密和解密。明文中的所有字母都在字母表
在上一篇的文章中介紹了自定義控件的屬性,詳情見《詳解Android自定義控件屬性TypedArray以及attrs》。那麼在這基礎上實現隨機驗證碼生成,裡面的代碼是自定義
1、介紹周末在逛慕課網的時候,看到了一張學習計劃報告圖,詳細記錄了自己一周的學習情況,天天都是0節課啊!正好在學習Android自定義View,於是就想著自己去寫了一個,