Force close when calling Picture.draw(canvas) in onDraw(Canvas canvas) android custom View

0

I'm trying to draw an android Picture with onDraw() method in a custom View:

MapView extends View implements View.OnTouchListener
{
        Picture pictureBuilding;
        Picture pictureMarkers;


    Canvas frameBuildingCanvas;
    Canvas frameMarkerCanvas;

     public MapView(Context context) {
        super(context);
        init(null, 0);
    }

    private void init(AttributeSet attrs, int defStyle) {

        setOnTouchListener(this);

        pictureBuilding = new Picture();
            Canvas canvasBuilding;
            Paint paintWalls = new Paint();
            paintWalls.setColor(Color.BLUE);


            Path path = new Path();
            path.moveTo(1, 1);
            path.lineTo(250, 1);
            path.lineTo(250, 250);
            path.lineTo(1, 250);
            path.lineTo(1, 1);

            canvasBuilding = pictureBuilding.beginRecording(320, 320);
            canvasBuilding.drawPath(path, paintWalls);
            canvasBuilding.restore();
        pictureBuilding.endRecording();

    }


     @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        pictureBuilding.draw(canvas);

    }
}

The only thing I can get is a force close!

Drawing the pictureBuilding in a new Canvas(bitmap) and passing the bitmap to canvas.drawBitmap(bitmap, ..)

    Paint framePaint = new Paint();

    Bitmap frame = Bitmap.createBitmap(320, 320, Bitmap.Config.ARGB_8888);
    Canvas frameCanvas = new Canvas(frame);
    pictureBuilding.draw(frameCanvas);
    canvas.drawBitmap(frame, 0, 0, framePaint);

works, but I need to use a fast drawing method (I will use pinch to zoom, panning, etc..) and I wonder if I can avoid to use the bitmap.

I need to draw with class Picture because I like to get some separates pictures so that I can change the matrix of each picture independently.

I have to draw an indoor map and some indoor markers, and I need to zoom the map (pictureBuilding) without zooming the markers!

logcat:

02-10 00:05:37.189  14945-14945/com.example.nagash.indoormaptest W/ApplicationPackageManager﹕ getCSCPackageItemText()
02-10 00:05:37.199  14945-14945/com.example.nagash.indoormaptest I/PersonaManager﹕ getPersonaService() name persona_policy
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest W/dalvikvm﹕ VFY: unable to resolve virtual method 11357: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest W/dalvikvm﹕ VFY: unable to resolve virtual method 11363: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest W/dalvikvm﹕ VFY: unable to resolve virtual method 9048: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
02-10 00:05:37.249  14945-14945/com.example.nagash.indoormaptest D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
02-10 00:05:37.259  14945-14945/com.example.nagash.indoormaptest I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
02-10 00:05:37.259  14945-14945/com.example.nagash.indoormaptest W/dalvikvm﹕ VFY: unable to resolve virtual method 364: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
02-10 00:05:37.259  14945-14945/com.example.nagash.indoormaptest D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
02-10 00:05:37.259  14945-14945/com.example.nagash.indoormaptest I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
02-10 00:05:37.259  14945-14945/com.example.nagash.indoormaptest W/dalvikvm﹕ VFY: unable to resolve virtual method 386: Landroid/content/res/TypedArray;.getType (I)I
02-10 00:05:37.259  14945-14945/com.example.nagash.indoormaptest D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
02-10 00:05:37.379  14945-14945/com.example.nagash.indoormaptest I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build:  (CL3869936)
    OpenGL ES Shader Compiler Version: 17.01.11.SPL
    Build Date: 01/17/14 Fri
    Local Branch:
    Remote Branch:
    Local Patches:
    Reconstruct Branch:
02-10 00:05:37.419  14945-14945/com.example.nagash.indoormaptest D/OpenGLRenderer﹕ Enabling debug mode 0
02-10 00:05:37.449  14945-14945/com.example.nagash.indoormaptest A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x00000058 (code=1), thread 14945 (h.indoormaptest)

android
image
canvas
ondraw
custom-view
asked on Stack Overflow Feb 9, 2015 by Nagash • edited Feb 9, 2015 by Nagash

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0