有用代码片段(2)
protected void doCropPhoto(File f) {
try {
final Intent intent = getCropImageIntent(Uri.fromFile(f));
startActivityForResult(intent, PHOTO_PICKED_WITH_DATA);
} catch (Exception e) {
Toast.makeText(this, "111111111111111",Toast.LENGTH_LONG).show();
}
}
public static Intent getCropImageIntent(Uri photoUri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(photoUri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 80);
intent.putExtra("outputY", 80);
intent.putExtra("return-data", true);
return intent;
}
/**
*
* Bitmap picture = Bitmap.createBitmap( 480, 480, Config.ARGB_8888 ); //创建一张480*480大小的图片
Canvas canvasTemp = new Canvas( picture ); //创建画布
canvasTemp.drawColor(Color.TRANSPARENT); //设置画布透明
Paint p = new Paint();
smallpic=Bitmap.createBitmap(bigpic, 0, (count-1)*width, width, width); //从大图片中取得第count张图片,从上往下数
canvasTemp.drawBitmap(smallpic, 0, 0, p); //将取得小图片画在画布上,位置(0,0)
*
* */
本文出自 “技术人生” 博客,请务必保留此出处http://zhaohaiyang.blog.51cto.com/2056753/615518
相关新闻>>
- 发表评论
-
- 最新评论 更多>>