{"id":357,"date":"2013-05-28T01:19:49","date_gmt":"2013-05-27T16:19:49","guid":{"rendered":"https:\/\/www.united-bears.co.jp\/blog\/?p=357"},"modified":"2013-05-28T01:22:40","modified_gmt":"2013-05-27T16:22:40","slug":"imageview-%e3%81%ab%e3%82%bb%e3%83%83%e3%83%88%e3%81%97%e3%81%9f-bitmap-%e3%81%af%e3%81%a9%e3%81%86%e3%81%aa%e3%82%8b%e3%81%ae%e3%81%8b1","status":"publish","type":"post","link":"https:\/\/www.united-bears.co.jp\/blog\/archives\/357","title":{"rendered":"ImageView \u306b\u30bb\u30c3\u30c8\u3057\u305f Bitmap \u306f\u3069\u3046\u306a\u308b\u306e\u304b(1)"},"content":{"rendered":"<p>Android \u3067\u753b\u50cf\u3092\u6271\u3046\u3068\u3001\u3059\u3050\u306b OutOfMemoryError \u306b\u304a\u76ee\u306b\u304b\u304b\u308b\u3002\u57fa\u672c\u7684\u306b\u306f\u3001Bitmap \u3092\u4f7f\u3044\u7d42\u308f\u3063\u305f\u3089 recycle() \u3059\u308b\u3053\u3068\u3067\u56de\u907f\u3067\u304d\u308b\u306e\u3060\u304c(Android 2.x \u7cfb\u3067\u306f\u3001Bitmap \u306f native \u306a\u9818\u57df\u306b\u78ba\u4fdd\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001gc \u3067\u81ea\u52d5\u7684\u306b\u56de\u53ce\u3055\u308c\u306a\u3044)\u3001\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u8aad\u307f\u8fbc\u3093\u3060\u753b\u50cf\u306f immutable \u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306a\u308b\u306e\u3067\u3001Bitmap \u3092\u30b3\u30d4\u30fc\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u305a\u3001\u305d\u3053\u3067\u843d\u3061\u305f\u308a\u3057\u3066\u306a\u304b\u306a\u304b\u3084\u3063\u304b\u3044\u3060\u3002<\/p>\n<p>Bitmap \u306e\u5229\u7528\u6642\u306b\u767a\u751f\u3059\u308b OutOfMemoryError \u306e\u56de\u907f\u65b9\u6cd5\u306f\u8208\u5473\u6df1\u3044\u306e\u3060\u304c\u3001\u305f\u304f\u3055\u3093\u306e\u8a18\u4e8b\u304c\u3042\u308b\u306e\u3067\u5f8c\u56de\u3057\u306b\u3057\u3066\u3001\u4f55\u56de\u304b\u306b\u6e21\u3063\u3066 ImageView \u3092\u8abf\u3079\u3066\u307f\u3088\u3046\u3068\u601d\u3046\u3002ImageView \u306b\u306f\u3001setImageBitmap(Bitmap bm)\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u304c\u7528\u610f\u3055\u308c\u3066\u304a\u308a\u3001Bitmap \u3092\u30bb\u30c3\u30c8\u3057\u3066\u63cf\u753b\u3067\u304d\u308b\u3002Bitmap \u306a\u306e\u3067\u3001\u5f53\u7136 recycle()\u3092\u547c\u3073\u51fa\u3055\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u304c\u3001\u547c\u3073\u51fa\u3059\u30bf\u30a4\u30df\u30f3\u30b0\u304c\u96e3\u3057\u3044\u3002\u3067\u304d\u308c\u3070\u3001ImageView \u304c\u51e6\u7406\u3057\u3066\u304f\u308c\u308b\u3068\u3046\u308c\u3057\u3044\u306e\u3060\u304c\u30fb\u30fb\u30fb<\/p>\n<p>\u307e\u305a\u306f\u3001<a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/ImageView.html#setImageBitmap(android.graphics.Bitmap)\" target=\"_blank\">API \u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u3092\u8abf\u3079\u3066\u307f\u305f\u3002<\/p>\n<blockquote><p>\nSets a Bitmap as the content of this ImageView.<\/p>\n<p>Parameters<br \/>\nbm The bitmap to set\n<\/p><\/blockquote>\n<p>Simple is best.   Bitmap \u304c\u3069\u3046\u306a\u308b\u306e\u304b\u306a\u3093\u3066\u3001\u5168\u304f\u8aac\u660e\u304c\u306a\u3044\u3002\u4ed5\u65b9\u304c\u306a\u3044\u306e\u3067\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u8aad\u3080\u3002\u4eca\u56de\u306f\u3001<a href=\"http:\/\/grepcode.com\/\" target=\"_blank\">grepcode.com<\/a>\u30674.2.2_r1\u306e\u30b3\u30fc\u30c9\u3092\u898b\u3066\u307f\u305f\u3002<\/p>\n<pre>\r\n     @android.view.RemotableViewMethod\r\n     public void setImageBitmap(Bitmap bm) {\r\n         setImageDrawable(new BitmapDrawable(mContext.getResources(), bm));\r\n     }\r\n<\/pre>\n<p>\u30bb\u30c3\u30c8\u3057\u305f Bitmap \u306b\u4f55\u304b\u3057\u3066\u3044\u308b\u69d8\u5b50\u306f\u306a\u3044\u30fb\u30fb\u30fb\u3067\u3059\u306d\u3002ImageView \u306b\u30bb\u30c3\u30c8\u3057\u305f Bitmap \u3092\u81ea\u5206\u3067 recycle() \u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3068\u3059\u308b\u3068\u3001\u3061\u3087\u3063\u3068\u4e0d\u4fbf\u3059\u304e\u308b\u306e\u3067\u3001\u6b21\u56de\u306f Bitmap \u3092\u81ea\u5206\u3067 recycle() \u3057\u306a\u304b\u3063\u305f\u3089\u30e1\u30e2\u30ea\u30fc\u30ea\u30fc\u30af\u3059\u308b\u306e\u304b\u3069\u3046\u304b\u8abf\u3079\u3066\u307f\u308b\u3053\u3068\u306b\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Android \u3067\u753b\u50cf\u3092\u6271\u3046\u3068\u3001\u3059\u3050\u306b OutOfMemoryError \u306b\u304a\u76ee\u306b\u304b\u304b\u308b\u3002\u57fa\u672c\u7684\u306b\u306f\u3001Bitmap \u3092\u4f7f\u3044\u7d42\u308f\u3063\u305f\u3089 recycle() \u3059\u308b\u3053\u3068\u3067\u56de\u907f\u3067\u304d\u308b\u306e\u3060\u304c(Android 2.x \u7cfb\u3067\u306f\u3001Bit [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-357","post","type-post","status-publish","format-standard","hentry","category-android","category-android-develop"],"_links":{"self":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=357"}],"version-history":[{"count":12,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/357\/revisions"}],"predecessor-version":[{"id":369,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/357\/revisions\/369"}],"wp:attachment":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}