Сохранение холста в растровое изображение на Android

У меня возникли некоторые трудности с размещением содержимого холста в растровое изображение. Когда я пытаюсь это сделать, файл записывается с размером файла около 5,80 КБ, но кажется, что он абсолютно пустой (каждый пиксель равен «# 000»).

Холст рисует серию взаимосвязанных линий, которые формируются почерком. Ниже мой onDraw для просмотра. (Я знаю, что он блокирует поток пользовательского интерфейса / плохие практики / и т. Д., Но мне просто нужно, чтобы он работал)

Спасибо.

@Override
protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    super.onDraw(canvas);

        if (IsTouchDown) {

            // Calculate the points
            Path currentPath = new Path();
            boolean IsFirst = true;
            for(Point point : currentPoints){
                if(IsFirst){
                    IsFirst = false;
                        currentPath.moveTo(point.x, point.y);
                    } else {
                        currentPath.lineTo(point.x, point.y);
                    }
                }

            // Draw the path of points
            canvas.drawPath(currentPath, pen);

            // Attempt to make the bitmap and write it to a file.
            Bitmap toDisk = null;
            try {

                // TODO: Get the size of the canvas, replace the 640, 480
                toDisk = Bitmap.createBitmap(640,480,Bitmap.Config.ARGB_8888);
                canvas.setBitmap(toDisk);
                toDisk.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File("arun.jpg")));

            } catch (Exception ex) {


            }

        } else {

            // Clear the points
            currentPoints.clear();

        }
    }

Ответы на вопрос(5)

Ваш ответ на вопрос