开发者

Android app crashes when I call bitmap.setPixel

开发者 https://www.devze.com 2023-02-28 21:04 出处:网络
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,

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 ?

0

精彩评论

暂无评论...
验证码 换一张
取 消