public static Bitmap getMutableBitmap(Bitmap bitmap)
{
if(bitmap == null || bitmap.isMutable())
{
return bitmap;
}
try {
File file = new File(AppConstants.SDCARD_PATH+"/mutable.txt");
file.getParentFile().mkdirs();
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
int width = bitmap.getWidth();
int height = bitmap.getHeight();
FileChannel channel = randomAccessFile.getChannel();
MappedByteBuffer map = channel.map(MapMode.READ_WRITE, 0, width*height*4);
bitmap.copyPixelsToBuffer(map);
bitmap.recycle();
bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
map.position(0);
bitmap.copyPixelsFromBuffer(map); channel.close();
randomAccessFile.close();
} catch (Exception e) {
return bitmap.copy(Bitmap.Config.ARGB_8888, true);
}
return bitmap;
}
public static Bitmap getMutableBitmap(Bitmap bitmap)
原创
©著作权归作者所有:来自51CTO博客作者TechOnly的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
bitmap架构优化 bitmap简介
&n
bitmap架构优化 Bitmap Matrix android图像处理 android -
bitmap框架 swift bitmap parameters
GDI基本概念及思想 编写代码的一般步骤:先用CreateDC创建(或GetDC获取)device content(DC),然后用GetObject获取(或使用创建object的函数创建)需要的object,并用SelectObject将获取的object选入device content(DC),再使用object
bitmap框架 swift object structure application function -
java工厂模式坏处
一、工厂模式主要是为创建对象提供过渡接口,以便将创建对象的具体过程屏蔽隔离起来,达到提高灵活性的目的。设计模式的原则:针对借口编程工厂模式的作用: A.应用程序的设计中把对象的的创建集中在一个地方创建或者统一由某类来管理(spring)  
java工厂模式坏处 java 设计模式 简单工厂模式 工厂方法模式