Android app crashes when I call bitmap.setPixel
I'm tryimng to see if I can creat dynamic images by creating a bitmap and using setPixel. The program crashes when I call setPixel
,
Bitmap bm= createBitmap (50,50, Bitmap.Config.RGB_565);
// program crashes here
bm.setPixel(25,25,0xffffff);
// add a test viue
ImageView mImage= new Ima开发者_运维技巧geView(this);
mImage.setImageBitmap(bm);
LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
layout.addView(mImage);
I figure it is something simple, but cannot figure it out. Ted
Can you paste the error message for more information ?
You're using Bitmap.Config.RGB_565, did you have tried with Bitmap.Config.ARGB_8888 instead ?
精彩评论