Image handling in Android
-
Upload
tyrone-nicholas -
Category
Technology
-
view
349 -
download
2
description
Transcript of Image handling in Android
![Page 1: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/1.jpg)
@tyronen@tyronen#facebook#facebook
Image handling in AndroidImage handling in Android
Tyrone Nicholas@[email protected]
Tyrone Nicholas@[email protected]
![Page 2: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/2.jpg)
@tyronen@tyronen#facebook#facebook
•~1/10 device RAM
•480 x 800 = 1.5 MB
![Page 3: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/3.jpg)
@tyronen@tyronen#facebook#facebook
GCGC
![Page 4: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/4.jpg)
java.lang.OutOfMemoryError
![Page 5: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/5.jpg)
@tyronen@tyronen#facebook#facebook
Android heapsAndroid heaps
Dalvik
•JDK
•Limited
•Slow
•Safe
Other
•Certain system
calls
•Like native
Native
•NDK
•Unlimited
•Fast
•Unsafe
![Page 6: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/6.jpg)
@tyronen@tyronen#facebook#facebook
What to do with images?What to do with images?
![Page 7: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/7.jpg)
@tyronen@tyronen#facebook#facebook
An image pipelineAn image pipeline
WebP
BMP
BMP JPG
JPG
JPG
UI thread Non-UI threads
![Page 8: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/8.jpg)
@tyronen@tyronen#facebook#facebook
Copying heap to heapCopying heap to heap
![Page 9: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/9.jpg)
@tyronen@tyronen#facebook#facebook
Using native heap from JavaUsing native heap from Java
![Page 10: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/10.jpg)
@tyronen@tyronen#facebook#facebook
BitmapsBitmaps
![Page 11: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/11.jpg)
@tyronen@tyronen#facebook#facebook
AshmemAshmem
• create
• pin
• unpin
![Page 12: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/12.jpg)
@tyronen@tyronen#facebook#facebook
Purgeable bitmapsPurgeable bitmaps
DrawDraw DecodeDecode PinPin
Stop drawin
g
Stop drawin
gUnpinUnpin
![Page 13: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/13.jpg)
@tyronen@tyronen#facebook#facebook
Using Purgeable BitmapsUsing Purgeable Bitmaps
![Page 14: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/14.jpg)
@tyronen@tyronen#facebook#facebook
Er, wait a minute…Er, wait a minute…
![Page 15: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/15.jpg)
@tyronen@tyronen#facebook#facebook
Solution #3 – Bitmap PoolingSolution #3 – Bitmap Pooling
![Page 16: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/16.jpg)
@tyronen@tyronen#facebook#facebook
Hang on…Hang on…
![Page 17: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/17.jpg)
@YourTwitterHandle#DVXFR14{session hashtag} @tyronen@tyronen#facebook#facebook
’s
solution
![Page 18: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/18.jpg)
@tyronen@tyronen#facebook#facebook
From the Android NDKFrom the Android NDK
![Page 19: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/19.jpg)
@tyronen@tyronen#facebook#facebook
Create a new method…Create a new method…
![Page 20: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/20.jpg)
@tyronen@tyronen#facebook#facebook
…and use it…and use it
![Page 21: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/21.jpg)
@tyronen@tyronen#facebook#facebook
But afterwards…But afterwards…
![Page 22: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/22.jpg)
![Page 23: Image handling in Android](https://reader033.fdocuments.in/reader033/viewer/2022052822/554f9222b4c905435d8b511e/html5/thumbnails/23.jpg)
@YourTwitterHandle#DVXFR14{session hashtag} @tyronen@tyronen#facebook#facebook
Q & A
[email protected]@tyronen