android - UnsupportedException from Canvas.setBitmap(Bitmap) -
i'm creating app drawings , such under users control , let's them save it. way i'm trying achieve using custom bitmap on canvas draws saving resulting bitmap.
everything working expected, until canvas.setbitmap(bitmap) called.
i following error.
03-24 13:47:50.741: e/androidruntime(27888): fatal exception: main 03-24 13:47:50.741: e/androidruntime(27888): process: example.imageeditor, pid: 27888 03-24 13:47:50.741: e/androidruntime(27888): java.lang.unsupportedoperationexception 03-24 13:47:50.741: e/androidruntime(27888): @ android.view.hardwarecanvas.setbitmap(hardwarecanvas.java:39)
code throwing exception:
protected void ondraw(canvas canvas) { mresultimage=bitmap.createbitmap(width,height,moriginalimage.getconfig()); canvas.setbitmap(mresultimage); canvas.save(); if(moriginalimage!=null) canvas.drawbitmap(moriginalimage, width, height, paint); else canvas.drawtext("image loading...", width/2f-20, height/2, paint); canvas.drawtext(text, x, y-20, paint); canvas.restore(); super.ondraw(canvas); }
the android.view.hardwarecanvas isn't on reference of android. able find information it. seems it's setbitmap(bitmap) isn't written yet, , that's ok.
my question why ondraw(canvas) returning hardwarecanvas class? isn't super class canvas.
bonus question: way around this?
if want draw on bitmap should create new canvas passing bitmap it. should not allowed change target of canvas view should drawn on. create new canvas bitmap , draw resulting bitmap on canvas in ondraw method.
Comments
Post a Comment