@@ -44,6 +44,11 @@ public class LineChartRenderer extends LineRadarRenderer {
4444 */
4545 protected Canvas mBitmapCanvas ;
4646
47+ /**
48+ * the bitmap configuration to be used
49+ */
50+ protected Bitmap .Config mBitmapConfig = Bitmap .Config .ARGB_8888 ;
51+
4752 protected Path cubicPath = new Path ();
4853 protected Path cubicFillPath = new Path ();
4954
@@ -87,7 +92,7 @@ public void drawData(Canvas c) {
8792
8893 if (width > 0 && height > 0 ) {
8994
90- mDrawBitmap = new WeakReference <Bitmap >(Bitmap .createBitmap (width , height , Bitmap . Config . ARGB_8888 ));
95+ mDrawBitmap = new WeakReference <Bitmap >(Bitmap .createBitmap (width , height , mBitmapConfig ));
9196 mBitmapCanvas = new Canvas (mDrawBitmap .get ());
9297 } else
9398 return ;
@@ -571,6 +576,27 @@ public void drawHighlighted(Canvas c, Highlight[] indices) {
571576 }
572577 }
573578
579+ /**
580+ * Sets the Bitmap.Config to be used by this renderer.
581+ * Default: Bitmap.Config.ARGB_8888
582+ * Use Bitmap.Config.ARGB_4444 to consume less memory.
583+ *
584+ * @param config
585+ */
586+ public void setBitmapConfig (Bitmap .Config config ) {
587+ mBitmapConfig = config ;
588+ releaseBitmap ();
589+ }
590+
591+ /**
592+ * Returns the Bitmap.Config that is used by this renderer.
593+ *
594+ * @return
595+ */
596+ public Bitmap .Config getBitmapConfig () {
597+ return mBitmapConfig ;
598+ }
599+
574600 /**
575601 * Releases the drawing bitmap. This should be called when {@link LineChart#onDetachedFromWindow()}.
576602 */
0 commit comments