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();

}

更多相关文章

  1. android 模拟器对应像素
  2. android 字体大小像素的设置
  3. android 字体大小,样式 ,像素的设置
  4. android 获取sd卡根目录
  5. Android - 像素密度和屏幕适配
  6. android通过USB的MTP模式下,禁止用户在根目录有任何操作(重命名 删
  7. Android 自定义像素AVD模拟器无键盘
  8. Android 中如何得到字符的像素宽度
  9. android 获取外置sd卡根目录

随机推荐

  1. 如何让android 支持多种屏幕尺寸
  2. Android事件分发机制完全解析,带你从源码
  3. Android学习总结
  4. Android常用Layout源码总结—FrameLayout
  5. AndroidX终极迁移指南
  6. 全球开发者:iOS、Android、WP哪个最赚钱?
  7. Android图片资源的缩放问题
  8. 简单处理Android(安卓)65536方法越界问题
  9. Android 利用addView 动态给Activity添加
  10. Android -- AppWidget 高级篇