I have an app that will create a png image of anything the user write in the text field (custom font and color)
What I'm doing is something like this:
- Set Typeface, Text Color and Text to a TextView (BG is transparent)
Using the code below, generate the image for the TextView
Bitmap returnedBitmap = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888); //Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); //Get the view's background Drawable bgDrawable =textView.getBackground(); if (bgDrawable!=null) //has background drawable, then draw it on the canvas bgDrawable.draw(canvas); // draw the view on the canvas view.draw(canvas); FileOutputStream out = null; out = new FileOutputStream(new File(filename)); returnedBitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
The problem is that, the quality of the generated image is not the same as what is displayed in the TextView
Is there any way to improve the quality?
Is it because of the TextView not having a background? If so, is there a workaround for this? Need the generated image to only be the text, hence the transparent background
Thanks