I encrypt, then decrypt an image that I then pass to my image util for resizing, (code graciously borrowed from somewhere) like so:
public static Bitmap loadResizedBitmap(InputStream dis, int width, int height) {
BufferedInputStream bis = new BufferedInputStream(dis);
Bitmap bitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(bis, null, options);
if (options.outHeight > 0 && options.outWidth > 0) {
options.inJustDecodeBounds = false;
options.inSampleSize = 2;
while (options.outWidth / options.inSampleSize > width &&
options.outHeight / options.inSampleSize > height) {
options.inSampleSize++;
}
options.inSampleSize--;
bitmap = BitmapFactory.decodeStream(bis, null, options);
}
return bitmap;
}
The issue is during the second decodeStream, the BitmapFactory returns null. I have verified the first one works, and outputs the correct size, etc. My guess is that CipherInputStream does not support mark and reset, so I wrapped it in a BufferedInputStream with no luck. Does anyone else have any suggestions?
[ANSWERED]
I switched it to use BitmapFactory.decodeByteArray and that solved it. I took another look at the API and I was able to pass along a byte[].
My takeaway is CipherInputStream does not support mark() and reset().