Äú¿ÉÒÔ¾èÖú£¬Ö§³ÖÎÒÃǵĹ«ÒæÊÂÒµ¡£

1Ôª 10Ôª 50Ôª





ÈÏÖ¤Â룺  ÑéÖ¤Âë,¿´²»Çå³þ?Çëµã»÷Ë¢ÐÂÑéÖ¤Âë ±ØÌî



  ÇóÖª ÎÄÕ ÎÄ¿â Lib ÊÓÆµ iPerson ¿Î³Ì ÈÏÖ¤ ×Éѯ ¹¤¾ß ½²×ù Modeler   Code  
»áÔ±   
 
   
 
 
     
   
 ¶©ÔÄ
  ¾èÖú
°²×¿µÚÊ®ÎåÌì±Ê¼Ç-ͼÐÎͼÏñһЩ¼òµ¥´¦Àí
 
×÷ÕߣºÉ­ÁÖÉ­ À´×ÔÓÚ£º²©¿ÍÔ° ·¢²¼ÓÚ 2016-3-31
  2421  次浏览      27
 

1.¼ÆËã»úÖÐͼÐμÆËãµÄ´óС

Ò»°ã°×É«¾ÍÊÇ0,ºÚÉ«¾ÍÊÇ1

µ¥É«Î»Í¼:

8λ±íʾһ¸ö×Ö½Ú,

´óС:³¤*¿í/8,±íʾ´óС,»¹ÓÐһЩÎļþÐÅÏ¢Èç´´½¨Ê±¼ä,ʲô¹¤¾ß´´½¨Ö®ÀàµÄ

24λλͼ

Ò»¸öÏñËØ±íʾ24λ

´óС:³¤*¿í*24/8

256É«

1¸öÏñËØ¿ÉÒÔ±íʾ256ÖÖÑÕÉ« Ò»¸ö×Ö½ÚËüµÄ³¤¶È¸ÕºÃÊÇ256 £¬ÄÇôһ¸öÏñËØµã¾ÍÊÇÒ»¸ö×Ö½Ú

´óС:³¤*¿í

°²×¿ÖÐĬÈÏʹÓÃ32λµÄ

λͼµÄȱÏÝ ?·Å´óµ½Ò»¶¨µÄ±ÈÀý»á³ö»á³öÏÖÊ§ÕæÓë¾â³ÝÐÎ×´

Õ¼ÓúܴóµÄ´æ´¢¿Õ¼ä

2.¼ÓÔØÒ»¸öͼƬÎļþµ½´æÖÐ

½«Ò»¸öͼƬ·ÅÔÚSD¿¨ÉÏ,ʹÓÃBitmapFactory.decodeFile½âÎöµÃBitmapÉèÖÃImageViewÏÔʾ

ImageView iv = (ImageView) findViewById(R.id.iv);
//¼ÓÔØÍ¼Æ¬
//Bitmap bitmap =BitmapFactory.decodeFile("/mnt/sdcard/img7.jpg");

Bitmap bitmap =BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+"/img7.jpg");
//ÉèÖÃͼƬ
iv.setImageBitmap(bitmap);

ÒÔÉϵÄͼƬ¿ÉÒÔÕý³£¼ÓÔØ

Òì³£ÏÖÏó---¼ÓÔØ µÄͼƬ¹ý´ó,Èç2560*1520Ö®ÀàµÄ,¼ÓÔØ ʱ¾Í»á±¨OutMemoryErrorÄÚ´æÒç³ö

 java.lang.OutOfMemoryError

3.ÉèÖÃͼƬµÄËõ·Å

1.»ñȡͼƬµÄ´óС¿íºÍ¸ß

»ñȡͼƬµÄ¿í¸ß

1.jpg

ExifInterface exif = new ExifInterface("/mnt/sdcard/biger.jpg");
String width = exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH);
String height = exif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH);

2.png

Options opt = new Options();

//²»»áÓÐbitmap·µ»Ø£¬µ«ÊÇoutµÄ×Ö¶ÎÓÐÊä³ö
opt.inJustDecodeBounds = true;

BitmapFactory.decodeFile("", opt);

//µÃµ½Í¼Æ¬¿í¸ß
opt.outHeight;
opt.outWidth ;

2.»ñÈ¡ÆÁÄ»µÄ´óС¿íºÍ¸ß

//1. »ñÈ¡µ½ÆÁÄ»·Ö±æÂÊ
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);

Display display = manager.getDefaultDisplay();

Point outSize = new Point();
display.getSize(outSize);
int x = outSize.x;

3.ʹÓÃͼƬµÄ´óС¿íºÍÆÁÄ»µÄ¿íÏà³ý,ͼƬµÄ¸ßÓëÆÁÄ»µÄ¸ßÏà³ý,±È´óС,È¡×î´óÖµ,»òÕßÈ¡ÖмäÖµ

4.

 /**
ͼƬÉèÖÃËõ·Å±ÈÀý

@author Áõéª *

2016-3-3ÏÂÎç1:20:28 */ @SuppressLint("NewApi") public class MainActivity extends Activity {

private static final String TAG = "MainActivity";
/*
* ԴͼƬ
*/
private ImageView src;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// ԴͼƬ
src = (ImageView) findViewById(R.id.src);
/*Options options = new Options();
options.inJustDecodeBounds=true;
BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/2.jpg",options);*/

/**
* µÃµ½ÆÁÄ»µÄ¿í¸ß
*/
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);

Display defaultDisplay = manager.getDefaultDisplay();
Point point = new Point();
defaultDisplay.getRealSize(point);

int screenWidth = point.x;
int screenHeight = point.y;

Log.d(TAG, "ÆÁÄ»¿í:"+screenWidth);
Log.d(TAG, "ÆÁÄ»¸ß:"+screenHeight);
/*
* jpgͼƬ½âÎö
*/
try {
ExifInterface jpgExifInterface = new ExifInterface(
Environment.getExternalStorageDirectory() + "/2.jpg");
/*
* ͼƬµÄ¿í¶È
*/
String width = jpgExifInterface
.getAttribute(ExifInterface.TAG_IMAGE_WIDTH);
/*
* µÃµ½Í¼Æ¬µÄ¸ß¶È
*/
String height = jpgExifInterface
.getAttribute(ExifInterface.TAG_IMAGE_LENGTH);

Log.d(TAG, "ͼƬ¿í:"+width);
Log.d(TAG, "ͼƬ¸ß:"+height);
//¼ÆËã±ÈÀý
int scale=Integer.parseInt(width)/screenWidth>Integer.parseInt(height)/screenHeight?Integer

.parseInt(width)/screenWidth:Integer.parseInt(height)/screenHeight;

//ÉèÖÃÏÔʾ
Log.d(TAG,"±ÈÀý:"+scale);
//µ÷ÖòÉÑùÂÊ,±ÈÀý
Options opts = new Options();
opts.inSampleSize=scale;
//ʹÓù¤³§ÔٴνâÎö
Bitmap decodeFile = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/2.jpg", opts);

//ÉèÖÃͼƬÏÔʾ
src.setImageBitmap(decodeFile);
} catch (IOException e) {
e.printStackTrace();
}
}

4.ͼƬµÄһЩ³£ÓòÙ×÷

1.ͼƬµÄÆ½ÒÆ

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
* ԴͼƬÏÔʾ
*/
srcImage = (ImageView) findViewById(R.id.ivsrc);
/*
* Ä¿±êͼƬ
*/
desImage = (ImageView) findViewById(R.id.ivdesc);
/*
* »ñȡͼƬ×ÊÔ´
*/
Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+"/bg.png");
//ÉèÖÃԴͼƬÏÔʾ
srcImage.setImageBitmap(bitmap);
//´´½¨Ò»ÕÅÄÚ´æÖеÄͼƬ
Bitmap buffereImage = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());

Canvas canvas = new Canvas(buffereImage);
Paint paint = new Paint();
Matrix matrix = new Matrix();
//ÒÆ¶¯µÚÒ»¸ö²ÎÊýx ˮƽ, µÚ¶þ¸ö²ÎÊýy¸ß¶È,¿ÉÒÔÊǸºÖµ
matrix.setTranslate(-20, -10);
/*
* ÐÂͼ
* µÚÒ»¸ö²ÎÊý:²ÎÕÕÎï
* µÚ¶þ¸ömatrix:¾ØÕó
* µÚÈý¸ö²ÎÊý:»­±Ê
*/
canvas.drawBitmap(bitmap, matrix, paint);
desImage.setImageBitmap(buffereImage);
}

2.ͼƬµÄͼÏñÐýת /* * degrees½Ç¶È: * px:¿ªÊ¼ÐýתµÄË®Æ½×ø±ê * py:¿ªÊ¼ÐýתµÄ´¹Ö±×ø±ê */ matrix.setRotate(45, bitmap.getWidth()/2, bitmap.getHeight()/2);

Ö»ÐèÒª¸ü¸ÄMatrix

Matrix matrix = new Matrix();

//ÒÆ¶¯µÚÒ»¸ö²ÎÊýx ˮƽ, µÚ¶þ¸ö²ÎÊýy¸ß¶È,¿ÉÒÔÊǸºÖµ

* degrees½Ç¶È:

* px:¿ªÊ¼ÐýתµÄË®Æ½×ø±ê

* py:¿ªÊ¼ÐýתµÄ´¹Ö±×ø±ê

matrix.setRotate(90, bitmap.getWidth()/2, bitmap.getHeight()/2);

1.ͼƬµÄ¾µ×ÓЧ¹û

Matrix matrix = new Matrix();
//ÒÆ¶¯µÚÒ»¸ö²ÎÊýx ˮƽ, µÚ¶þ¸ö²ÎÊýy¸ß¶È,¿ÉÒÔÊǸºÖµ
/*
* ÏȰÑͼƬˮƽ·­×ª
*/
matrix.setScale(-1, 1);
/*
* ÔÚÔÙÏÖÔÚµÄЧ¹ûÉÏ,Ë®Æ½ÒÆ¶¯Í¼Æ¬µÄ¿í¶È
*/
matrix.postTranslate(bitmap.getWidth(), 0);

2.. ͼƬµÄµ¹Ó°Ð§¹û

Matrix matrix = new Matrix();
//ÒÆ¶¯µÚÒ»¸ö²ÎÊýx ˮƽ, µÚ¶þ¸ö²ÎÊýy¸ß¶È,¿ÉÒÔÊǸºÖµ
/*
* ÏȰÑͼƬ´¹Ö±·­×ª
*/
matrix.setScale(1, -1);
/*
* ÔÚÔÙÏÖÔÚµÄЧ¹ûÉÏ,´¹Ö±Òƶ¯Í¼Æ¬µÄ¸ß¶È
*/
matrix.postTranslate(0, bitmap.getHeight());

3.setXXXºÍ postXXXÇø±ð

ǰÕßÊÇÔÚԭͼ»ù´¡ÉÏ×ö±ä»¯£¬ºóÕßÊÇÔÚĿǰµÄЧ¹û»ù´¡ÉÏ×ö±ä»¯

5.×Ô¶¨Òå»­°åͿѻ

²¼¾ÖÎļþ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layoutwidth="matchparent" android:layoutheight="matchparent" android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="horizontal" >
<!-- »­±ÊÑÕÉ« -->
<View
android:id="@+id/red"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ff0000" />

<View
android:id="@+id/green"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#00ff00" />

<View
android:id="@+id/blue"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#0000ff" />

<View
android:id="@+id/yellow"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ffff00" />

<View
android:id="@+id/purple"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ff00ff" />
</LinearLayout>
<!-- »­±Ê´Öϸ -->
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="20"
android:progress="5"
android:thumb="@drawable/ok" />
<!-- ͿѻµÄµØ·½ -->
<ImageView
android:id="@+id/iv_result"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

²Ëµ¥R.menu.main

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
android:id="@+id/save"
android:orderInCategory="100"
android:showAsAction="never"
android:title="±£´æÍ¿Ñ»"/>
<item
android:id="@+id/clear"
android:orderInCategory="100"
android:showAsAction="never"
android:title="Çå³ýÊý¾Ý"/>
</menu>

Activity

/**
* »­°åͿѻ
* 1.ÔÚÄÚ´æÖÐÉú³ÉÒ»ÕÅͼƬ
* 2.ΪImageViewÉèÖÃÕâÕÅͼƬ
* 3.ÉèÖû­²¼,»­±Ê
* 4.ΪImageViewÉèÖüàÌýʼþ

* @author Áõéª
*
* 2016-3-3ÏÂÎç7:28:20
*/
public class MainActivity extends Activity implements OnClickListener, OnSeekBarChangeListener, OnTouchListener{
private static final String TAG = "MainActivity";
/*
* ½ø¶ÈÌõ,ÓÃÀ´¸Ä±ä»­±Ê´Öϸ
*/
private SeekBar seekBar;
/*
* »­±ÊµÄÑÕÉ«
*/
private View red;
private View green;
private View blue;
private View yellow;
private View purple;
/*
* »­°å
*/
Canvas canvas ;
/*
* »­±Ê
*/
Paint paint;

private ImageView ivResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
* »­°åÒª»­µÄµØ·½
*/
ivResult = (ImageView) findViewById(R.id.iv_result);
/*
* ½ø¶ÈÌõ,ÓÃÀ´¸Ä±ä»­±Ê´Öϸ
*/
seekBar = (SeekBar) findViewById(R.id.seekbar);
/*
* »­±ÊµÄÑÕÉ«
*/
red = findViewById(R.id.red);
green = findViewById(R.id.green);
blue = findViewById(R.id.blue);
yellow = findViewById(R.id.yellow);
purple = findViewById(R.id.purple);
/*
* ÉèÖüàÌýʼþ
*/
red.setOnClickListener(this);
green.setOnClickListener(this);
blue.setOnClickListener(this);
yellow.setOnClickListener(this);
purple.setOnClickListener(this);
seekBar.setOnSeekBarChangeListener(this);
/*
* ÄÚ´æÖеÄͼ
*/
buffImage = Bitmap.createBitmap(300, 300, Config.ARGB_8888);
/*
* »­°å
*/
canvas = new Canvas(buffImage);
canvas.drawColor(Color.WHITE);
/*
* »­²¼
*/
paint = new Paint();

paint.setStrokeCap(Cap.ROUND);


ivResult.setImageBitmap(buffImage);

ivResult.setOnTouchListener(this);
}

/**
* ½ø¶ÈÌõ¸Ä±äʱ
*/
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {

}
/**
* ½ø¶ÈÌõ´¥Ãþʱ
*/
@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}
/**
* ½ø¶ÈÌõÍ£Ö¹
*/
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
paint.setStrokeWidth(progress);
Toast.makeText(this, "µ±Ç°»­±Ê´ÖϸÊÇ£º"+progress, Toast.LENGTH_SHORT).show();
}

/**
* µ¥»÷ʼþ¼àÌýÆ÷
*/
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.red:
paint.setColor(Color.RED);
Log.d(TAG,"»­±ÊÑÕÉ«:ºìÉ«");
break;
case R.id.green:
paint.setColor(Color.GREEN);
Log.d(TAG,"»­±ÊÑÕÉ«:ÂÌÉ«");
break;
case R.id.blue:
paint.setColor(Color.BLUE);
Log.d(TAG,"»­±ÊÑÕÉ«:À¶É«");
break;
case R.id.yellow:
paint.setColor(Color.YELLOW);
Log.d(TAG,"»­±ÊÑÕÉ«:»ÆÉ«");
break;
case R.id.purple:
paint.setColor(0xffff00ff);
Log.d(TAG,"»­±ÊÑÕÉ«:µ}É«");
break;


}
}
float startX ;
float startY;
/*
* ÄÚ´æÖеÄͼ
*/
private Bitmap buffImage;
/**
* ImageView´¥Ãþʼþ
*/
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d(TAG, "down---"+event.getX()+" £º£º£º "+event.getY());
startX = event.getX();
startY = event.getY();
canvas.drawLine(startX, startY, startX, startY, paint);
ivResult.setImageBitmap(buffImage);
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG, "move---"+event.getX()+" £º£º£º "+event.getY());

float stopX = event.getX();
float stopY = event.getY();

canvas.drawLine(startX, startY, stopX, stopY, paint);
ivResult.setImageBitmap(buffImage);
startX = event.getX();
startY = event.getY();
break;
case MotionEvent.ACTION_UP:
Log.d(TAG, "up---"+event.getX()+" £º£º£º "+event.getY());
break;
}
return true;
}

/**
* Ìí¼Ó²Ëµ¥
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

/**
* ²Ëµ¥±»Ñ¡ÔñʱµÄʼþ±£´æÍ¼Æ¬ÓëÇå³ýͼƬ
*/
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case R.id.save:
File file = new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis()+".jpg");
try {
OutputStream out = new FileOutputStream(file);
buffImage.compress(CompressFormat.JPEG, 100, out);
Toast.makeText(this, "±£´æ³É¹¦", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {

e.printStackTrace();
}
/*
* ·¢ËÍ֪ͨ¸æËßϵͳÐÂÔö¼ÓÁËÒ»ÕÅͼƬ
*/
Intent intent =new Intent();
intent.setAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
//·¢ËÍÊý¾Ý
intent.setData(Uri.fromFile(file));
//·¢Ë͹㲥
sendBroadcast(intent);

break;
case R.id.clear:
/*
* Çå³ý»­°å
*/
canvas.drawColor(Color.WHITE);
ivResult.setImageBitmap(buffImage);
break;


}
return super.onMenuItemSelected(featureId, item);
}
}

±£´æÔÚSD¿¨ÉϵÄȨÏÞ

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

getXºÍgetRawXµÄÇø±ð

getX

µ±Ç°µÄ´¥ÃþλÖõ½¿Ø¼þµÄ×ó±ß¼ä¾à

getRawX

µ±Ç°µÄ´¥ÃþλÖõ½ÆÁÄ»µÄ×ó±ß¼ä¾à

6.¼òµ¥ËºÒ·þ

Ô­Àí:

1.×¼±¸Á½ÕÅÒ»ÑùµÄͼƬ£¬Ò»ÕÅÊÇ´©ÓÐÒ·þµÄ£¬ÁíÒ»ÕÅÊÇûÓд©Ò·þµÄ¡£

2.ͨ¹ýFrameLayout½øÐв¼¾Ö£¬´©Ò·þµÄ·ÅÉÏÃæ£¬Ã»´©Ò·þµÄͼƬ·ÅÏÂÃæ¡£

3.ͨ¹ý´¥Ãþʼþ½øÐÐÅжϣ¬ÊÖÖ¸»®¹ýµÄµØ·½£¬Èô©Ò·þµÄͼƬ±ä³É͸Ã÷£¬¾ÍÏÔʾµ½ÁËÏÂÃæÃ»´©Ò·þµÄͼƬ¡£ÕâÑùЧ¹û¾ÍÐγÉÁË¡£

²¼¾Ö

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<ImageView

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/after" />
<ImageView
android:id="@+id/pre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>

ActivtyʵÏÖ

/**
* ˺Ò·þ
* 1.×¼±¸Á½ÕÅÒ»ÑùµÄͼƬ£¬Ò»ÕÅÊÇ´©ÓÐÒ·þµÄ£¬ÁíÒ»ÕÅÊÇûÓд©Ò·þµÄ¡£
2.ͨ¹ýFrameLayout½øÐв¼¾Ö»òÕßÏà¶Ô²¼¾ÖÕâÀïʹÓÃÏà¶Ô£¬´©Ò·þµÄ·ÅÉÏÃæ£¬Ã»´©Ò·þµÄͼƬ·ÅÏÂÃæ¡£
3.ͨ¹ý´¥Ãþʼþ½øÐÐÅжϣ¬ÊÖÖ¸»®¹ýµÄµØ·½£¬Èô©Ò·þµÄͼƬ±ä³É͸Ã÷£¬¾ÍÏÔʾµ½ÁËÏÂÃæÃ»´©Ò·þµÄͼƬ¡£
public class MainActivity extends Activity implements OnTouchListener {

private static final String TAG = "MainActivity";

/*
* Ç°ÃæµÄÒ»ÕÅͼƬ
*/
private ImageView pre;

private Canvas canvas;

private Bitmap buffImage;

private static final int RADIUS = 10;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

pre = (ImageView) findViewById(R.id.pre);
/*
* ͨ¹ýÕâÖÖ·½·¨¶ÁÈ¡µÄbitmapÊÇÖ»¶ÁµÄ£¬²»¿ÉÐÞ¸Ä
*/
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.pre);
/*
* ÄÚ´æÖеÄÉú³ÉÒ»ÕÅͬÑù´óСÓëÅäÖõÄͼƬ
*/
buffImage = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(),
bitmap.getConfig());

canvas = new Canvas(buffImage);

Paint paint = new Paint();

Matrix matrix = new Matrix();
/*
* »­Í¼
*/
canvas.drawBitmap(bitmap, matrix, paint);
pre.setImageBitmap(buffImage);

/*
* ÉèÖüàÌýʼþ
*/
pre.setOnTouchListener(this);
}

@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
Log.d(TAG, "move" + event.getX() + "------->" + event.getY());
int stopX = (int) event.getX();
int stopY = (int) event.getY();
// Õâ¸öÅжÏÊǼÆËã±ß½ç£¬ÒòΪ³¬¹ýÁ˱߽çΪ¸ºÖµÊ±»á±¨´í
if (stopX >= RADIUS && stopX <= pre.getWidth() - RADIUS
&& stopY >= RADIUS && stopY <= pre.getHeight() - RADIUS) {
/**
* ¼ÆËãÔ²£¬ÍÚ¿ÕÒ»¸ö°ë¾¶ÎªRADIUSµÄʵÐÄÔ²
*/
for (int radius = 0; radius <= RADIUS; radius++) {
for (double angle = 0; angle <= 360; angle++) {

int newX = (int) (stopX + radius * Math.cos(angle));
int newY = (int) (stopY + radius * Math.sin(angle));
buffImage.setPixel(newX, newY, Color.TRANSPARENT);

}
}
pre.setImageBitmap(buffImage);
}
break;

}
return true;
}

}

7.¼òÒ×µ÷É«°åµÄʹÓÃ

²¼¾Ö

<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:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="µ÷É«°å" />

<SeekBar
android:id="@+id/seekbar_red"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="50"
android:max="100"/>
<SeekBar
android:id="@+id/seekbar_green"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="50"
android:max="100"/>
<SeekBar
android:id="@+id/seekbar_blue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="50"
android:max="100"/>
<SeekBar
android:id="@+id/seekbar_alpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="50"
android:max="100"/>

<ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

Activity

/**
* ¼òÒ×µ÷É«°å ²½Öè: 1.ʹÓÃSeekBarÀ´¿ØÖÆÑÕÉ«µÄÏÔʾ±ÈÀý
*
*
* @author Áõéª
*
* 2016-3-3ÏÂÎç10:58:24
*/
public class MainActivity extends Activity {

private SeekBar seekbarRed;
private ImageView iv;
private Paint paint;
private Matrix matrix;
private Canvas canvas;
private SeekBar seekbarGreen;
private SeekBar seekbarBlue;
private SeekBar seekbarAlpha;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
seekbarRed = (SeekBar) findViewById(R.id.seekbar_red);
seekbarGreen = (SeekBar) findViewById(R.id.seekbar_green);
seekbarBlue = (SeekBar) findViewById(R.id.seekbar_blue);
seekbarAlpha = (SeekBar) findViewById(R.id.seekbar_alpha);
iv = (ImageView) findViewById(R.id.iv);
// ͨ¹ýÕâÖÖ·½·¨¶ÁÈ¡µÄbitmapÊÇÖ»¶ÁµÄ£¬²»¿ÉÐÞ¸Ä
final Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.pre14);

final Bitmap buffImage = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), bitmap.getConfig());

canvas = new Canvas(buffImage);

paint = new Paint();
matrix = new Matrix();

canvas.drawBitmap(bitmap, matrix, paint);

iv.setImageBitmap(buffImage);

seekbarRed.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
float value = progress / 50.0f;
ColorMatrix cm = new ColorMatrix();
/*
*
* ÑÕÉ«¾ØÕó
*/
cm.set(new float[] { 1 * value, 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(bitmap, matrix, paint);
iv.setImageBitmap(buffImage);

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {

float value = progress / 50.0f;
ColorMatrix cm = new ColorMatrix();
/*
*
* ÑÕÉ«¾ØÕó
*/
cm.set(new float[] { 1 * value, 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(bitmap, matrix, paint);
iv.setImageBitmap(buffImage);

}
});
seekbarGreen.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
float value = progress / 50.0f;
ColorMatrix cm = new ColorMatrix();
/*
*
* ÑÕÉ«¾ØÕó
*/
cm.set(new float[] { 1, 0, 0, 0, 0,// ºìÉ«
0, 1 * value, 0, 0, 0,// ÂÌÉ«
0, 0, 1, 0, 0,// À¶É«
0, 0, 0, 1, 0,// ͸Ã÷¶È
});
// ¸ø»­±ÊÌí¼Ó¹ýÂËÆ÷
// ¸ø»­±ÊÌí¼ÓÑÕÉ«¹ýÂËÆ÷

paint.setColorFilter(new ColorMatrixColorFilter(cm));

canvas.drawBitmap(bitmap, matrix, paint);
iv.setImageBitmap(buffImage);

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {

float value = progress / 50.0f;
ColorMatrix cm = new ColorMatrix();
/*
*
* ÑÕÉ«¾ØÕó
*/
cm.set(new float[] { 1, 0, 0, 0, 0,// ºìÉ«
0, 1 * value, 0, 0, 0,// ÂÌÉ«
0, 0, 1, 0, 0,// À¶É«
0, 0, 0, 1, 0,// ͸Ã÷¶È
});
// ¸ø»­±ÊÌí¼Ó¹ýÂËÆ÷
// ¸ø»­±ÊÌí¼ÓÑÕÉ«¹ýÂËÆ÷

paint.setColorFilter(new ColorMatrixColorFilter(cm));

canvas.drawBitmap(bitmap, matrix, paint);
iv.setImageBitmap(buffImage);

}
});
seekbarBlue.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
float value = progress / 50.0f;
ColorMatrix cm = new ColorMatrix();
/*
*
* ÑÕÉ«¾ØÕó
*/
cm.set(new float[] { 1, 0, 0, 0, 0,// ºìÉ«
0, 1, 0, 0, 0,// ÂÌÉ«
0, 0, 1 * value, 0, 0,// À¶É«
0, 0, 0, 1, 0,// ͸Ã÷¶È
});
// ¸ø»­±ÊÌí¼Ó¹ýÂËÆ÷
// ¸ø»­±ÊÌí¼ÓÑÕÉ«¹ýÂËÆ÷

paint.setColorFilter(new ColorMatrixColorFilter(cm));

canvas.drawBitmap(bitmap, matrix, paint);
iv.setImageBitmap(buffImage);

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {

float value = progress / 50.0f;
ColorMatrix cm = new ColorMatrix();
cm.set(new float[] { 1, 0, 0, 0, 0,// ºìÉ«
0, 1, 0, 0, 0,// ÂÌÉ«
0, 0, 1 * value, 0, 0,// À¶É«
0, 0, 0, 1, 0,// ͸Ã÷¶È
});
// ¸ø»­±ÊÌí¼Ó¹ýÂËÆ÷
// ¸ø»­±ÊÌí¼ÓÑÕÉ«¹ýÂËÆ÷

paint.setColorFilter(new ColorMatrixColorFilter(cm));

canvas.drawBitmap(bitmap, matrix, paint);
iv.setImageBitmap(buffImage);

}
});
seekbarAlpha.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
float value = progress / 50.0f;
ColorMatrix cm = new ColorMatrix();
cm.set(new float[] { 1, 0, 0, 0, 0,// ºìÉ«
0, 1, 0, 0, 0,// ÂÌÉ«
0, 0, 1, 0, 0,// À¶É«
0, 0, 0, 1 * value, 0,// ͸Ã÷¶È
});
// ¸ø»­±ÊÌí¼Ó¹ýÂËÆ÷
// ¸ø»­±ÊÌí¼ÓÑÕÉ«¹ýÂËÆ÷

paint.setColorFilter(new ColorMatrixColorFilter(cm));

canvas.drawBitmap(bitmap, matrix, paint);
iv.setImageBitmap(buffImage);

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {

float value = progress / 50.0f;
ColorMatrix cm = new ColorMatrix();
cm.set(new float[] { 1, 0, 0, 0, 0,// ºìÉ«
0, 1, 0, 0, 0,// ÂÌÉ«
0, 0, 1, 0, 0,// À¶É«
0, 0, 0, 1 * value, 0,// ͸Ã÷¶È
});
// ¸ø»­±ÊÌí¼Ó¹ýÂËÆ÷
// ¸ø»­±ÊÌí¼ÓÑÕÉ«¹ýÂËÆ÷

paint.setColorFilter(new ColorMatrixColorFilter(cm));

canvas.drawBitmap(bitmap, matrix, paint);
iv.setImageBitmap(buffImage);

}
});
}

}

   
2421 ´Îä¯ÀÀ       27
 
Ïà¹ØÎÄÕÂ

ÊÖ»úÈí¼þ²âÊÔÓÃÀýÉè¼ÆÊµ¼ù
ÊÖ»ú¿Í»§¶ËUI²âÊÔ·ÖÎö
iPhoneÏûÏ¢ÍÆËÍ»úÖÆÊµÏÖÓë̽ÌÖ
AndroidÊÖ»ú¿ª·¢£¨Ò»£©
 
Ïà¹ØÎĵµ

Android_UI¹Ù·½Éè¼Æ½Ì³Ì
ÊÖ»ú¿ª·¢Æ½Ì¨½éÉÜ
androidÅÄÕÕ¼°ÉÏ´«¹¦ÄÜ
Android½²ÒåÖÇÄÜÊÖ»ú¿ª·¢
Ïà¹Ø¿Î³Ì

Android¸ß¼¶Òƶ¯Ó¦ÓóÌÐò
Androidϵͳ¿ª·¢
AndroidÓ¦Óÿª·¢
ÊÖ»úÈí¼þ²âÊÔ
×îл¼Æ»®
DeepSeekÔÚÈí¼þ²âÊÔÓ¦ÓÃʵ¼ù 4-12[ÔÚÏß]
DeepSeek´óÄ£ÐÍÓ¦Óÿª·¢Êµ¼ù 4-19[ÔÚÏß]
UAF¼Ü¹¹ÌåϵÓëʵ¼ù 4-11[±±¾©]
AIÖÇÄÜ»¯Èí¼þ²âÊÔ·½·¨Óëʵ¼ù 5-23[ÉϺ£]
»ùÓÚ UML ºÍEA½øÐзÖÎöÉè¼Æ 4-26[±±¾©]
ÒµÎñ¼Ü¹¹Éè¼ÆÓ뽨ģ 4-18[±±¾©]

androidÈË»ú½çÃæÖ¸ÄÏ
AndroidÊÖ»ú¿ª·¢£¨Ò»£©
AndroidÊÖ»ú¿ª·¢£¨¶þ£©
AndroidÊÖ»ú¿ª·¢£¨Èý£©
AndroidÊÖ»ú¿ª·¢£¨ËÄ£©
iPhoneÏûÏ¢ÍÆËÍ»úÖÆÊµÏÖ̽ÌÖ
ÊÖ»úÈí¼þ²âÊÔÓÃÀýÉè¼ÆÊµ¼ù
ÊÖ»ú¿Í»§¶ËUI²âÊÔ·ÖÎö
ÊÖ»úÈí¼þ×Ô¶¯»¯²âÊÔÑо¿±¨¸æ

Android¸ß¼¶Òƶ¯Ó¦ÓóÌÐò
AndroidÓ¦Óÿª·¢
Androidϵͳ¿ª·¢
ÊÖ»úÈí¼þ²âÊÔ
ǶÈëʽÈí¼þ²âÊÔ
AndroidÈí¡¢Ó²¡¢ÔÆÕûºÏ

ÁìÏÈIT¹«Ë¾ android¿ª·¢Æ½Ì¨×î¼Ñʵ¼ù
±±¾© Android¿ª·¢¼¼Êõ½ø½×
ijÐÂÄÜÔ´ÁìÓòÆóÒµ Android¿ª·¢¼¼Êõ
ijº½Ì칫˾ Android¡¢IOSÓ¦ÓÃÈí¼þ¿ª·¢
°¢¶û¿¨ÌØ LinuxÄÚºËÇý¶¯
°¬Ä¬Éú ǶÈëʽÈí¼þ¼Ü¹¹Éè¼Æ
Î÷ÃÅ×Ó Ç¶Èëʽ¼Ü¹¹Éè¼Æ