标签:
1.打开根目录下test.jpg
Bitmap bm = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.jpg");
int[] pixels = new int[bm.getWidth()*bm.getHeight()];
bm.getPixels =(pixels,0,bm.getWidth(),0,0,bm.getWidth(),bm.getHeight() );
Bitmap bm1 = bm.copy(bm.getConfig(),true);//bm is not Mutable ,像素值不能改
bm1.setPixels(pixels,0,bm.getWidth(),0,0,bm.getWidth(),bm.getHeight() );
saveBitmap("test2",bm1);
ImageVie imgview = (ImageView)findViewById(R.id.imageView1);
imgview.setImageBitmap(bm1);
2.保存图片
public void saveBitmap(String name,Bitmap mBitmap){
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+name+".png");
file.createNewFile();
FileOutPutStream fout = null;
fout = new FileOutPutStream(file);
mBitmap.compress(Bitmap.CompressFormat.PNG,100,fout);
fout.flush();
fout.close();
}
标签:
原文地址:http://www.cnblogs.com/mlj318/p/4512355.html