I have seen the following code elsewhere for calculating the size in kb of an Android Bitmap, and was wondering if this is actually destructive to the Bitmap?
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bytes = stream.toByteArray();
long sizeInKB = bytes.length;
Specifically the line:
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
Does this actually mutate the Bitmap? Ideally I am looking for a totally non-destructive way of recording the image size in kb before continuing to use it.
NOTE: It is not practical in this case to use something like:
File file = new File(filepath);
long length = file.length();
Because I don't have the Bitmap on file at that point.
EDIT: I decided to solve my problem by getting the bytes downloaded value a different way: I extended InputStream and overrode the read(byte b[], int off, int len) method to include a counter, which can be returned at completion of the download - or indeed if the download was interrupted at all.