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