android


How to set BitmapFactory.Option to bitmap object?


I have a function that uses file path to access a JPG file on sdCard and create a bitmap of it. It uses inSampleSize to make a RAM compatible bitmap:
public static Bitmap decodeSampledBitmapFromResource(String imgPath, int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(imgPath, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options,reqWidth,reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(imgPath, options);
}
Now I wanna pass a bitmap to this function instead of imgPath like this:
public static Bitmap decodeSampledBitmapFromResource(Bitmap bitmap, int reqWidth, int reqHeight)
I want to do that because I have multiple bitmaps on screen. I can use a large temp bitmap but I cant add that to my bitmap list because of memory issues. BitmapFactory does not have this option. What is the best way to do this?

Related Links

Setting the text color based on state of a Custom Tab View
Some questions of ActionBar on Android
Application stops on changing page
How to swipe between pages or layouts without using ViewPager or ViewFlipper?
Table - Conflict onTouchEvent and OnClickListener
non-numeric second argument to 'wordlist'
Android Studio proguard doesn't work
Setting bitmap though setImageBitmap() results only in gifs being visible in view
launch fragment by variable name
retrieve video (categoryID) from youtube using json
PreferenceFragment::onPreferenceTreeClick return value - what does it do?
ListView is not updating the entries from array
Point a computer to an Android phone - position or direction of the phone based on its sensors?
No Activity found to handle Intent - Error
multiple fragments from ONE ActionTab
update a DialogFragment view (and using a AsyncTask)

Categories

HOME
twig
sh
gradient
cakephp-3.4
mapbox
lanczos
discrete-mathematics
github-enterprise
text-mining
atlassian
nodemcu
user-experience
squashfs
mongoid6
roundup
licensing
outliers
fractions
firebase-analytics
scrollview
aws-codecommit
python-2.6
cart
deltaspike
dumpbin
memory-address
activexobject
openwhisk
joomla2.5
engine.io
protege4
openerp-7
zoomify
metaprogramming
datacachefactory
wmp
httrack
mschart
css-transforms
bootstrap-tags-input
rxtx
atlas
pytables
greatest-n-per-group
drawstring
vorpal.js
upx
blitline
video-player
haskell-warp
ocra
botan
jquery-forms-plugin
code-documentation
mass-assignment
appserver
raygun
named-parameters
malformedurlexception
paste
qscrollarea
hibernate-entitymanager
http-patch
mysql-error-1044
oocss
observium
sentestingkit
cgimage
screen-size
drawtobitmap
unattended-processing
cdonts
django-paypal
codebase
cac
ie-compatibility-mode
purepdf
asynchronous-wcf-call
image-capture
great-circle

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App