/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }
/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }
/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }
/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }
/** * Returns the bitmap that represents the chart. * * @return */ public Bitmap getChartBitmap() { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.RGB_565); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = getBackground(); if (bgDrawable != null) // has background drawable, then draw it on the canvas { bgDrawable.draw(canvas); } else // does not have background drawable, then draw white background on // the canvas { canvas.drawColor(Color.WHITE); } // draw the view on the canvas draw(canvas); // return the bitmap return returnedBitmap; }