{"action":"created","issue":{"url":"https://api.github.com/repos/flutter/flutter/issues/16635","repository_url":"https://api.github.com/repos/flutter/flutter","labels_url":"https://api.github.com/repos/flutter/flutter/issues/16635/labels{/name}","comments_url":"https://api.github.com/repos/flutter/flutter/issues/16635/comments","events_url":"https://api.github.com/repos/flutter/flutter/issues/16635/events","html_url":"https://github.com/flutter/flutter/issues/16635","id":314805902,"number":16635,"title":"Support different encodings in Image.toByteData()","user":{"login":"tvolkert","id":15253456,"avatar_url":"https://avatars0.githubusercontent.com/u/15253456?v=4","gravatar_id":"","url":"https://api.github.com/users/tvolkert","html_url":"https://github.com/tvolkert","followers_url":"https://api.github.com/users/tvolkert/followers","following_url":"https://api.github.com/users/tvolkert/following{/other_user}","gists_url":"https://api.github.com/users/tvolkert/gists{/gist_id}","starred_url":"https://api.github.com/users/tvolkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvolkert/subscriptions","organizations_url":"https://api.github.com/users/tvolkert/orgs","repos_url":"https://api.github.com/users/tvolkert/repos","events_url":"https://api.github.com/users/tvolkert/events{/privacy}","received_events_url":"https://api.github.com/users/tvolkert/received_events","type":"User","site_admin":false},"labels":[{"id":284438921,"url":"https://api.github.com/repos/flutter/flutter/labels/prod:%20engine","name":"prod: engine","color":"003570","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-16T20:28:29Z","updated_at":"2018-04-16T20:28:55Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Use case A: raw bytes in their native form\r\n\r\n`Image.toByteData()` currently returns the raw image bytes in RGBA form.  For images that are encoded in a different native format (e.g. grayscale), this means we go through a potentially expensive and wasteful conversion to RGBA.\r\n\r\n### Use case B: encoded bytes (PNG)\r\n\r\nFurther, there's a chance we could support PNG encoding and tree-shake Skia's support for the other encoders (jpeg, gif, webp, etc.), thus avoiding significant binary size bloat that would otherwise come with taking on the dependency on image encoding (for history, flutter/engine#4762 added `Image.toByteData()` with encoding support, but the encoding support was removed due to https://github.com/flutter/flutter/issues/16537).\r\n\r\n### Proposal\r\n\r\nWe could satisfy both these uses with the following API:\r\n\r\n```dart\r\nenum ImageEncodingFormat {\r\n  /// Unencoded bytes, in RGBA form (kRGBA_8888_SkColorType)\r\n  rawRgba,\r\n\r\n  /// Unencoded bytes, in whatever form they exist within the image\r\n  /// (e.g. kGray_8_SkColorType)\r\n  rawNative,\r\n\r\n   /// PNG encoding\r\n  png,\r\n}\r\n\r\nclass Image {\r\n  Future<ByteData> toByteData({ImageEncodingFormat format: ImageEncodingFormat.rawRgba})\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/flutter/flutter/issues/comments/381738492","html_url":"https://github.com/flutter/flutter/issues/16635#issuecomment-381738492","issue_url":"https://api.github.com/repos/flutter/flutter/issues/16635","id":381738492,"user":{"login":"tvolkert","id":15253456,"avatar_url":"https://avatars0.githubusercontent.com/u/15253456?v=4","gravatar_id":"","url":"https://api.github.com/users/tvolkert","html_url":"https://github.com/tvolkert","followers_url":"https://api.github.com/users/tvolkert/followers","following_url":"https://api.github.com/users/tvolkert/following{/other_user}","gists_url":"https://api.github.com/users/tvolkert/gists{/gist_id}","starred_url":"https://api.github.com/users/tvolkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvolkert/subscriptions","organizations_url":"https://api.github.com/users/tvolkert/orgs","repos_url":"https://api.github.com/users/tvolkert/repos","events_url":"https://api.github.com/users/tvolkert/events{/privacy}","received_events_url":"https://api.github.com/users/tvolkert/received_events","type":"User","site_admin":false},"created_at":"2018-04-16T20:28:54Z","updated_at":"2018-04-16T20:28:54Z","author_association":"CONTRIBUTOR","body":"/cc @majido @fmorgado @chinmaygarde "}}
{"actor":{"display_login":"tvolkert"}}