{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/fresco/issues/166","labels_url":"https://api.github.com/repos/facebook/fresco/issues/166/labels{/name}","comments_url":"https://api.github.com/repos/facebook/fresco/issues/166/comments","events_url":"https://api.github.com/repos/facebook/fresco/issues/166/events","html_url":"https://github.com/facebook/fresco/issues/166","id":69404703,"number":166,"title":"Use callback method to  get Bitmap reference ?","user":{"login":"leelei","id":8695231,"avatar_url":"https://avatars.githubusercontent.com/u/8695231?v=3","gravatar_id":"","url":"https://api.github.com/users/leelei","html_url":"https://github.com/leelei","followers_url":"https://api.github.com/users/leelei/followers","following_url":"https://api.github.com/users/leelei/following{/other_user}","gists_url":"https://api.github.com/users/leelei/gists{/gist_id}","starred_url":"https://api.github.com/users/leelei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leelei/subscriptions","organizations_url":"https://api.github.com/users/leelei/orgs","repos_url":"https://api.github.com/users/leelei/repos","events_url":"https://api.github.com/users/leelei/events{/privacy}","received_events_url":"https://api.github.com/users/leelei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-19T09:25:04Z","updated_at":"2015-04-19T13:12:26Z","closed_at":null,"body":"I use ```Palette.generateAsync``` ,  so I need get  a Bitmap reference \r\n```\r\nPostprocessor palettePostprocessor = new Postprocessor() { \r\n  @Override\r\n  public String getName() {\r\n    return \"PalettePostprocessor\";\r\n  }\r\n\r\n  @Override\r\n  public void process(Bitmap bitmap) {\r\n     //Palette.generateAsync(bitmap, paletteAsyncListener)\r\n    }\r\n  }\r\n}\r\n```\r\nbut , it is a copy of origin Bitmap ,because of  performance , so i just  use this\r\n```\r\n setPostprocessor(new Postprocessor() {\r\n        @Override public CloseableReference<Bitmap> process(Bitmap sourceBitmap,\r\n            PlatformBitmapFactory bitmapFactory) {\r\n          return CloseableReference.of(sourceBitmap, new ResourceReleaser<Bitmap>() {\r\n            @Override public void release(Bitmap value) {\r\n            }\r\n          });\r\n        }\r\n\r\n        @Override public String getName() {\r\n          return null;\r\n        }\r\n      })\r\n```\r\nin  ```release(Bitmap value)```  do nothing( it will be auto recycle ?), it is ok ?"},"comment":{"url":"https://api.github.com/repos/facebook/fresco/issues/comments/94275591","html_url":"https://github.com/facebook/fresco/issues/166#issuecomment-94275591","issue_url":"https://api.github.com/repos/facebook/fresco/issues/166","id":94275591,"user":{"login":"plamenko","id":3705123,"avatar_url":"https://avatars.githubusercontent.com/u/3705123?v=3","gravatar_id":"","url":"https://api.github.com/users/plamenko","html_url":"https://github.com/plamenko","followers_url":"https://api.github.com/users/plamenko/followers","following_url":"https://api.github.com/users/plamenko/following{/other_user}","gists_url":"https://api.github.com/users/plamenko/gists{/gist_id}","starred_url":"https://api.github.com/users/plamenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plamenko/subscriptions","organizations_url":"https://api.github.com/users/plamenko/orgs","repos_url":"https://api.github.com/users/plamenko/repos","events_url":"https://api.github.com/users/plamenko/events{/privacy}","received_events_url":"https://api.github.com/users/plamenko/received_events","type":"User","site_admin":false},"created_at":"2015-04-19T13:12:26Z","updated_at":"2015-04-19T13:12:26Z","body":"Hi. No, this is not a proper way of doing it as the source bitmap can be recycled immediately after this method finishes. I'd strongly suggest that you don't deal with CloseableReferences as it is easy to get the things wrong. \r\nOne question to answer first: Do you really have performance problems because the postprocessor makes a copy or is this really a premature optimization?\r\nIf it's the later, then I suggest that you just override `public void process(Bitmap bitmap)` and do `Palette.generate` there. No need for `Palette.generateAsync` as postprocessors run on the background thread anyway.\r\nIf you however do see perf issues, then I'd suggest that you don't use postprocessor at all. Postprocessor is intended for modifying the image (in which case we have to make a copy, otherwise you'd overwrite the source bitmap that is cached and may be used by other clients).\r\nInstead, use the image pipeline directly to get the bitmap and then generate the palette information from it. See http://frescolib.org/docs/using-image-pipeline.html#_ and how to use `BaseBitmapDataSubscriber` in http://frescolib.org/docs/datasources-datasubscribers.html#_.\r\n"}}