BitmapFactory

Options

1. inBitmap

重用這個(gè)bitmap

  • If set, decode methods that take the Options object will attempt to reuse this bitmap when loading content.
  • If the decode operation cannot use this bitmap, the decode method will return null and will throw an IllegalArgumentException.
  • The current implementation necessitates that the reused bitmap be mutable, and the resulting reused bitmap will continue to remain mutable even when decoding a resource which would normally result in an immutable bitmap.
  • You should still always use the returned Bitmap of the decode method and not assume that reusing the bitmap worked, due to the constraints outlined above and failure situations that can occur. Checking whether the return value matches the value of the inBitmap set in the Options structure will indicate if the bitmap was reused, but in all cases you should use the Bitmap returned by the decoding function to ensure that you are using the bitmap that was used as the decode destination.

配合 BitmapFactory 使用

Usage with BitmapFactory

  • As of android.os.Build.VERSION_CODES.KITKAT, any mutable bitmap can be reused by BitmapFactory to decode any other bitmaps as long as the resulting byte count of the decoded bitmap is less than or equal to the allocated byte count of the reused bitmap. This can be because the intrinsic size is smaller, or its size post scaling (for density / sample size) is smaller.
  • Prior to android.os.Build.VERSION_CODES.KITKAT additional constraints apply: The image being decoded (whether as a resource or as a stream) must be in jpeg or png format. Only equal sized bitmaps are supported, with inSampleSize set to 1. Additionally, the configuration of the reused bitmap will override the setting of inPreferredConfig, if set.

配合 BitmapRegionDecoder 使用

Usage with BitmapRegionDecoder
BitmapRegionDecoder will draw its requested content into the Bitmap provided, clipping if the output content size (post scaling) is larger than the provided Bitmap. The provided Bitmap's width, height, and Bitmap.Config will not be changed.
BitmapRegionDecoder support for inBitmap was introduced in android.os.Build.VERSION_CODES.JELLY_BEAN. All formats supported by BitmapRegionDecoder support Bitmap reuse via inBitmap.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末辟宗,一起剝皮案震驚了整個(gè)濱河市汉买,隨后出現(xiàn)的幾起案子瘸彤,更是在濱河造成了極大的恐慌,老刑警劉巖戈毒,帶你破解...
    沈念sama閱讀 222,729評(píng)論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異横堡,居然都是意外死亡埋市,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,226評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門命贴,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)道宅,“玉大人,你說(shuō)我怎么就攤上這事胸蛛∥垡穑” “怎么了?”我有些...
    開(kāi)封第一講書人閱讀 169,461評(píng)論 0 362
  • 文/不壞的土叔 我叫張陵葬项,是天一觀的道長(zhǎng)泞当。 經(jīng)常有香客問(wèn)我,道長(zhǎng)玷室,這世上最難降的妖魔是什么零蓉? 我笑而不...
    開(kāi)封第一講書人閱讀 60,135評(píng)論 1 300
  • 正文 為了忘掉前任,我火速辦了婚禮穷缤,結(jié)果婚禮上敌蜂,老公的妹妹穿的比我還像新娘。我一直安慰自己津肛,他們只是感情好章喉,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,130評(píng)論 6 398
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著身坐,像睡著了一般秸脱。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上部蛇,一...
    開(kāi)封第一講書人閱讀 52,736評(píng)論 1 312
  • 那天摊唇,我揣著相機(jī)與錄音,去河邊找鬼涯鲁。 笑死巷查,一個(gè)胖子當(dāng)著我的面吹牛有序,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播岛请,決...
    沈念sama閱讀 41,179評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼旭寿,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了崇败?” 一聲冷哼從身側(cè)響起盅称,我...
    開(kāi)封第一講書人閱讀 40,124評(píng)論 0 277
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎后室,沒(méi)想到半個(gè)月后缩膝,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,657評(píng)論 1 320
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡咧擂,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,723評(píng)論 3 342
  • 正文 我和宋清朗相戀三年逞盆,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片松申。...
    茶點(diǎn)故事閱讀 40,872評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡云芦,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出贸桶,到底是詐尸還是另有隱情舅逸,我是刑警寧澤,帶...
    沈念sama閱讀 36,533評(píng)論 5 351
  • 正文 年R本政府宣布皇筛,位于F島的核電站琉历,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏水醋。R本人自食惡果不足惜旗笔,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,213評(píng)論 3 336
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望拄踪。 院中可真熱鬧蝇恶,春花似錦、人聲如沸惶桐。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 32,700評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)姚糊。三九已至贿衍,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間救恨,已是汗流浹背贸辈。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 33,819評(píng)論 1 274
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留肠槽,地道東北人裙椭。 一個(gè)月前我還...
    沈念sama閱讀 49,304評(píng)論 3 379
  • 正文 我出身青樓躏哩,卻偏偏與公主長(zhǎng)得像署浩,于是被迫代替她去往敵國(guó)和親揉燃。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,876評(píng)論 2 361

推薦閱讀更多精彩內(nèi)容