public voidonCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}private static class SampleView extendsView {privateBitmap mBitmap;publicSampleView(Context context) {super(context);
setFocusable(true);
Bitmap bmp= null;
String filePath= Environment.getExternalStorageDirectory().getAbsolutePath()+"/sx/852.png";
BitmapFactory.Options options=newOptions();
options.inPreferredConfig=Bitmap.Config.ARGB_4444;
bmp=BitmapFactory.decodeFile(filePath, options);
Log.v(TAG,"decode success--threadid=="+Thread.currentThread().getId()+",name=="+Thread.currentThread().getName());
mBitmap=bmp;//decodeStream 流
/*java.io.InputStream is;
is = context.getResources().openRawResource(R.drawable.r8521);
BitmapFactory.Options opts = new BitmapFactory.Options();
Bitmap bm;
opts.inPreferredConfig = Bitmap.Config.ARGB_4444;
//opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
bm = BitmapFactory.decodeStream(is, null, opts);
mBitmap = bm;*/
//TODO Auto-generated constructor stub
}
@Overrideprotected voidonDraw(Canvas canvas) {//TODO Auto-generated method stub
canvas.drawColor(0xFF000000);
canvas.drawBitmap(mBitmap,0, 0, null);
}
}