filmov
tv
Performance optimisations for android applications - Part 3 BitmapFactory.Options inSampleSize

Показать описание
Part 3 - Uses the BitmapFactory.Options inSampleSize to subsample the original image therefore loading a smaller image saving memory & cpu resources, resulting in more responsiveness especially in scrolling.
These tutorials are expected to be viewed in sequence starting from Part 1 & Part 2.
In this part of the android tutorial performance series we identify one of the main performance issues is with loading the full size images straight into the much smaller ImageViews thumbnails.
The result is to create a scale factor algorithm to measure the difference in width & height between the image & ImageView and output that result as a factor of 2.
This can then be feed into the BitmapFactory.Options inSampleSize where subsampling can then take place resulting the loading of a smaller image.
All this happens in a background thread created by a AsyncTask.
In this tutorial we will cover:
- Creating the scale factor algorithm
- Getting the image dimensions from inJustDecodeBounds to true
- Calling the scale factor algorithm
- Setting the inSampleSize prior to loading the image
- Run the application and check for performance changes
- Debug app and step through the code changes
The previous tutorials were aimed at beginners to android but over time have been getting more complex as the original camera_intent app has developed.
This tutorial series is more aimed towards the intermediate developers but for those who have been following the previous tutorial series, feel free to watch this android performance series.
Android studio (1.2.1) is the editor of choice (IDE) for this tutorial series.
API's covered
- BitmapFactory.Options
- BitmapFactory.Options inJustDecodeBounds
- BitmapFactory.Options inSampleSize
- BitmapFactory.DecodeFile
This tutorial series is the start of what I expect to be many so I encourage comments and feedback to improve the quality and viewing experience.
These tutorials are expected to be viewed in sequence starting from Part 1 & Part 2.
In this part of the android tutorial performance series we identify one of the main performance issues is with loading the full size images straight into the much smaller ImageViews thumbnails.
The result is to create a scale factor algorithm to measure the difference in width & height between the image & ImageView and output that result as a factor of 2.
This can then be feed into the BitmapFactory.Options inSampleSize where subsampling can then take place resulting the loading of a smaller image.
All this happens in a background thread created by a AsyncTask.
In this tutorial we will cover:
- Creating the scale factor algorithm
- Getting the image dimensions from inJustDecodeBounds to true
- Calling the scale factor algorithm
- Setting the inSampleSize prior to loading the image
- Run the application and check for performance changes
- Debug app and step through the code changes
The previous tutorials were aimed at beginners to android but over time have been getting more complex as the original camera_intent app has developed.
This tutorial series is more aimed towards the intermediate developers but for those who have been following the previous tutorial series, feel free to watch this android performance series.
Android studio (1.2.1) is the editor of choice (IDE) for this tutorial series.
API's covered
- BitmapFactory.Options
- BitmapFactory.Options inJustDecodeBounds
- BitmapFactory.Options inSampleSize
- BitmapFactory.DecodeFile
This tutorial series is the start of what I expect to be many so I encourage comments and feedback to improve the quality and viewing experience.
Комментарии