androiddecodebitmapfactorysample-size

Android BitmapFactory decodeStream()


I have a question that I seem to find the answer nowhere. Does this lines of code:

final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;

    BitmapFactory.decodeStream(is, null, options);

actually mean that, that file is being downloaded? Android docs say something like this:

decode with inJustDecodeBounds=true to check dimensions

and Does:

options.inSampleSize = calculateInSampleSize(options, reqWidth,
            reqHeight);

    // Decode bitmap with inSampleSize set
    options.inJustDecodeBounds = false;
    BitmapFactory.decodeStream(is, null, options);

means that it will actually download the file smaller (not downloaded as original size and copied after that to a smaller size bitmap).

Clear example: I have some url's that point to many 2000 x 1500 images. By decoding those files and loading them to bitmaps, do I need to have enough memory for downloading the file at its full resolution (2000 x 1500), if I only need thumbnails of (200 x 150)?


Solution

  • Indeed looks like the file is being downloaded, and the effiency part comes where the bitmap being loaded in memory is the smaller one ( the one being decoded with inSampleSize options).