{"action":"created","comment":{"url":"https://api.github.com/repos/harukasan/go-libwebp/pulls/comments/67348715","id":67348715,"diff_hunk":"@@ -0,0 +1,80 @@\n+// Package rgb provides RGB image which implements image.Image interface.\n+package webp\n+\n+import (\n+\t\"image\"\n+\t\"image/color\"\n+)\n+\n+// Image represent image data which has RGB colors.\n+// Image is compatible with image.RGBA, but does not have alpha channel to reduce using memory.\n+type RGBImage struct {\n+\t// Pix holds the image's stream, in R, G, B order.\n+\tPix []uint8\n+\t// Stride is the Pix stride (in bytes) between vertically adjacent pixels.\n+\tStride int\n+\t// Rect is the image's bounds.\n+\tRect image.Rectangle\n+}\n+\n+// NewRGBImage allocates and returns RGB image\n+func NewRGBImage(r image.Rectangle) *RGBImage {\n+\tw, h := r.Dx(), r.Dy()\n+\treturn &RGBImage{Pix: make([]uint8, 3*w*h), Stride: 3 * w, Rect: r}\n+}\n+\n+// ColorModel returns RGB color model.\n+func (p *RGBImage) ColorModel() color.Model {\n+\treturn RGBModel\n+}\n+\n+// Bounds implements image.Image.At\n+func (p *RGBImage) Bounds() image.Rectangle {\n+\treturn p.Rect\n+}\n+\n+// At implements image.Image.At\n+func (p *RGBImage) At(x, y int) color.Color {\n+\treturn p.RGBAAt(x, y)\n+}\n+\n+// RGBAAt returns the color of the pixel at (x, y) as RGBA.\n+func (p *RGBImage) RGBAAt(x, y int) color.RGBA {\n+\tif !(image.Point{x, y}.In(p.Rect)) {\n+\t\treturn color.RGBA{}\n+\t}\n+\ti := (y-p.Rect.Min.Y)*p.Stride + (x-p.Rect.Min.X)*3\n+\treturn color.RGBA{p.Pix[i+0], p.Pix[i+1], p.Pix[i+2], 0xFF}\n+}\n+\n+// ColorModel is RGB color model instance\n+var RGBModel = color.ModelFunc(rgbModel)\n+\n+func rgbModel(c color.Color) color.Color {\n+\tif _, ok := c.(RGB); ok {\n+\t\treturn c\n+\t}\n+\tr, g, b, _ := c.RGBA()\n+\treturn RGB{uint8(r >> 8), uint8(g >> 8), uint8(b >> 8)}\n+}\n+\n+// RGB color\n+type RGB struct {\n+\tR, G, B uint8\n+}\n+\n+// RGBA implements Color.RGBA\n+func (c RGB) RGBA() (r, g, b, a uint32) {\n+\tr = uint32(c.R)\n+\tr |= r << 8\n+\tg = uint32(c.G)\n+\tg |= g << 8\n+\tb = uint32(c.B)\n+\tb |= b << 8\n+\ta = uint32(0xFFFF)\n+\treturn\n+}\n+\n+// Make sure Image implements image.Image.","path":"webp/rgb_image.go","position":78,"original_position":78,"commit_id":"462078c647f86dc3a1bf5f440edd796beb4fb5d5","original_commit_id":"462078c647f86dc3a1bf5f440edd796beb4fb5d5","user":{"login":"harukasan","id":44918,"avatar_url":"https://avatars.githubusercontent.com/u/44918?v=3","gravatar_id":"","url":"https://api.github.com/users/harukasan","html_url":"https://github.com/harukasan","followers_url":"https://api.github.com/users/harukasan/followers","following_url":"https://api.github.com/users/harukasan/following{/other_user}","gists_url":"https://api.github.com/users/harukasan/gists{/gist_id}","starred_url":"https://api.github.com/users/harukasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harukasan/subscriptions","organizations_url":"https://api.github.com/users/harukasan/orgs","repos_url":"https://api.github.com/users/harukasan/repos","events_url":"https://api.github.com/users/harukasan/events{/privacy}","received_events_url":"https://api.github.com/users/harukasan/received_events","type":"User","site_admin":false},"body":"s/Image/RGBImage/","created_at":"2016-06-16T13:58:42Z","updated_at":"2016-06-16T13:58:42Z","html_url":"https://github.com/harukasan/go-libwebp/pull/8#discussion_r67348715","pull_request_url":"https://api.github.com/repos/harukasan/go-libwebp/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/harukasan/go-libwebp/pulls/comments/67348715"},"html":{"href":"https://github.com/harukasan/go-libwebp/pull/8#discussion_r67348715"},"pull_request":{"href":"https://api.github.com/repos/harukasan/go-libwebp/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/harukasan/go-libwebp/pulls/8","id":73155378,"html_url":"https://github.com/harukasan/go-libwebp/pull/8","diff_url":"https://github.com/harukasan/go-libwebp/pull/8.diff","patch_url":"https://github.com/harukasan/go-libwebp/pull/8.patch","issue_url":"https://api.github.com/repos/harukasan/go-libwebp/issues/8","number":8,"state":"open","locked":false,"title":"Add RGB encoder","user":{"login":"saturday06","id":532872,"avatar_url":"https://avatars.githubusercontent.com/u/532872?v=3","gravatar_id":"","url":"https://api.github.com/users/saturday06","html_url":"https://github.com/saturday06","followers_url":"https://api.github.com/users/saturday06/followers","following_url":"https://api.github.com/users/saturday06/following{/other_user}","gists_url":"https://api.github.com/users/saturday06/gists{/gist_id}","starred_url":"https://api.github.com/users/saturday06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saturday06/subscriptions","organizations_url":"https://api.github.com/users/saturday06/orgs","repos_url":"https://api.github.com/users/saturday06/repos","events_url":"https://api.github.com/users/saturday06/events{/privacy}","received_events_url":"https://api.github.com/users/saturday06/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-09T04:16:31Z","updated_at":"2016-06-16T13:58:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d0b55f43c34f3d91b7e71368eecf52ea2224365","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/harukasan/go-libwebp/pulls/8/commits","review_comments_url":"https://api.github.com/repos/harukasan/go-libwebp/pulls/8/comments","review_comment_url":"https://api.github.com/repos/harukasan/go-libwebp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/harukasan/go-libwebp/issues/8/comments","statuses_url":"https://api.github.com/repos/harukasan/go-libwebp/statuses/462078c647f86dc3a1bf5f440edd796beb4fb5d5","head":{"label":"saturday06:feature/rgb_encode","ref":"feature/rgb_encode","sha":"462078c647f86dc3a1bf5f440edd796beb4fb5d5","user":{"login":"saturday06","id":532872,"avatar_url":"https://avatars.githubusercontent.com/u/532872?v=3","gravatar_id":"","url":"https://api.github.com/users/saturday06","html_url":"https://github.com/saturday06","followers_url":"https://api.github.com/users/saturday06/followers","following_url":"https://api.github.com/users/saturday06/following{/other_user}","gists_url":"https://api.github.com/users/saturday06/gists{/gist_id}","starred_url":"https://api.github.com/users/saturday06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saturday06/subscriptions","organizations_url":"https://api.github.com/users/saturday06/orgs","repos_url":"https://api.github.com/users/saturday06/repos","events_url":"https://api.github.com/users/saturday06/events{/privacy}","received_events_url":"https://api.github.com/users/saturday06/received_events","type":"User","site_admin":false},"repo":{"id":50404735,"name":"go-libwebp","full_name":"saturday06/go-libwebp","owner":{"login":"saturday06","id":532872,"avatar_url":"https://avatars.githubusercontent.com/u/532872?v=3","gravatar_id":"","url":"https://api.github.com/users/saturday06","html_url":"https://github.com/saturday06","followers_url":"https://api.github.com/users/saturday06/followers","following_url":"https://api.github.com/users/saturday06/following{/other_user}","gists_url":"https://api.github.com/users/saturday06/gists{/gist_id}","starred_url":"https://api.github.com/users/saturday06/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saturday06/subscriptions","organizations_url":"https://api.github.com/users/saturday06/orgs","repos_url":"https://api.github.com/users/saturday06/repos","events_url":"https://api.github.com/users/saturday06/events{/privacy}","received_events_url":"https://api.github.com/users/saturday06/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/saturday06/go-libwebp","description":"An implemantaion of Go bindings for libwebp.","fork":true,"url":"https://api.github.com/repos/saturday06/go-libwebp","forks_url":"https://api.github.com/repos/saturday06/go-libwebp/forks","keys_url":"https://api.github.com/repos/saturday06/go-libwebp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saturday06/go-libwebp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saturday06/go-libwebp/teams","hooks_url":"https://api.github.com/repos/saturday06/go-libwebp/hooks","issue_events_url":"https://api.github.com/repos/saturday06/go-libwebp/issues/events{/number}","events_url":"https://api.github.com/repos/saturday06/go-libwebp/events","assignees_url":"https://api.github.com/repos/saturday06/go-libwebp/assignees{/user}","branches_url":"https://api.github.com/repos/saturday06/go-libwebp/branches{/branch}","tags_url":"https://api.github.com/repos/saturday06/go-libwebp/tags","blobs_url":"https://api.github.com/repos/saturday06/go-libwebp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saturday06/go-libwebp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saturday06/go-libwebp/git/refs{/sha}","trees_url":"https://api.github.com/repos/saturday06/go-libwebp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saturday06/go-libwebp/statuses/{sha}","languages_url":"https://api.github.com/repos/saturday06/go-libwebp/languages","stargazers_url":"https://api.github.com/repos/saturday06/go-libwebp/stargazers","contributors_url":"https://api.github.com/repos/saturday06/go-libwebp/contributors","subscribers_url":"https://api.github.com/repos/saturday06/go-libwebp/subscribers","subscription_url":"https://api.github.com/repos/saturday06/go-libwebp/subscription","commits_url":"https://api.github.com/repos/saturday06/go-libwebp/commits{/sha}","git_commits_url":"https://api.github.com/repos/saturday06/go-libwebp/git/commits{/sha}","comments_url":"https://api.github.com/repos/saturday06/go-libwebp/comments{/number}","issue_comment_url":"https://api.github.com/repos/saturday06/go-libwebp/issues/comments{/number}","contents_url":"https://api.github.com/repos/saturday06/go-libwebp/contents/{+path}","compare_url":"https://api.github.com/repos/saturday06/go-libwebp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saturday06/go-libwebp/merges","archive_url":"https://api.github.com/repos/saturday06/go-libwebp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saturday06/go-libwebp/downloads","issues_url":"https://api.github.com/repos/saturday06/go-libwebp/issues{/number}","pulls_url":"https://api.github.com/repos/saturday06/go-libwebp/pulls{/number}","milestones_url":"https://api.github.com/repos/saturday06/go-libwebp/milestones{/number}","notifications_url":"https://api.github.com/repos/saturday06/go-libwebp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saturday06/go-libwebp/labels{/name}","releases_url":"https://api.github.com/repos/saturday06/go-libwebp/releases{/id}","deployments_url":"https://api.github.com/repos/saturday06/go-libwebp/deployments","created_at":"2016-01-26T05:05:42Z","updated_at":"2016-01-26T05:05:43Z","pushed_at":"2016-06-16T07:14:43Z","git_url":"git://github.com/saturday06/go-libwebp.git","ssh_url":"git@github.com:saturday06/go-libwebp.git","clone_url":"https://github.com/saturday06/go-libwebp.git","svn_url":"https://github.com/saturday06/go-libwebp","homepage":"","size":3697,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"harukasan:master","ref":"master","sha":"10d006dab5599bfc6da8bdf8e4f502bdbf99bc89","user":{"login":"harukasan","id":44918,"avatar_url":"https://avatars.githubusercontent.com/u/44918?v=3","gravatar_id":"","url":"https://api.github.com/users/harukasan","html_url":"https://github.com/harukasan","followers_url":"https://api.github.com/users/harukasan/followers","following_url":"https://api.github.com/users/harukasan/following{/other_user}","gists_url":"https://api.github.com/users/harukasan/gists{/gist_id}","starred_url":"https://api.github.com/users/harukasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harukasan/subscriptions","organizations_url":"https://api.github.com/users/harukasan/orgs","repos_url":"https://api.github.com/users/harukasan/repos","events_url":"https://api.github.com/users/harukasan/events{/privacy}","received_events_url":"https://api.github.com/users/harukasan/received_events","type":"User","site_admin":false},"repo":{"id":28999571,"name":"go-libwebp","full_name":"harukasan/go-libwebp","owner":{"login":"harukasan","id":44918,"avatar_url":"https://avatars.githubusercontent.com/u/44918?v=3","gravatar_id":"","url":"https://api.github.com/users/harukasan","html_url":"https://github.com/harukasan","followers_url":"https://api.github.com/users/harukasan/followers","following_url":"https://api.github.com/users/harukasan/following{/other_user}","gists_url":"https://api.github.com/users/harukasan/gists{/gist_id}","starred_url":"https://api.github.com/users/harukasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harukasan/subscriptions","organizations_url":"https://api.github.com/users/harukasan/orgs","repos_url":"https://api.github.com/users/harukasan/repos","events_url":"https://api.github.com/users/harukasan/events{/privacy}","received_events_url":"https://api.github.com/users/harukasan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/harukasan/go-libwebp","description":"An implemantaion of Go bindings for libwebp.","fork":false,"url":"https://api.github.com/repos/harukasan/go-libwebp","forks_url":"https://api.github.com/repos/harukasan/go-libwebp/forks","keys_url":"https://api.github.com/repos/harukasan/go-libwebp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/harukasan/go-libwebp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/harukasan/go-libwebp/teams","hooks_url":"https://api.github.com/repos/harukasan/go-libwebp/hooks","issue_events_url":"https://api.github.com/repos/harukasan/go-libwebp/issues/events{/number}","events_url":"https://api.github.com/repos/harukasan/go-libwebp/events","assignees_url":"https://api.github.com/repos/harukasan/go-libwebp/assignees{/user}","branches_url":"https://api.github.com/repos/harukasan/go-libwebp/branches{/branch}","tags_url":"https://api.github.com/repos/harukasan/go-libwebp/tags","blobs_url":"https://api.github.com/repos/harukasan/go-libwebp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/harukasan/go-libwebp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/harukasan/go-libwebp/git/refs{/sha}","trees_url":"https://api.github.com/repos/harukasan/go-libwebp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/harukasan/go-libwebp/statuses/{sha}","languages_url":"https://api.github.com/repos/harukasan/go-libwebp/languages","stargazers_url":"https://api.github.com/repos/harukasan/go-libwebp/stargazers","contributors_url":"https://api.github.com/repos/harukasan/go-libwebp/contributors","subscribers_url":"https://api.github.com/repos/harukasan/go-libwebp/subscribers","subscription_url":"https://api.github.com/repos/harukasan/go-libwebp/subscription","commits_url":"https://api.github.com/repos/harukasan/go-libwebp/commits{/sha}","git_commits_url":"https://api.github.com/repos/harukasan/go-libwebp/git/commits{/sha}","comments_url":"https://api.github.com/repos/harukasan/go-libwebp/comments{/number}","issue_comment_url":"https://api.github.com/repos/harukasan/go-libwebp/issues/comments{/number}","contents_url":"https://api.github.com/repos/harukasan/go-libwebp/contents/{+path}","compare_url":"https://api.github.com/repos/harukasan/go-libwebp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/harukasan/go-libwebp/merges","archive_url":"https://api.github.com/repos/harukasan/go-libwebp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/harukasan/go-libwebp/downloads","issues_url":"https://api.github.com/repos/harukasan/go-libwebp/issues{/number}","pulls_url":"https://api.github.com/repos/harukasan/go-libwebp/pulls{/number}","milestones_url":"https://api.github.com/repos/harukasan/go-libwebp/milestones{/number}","notifications_url":"https://api.github.com/repos/harukasan/go-libwebp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/harukasan/go-libwebp/labels{/name}","releases_url":"https://api.github.com/repos/harukasan/go-libwebp/releases{/id}","deployments_url":"https://api.github.com/repos/harukasan/go-libwebp/deployments","created_at":"2015-01-09T03:51:51Z","updated_at":"2016-02-26T07:23:18Z","pushed_at":"2016-06-16T07:14:44Z","git_url":"git://github.com/harukasan/go-libwebp.git","ssh_url":"git@github.com:harukasan/go-libwebp.git","clone_url":"https://github.com/harukasan/go-libwebp.git","svn_url":"https://github.com/harukasan/go-libwebp","homepage":"","size":3696,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/harukasan/go-libwebp/pulls/8"},"html":{"href":"https://github.com/harukasan/go-libwebp/pull/8"},"issue":{"href":"https://api.github.com/repos/harukasan/go-libwebp/issues/8"},"comments":{"href":"https://api.github.com/repos/harukasan/go-libwebp/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/harukasan/go-libwebp/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/harukasan/go-libwebp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/harukasan/go-libwebp/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/harukasan/go-libwebp/statuses/462078c647f86dc3a1bf5f440edd796beb4fb5d5"}}}}
{"actor":{"display_login":"harukasan"}}