Sch*_*ger 16 graphics performance android
我想将一个位图图像的裁剪版本加载到Bitmap对象中,而不加载原始位图.
如果不编写自定义加载例程来处理原始数据,这是否可行?
谢谢,桑德尔
Ste*_*ley 13
这实际上非常简单.使用
Bitmap yourBitmap = Bitmap.createBitmap(sourceBitmap, x to start from, y to start from, width, height)
更新:使用BitmapRegionDecoder
Ren*_*ith 10
试试这个
InputStream istream = null;
try {
istream = this.getContentResolver().openInputStream(yourBitmapUri);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
BitmapRegionDecoder decoder = null;
try {
decoder = BitmapRegionDecoder.newInstance(istream, false);
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bMap = decoder.decodeRegion(new Rect(istream, x to start from, y to start from, x to end with, y to end with), null);
imageView.setImageBitmap(bMap);
Run Code Online (Sandbox Code Playgroud)