Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring A Modified Bitmap To Disk
    primarykey
    data
    text
    <p>The project I am working on requires rounded corners (yes a copy from the iphone unfortunately). I round the corners when the image is downloaded then it is displayed. Here is how I round the corners...</p> <pre><code>public class ImageRounder { private Paint paint = new Paint(); private Canvas canvas; private Rect rect; private RectF rectF; final int color = 0xff424242; @Inject public ImageRounder() {} public synchronized Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap .getHeight(), Bitmap.Config.ARGB_8888); canvas = new Canvas(output); paint.reset(); rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); rectF = new RectF(rect); float roundPx = pixels; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.BLACK); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; } } </code></pre> <p>I also save the images to disk so I don't have to download it more than onces. This is how I save and retrieve the image</p> <pre><code>@Override public synchronized void saveImage(String id, Bitmap bitmap) throws FileNotFoundException { FileOutputStream outputStream = context.openFileOutput(id, Context.MODE_PRIVATE); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream); } @Override public synchronized Bitmap getImage(String id) throws FileNotFoundException { return BitmapFactory.decodeStream(context.openFileInput(id)); } </code></pre> <p>The problem is when I retrieve the image from disk it looks like this...</p> <p><img src="https://i.stack.imgur.com/hist5.jpg" alt="enter image description here"></p> <p>Its hard to tell me the corners are rounded but the background is black. I have tried setting the background of the imageview to both white and transparent but the corners still show as black.</p> <p>Does anybody know why this is?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload