Tomando captura de pantalla

Estoy desarrollando una aplicación para tomar capturas de pantalla en el dispositivo. En esta aplicación, podemos dibujar cualquier cosa en la pantalla. Para esto estoy usando Canvas, Paint y Path para hacer esto.

Estoy usando este código para tomar capturas de pantalla:

        public void saveScreenshot() 
    {
        if (ensureSDCardAccess()) 
        {
            Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            onDraw(canvas);
            File file = new File(mScreenshotPath + "/" + System.currentTimeMillis() + ".jpg");
            FileOutputStream fos;
            try {
                fos = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
                fos.close();
            } catch (FileNotFoundException e) {
                Log.e("Panel", "FileNotFoundException", e);
            } catch (IOException e) {
                Log.e("Panel", "IOEception", e);
            }
        }
    }

    /**
     * Helper method to ensure that the given path exists.
     * TODO: check external storage state
     */
    private boolean ensureSDCardAccess() {
        File file = new File(mScreenshotPath);
        if (file.exists()) {
            return true;
        } else if (file.mkdirs()) {
            return true;
        }
        return false;
    }

Sin embargo, cuando se ejecuta la siguiente línea:

Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);

a aplicación @my se cierra con la siguiente excepción:

11-28 15:05:46.291: E/AndroidRuntime(8209): java.lang.IllegalArgumentException: width and height must be > 0

Si cambio la altura y el ancho, se toma la captura de pantalla, pero está vacía:

¿Por qué está pasando eso? ¿Qué estoy haciendo mal

Respuestas a la pregunta(6)

Su respuesta a la pregunta