{"action":"created","issue":{"url":"https://api.github.com/repos/AvaloniaUI/Avalonia/issues/1889","repository_url":"https://api.github.com/repos/AvaloniaUI/Avalonia","labels_url":"https://api.github.com/repos/AvaloniaUI/Avalonia/issues/1889/labels{/name}","comments_url":"https://api.github.com/repos/AvaloniaUI/Avalonia/issues/1889/comments","events_url":"https://api.github.com/repos/AvaloniaUI/Avalonia/issues/1889/events","html_url":"https://github.com/AvaloniaUI/Avalonia/pull/1889","id":359222115,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0NzY1MjQ2","number":1889,"title":"API Cleanup: Use PixelSize for device-dependent sizes.","user":{"login":"grokys","id":1775141,"node_id":"MDQ6VXNlcjE3NzUxNDE=","avatar_url":"https://avatars1.githubusercontent.com/u/1775141?v=4","gravatar_id":"","url":"https://api.github.com/users/grokys","html_url":"https://github.com/grokys","followers_url":"https://api.github.com/users/grokys/followers","following_url":"https://api.github.com/users/grokys/following{/other_user}","gists_url":"https://api.github.com/users/grokys/gists{/gist_id}","starred_url":"https://api.github.com/users/grokys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grokys/subscriptions","organizations_url":"https://api.github.com/users/grokys/orgs","repos_url":"https://api.github.com/users/grokys/repos","events_url":"https://api.github.com/users/grokys/events{/privacy}","received_events_url":"https://api.github.com/users/grokys/received_events","type":"User","site_admin":true},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-11T21:00:52Z","updated_at":"2018-09-12T21:42:15Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/AvaloniaUI/Avalonia/pulls/1889","html_url":"https://github.com/AvaloniaUI/Avalonia/pull/1889","diff_url":"https://github.com/AvaloniaUI/Avalonia/pull/1889.diff","patch_url":"https://github.com/AvaloniaUI/Avalonia/pull/1889.patch"},"body":"This is something I've been meaning to do for years... Our API was inconsistent about accepting pixel sizes and DPI. For example:\r\n\r\n- `RenderTargetBitmap` accepted a DPI but `WriteableBitmap` didn't\r\n- `IBitmap` didn't expose the DPI so once it was put into `RenderTargetBitmap` it couldn't be read again\r\n- Sometimes DPI was represented by a `Vector` and sometimes by a pair of `double`s\r\n- etc.\r\n\r\nThis PR introduces a new `struct PixelSize` which has an `int` width and height, and also methods for converting to/from a `Size` with a specified DPI (instead of having to do ` size = new Size(width / (dpi / 96, height / (dpi / 96));` which isn't so easy to remember). Hopefully this helps make the distinction between device-independent pixels and device pixels clearer.\r\n\r\nWherever a pixel size is passed to a constructor to create a bitmap, a DPI is also passed as a `Vector`.\r\n\r\nUnfortunately Skia doesn't provide an API for getting an image's DPI, so images loaded there are always 96dpi. Not sure what to do about this. For this reason `Image` still always uses the pixel size as the size to render, rather than the pixel size scaled by DPI."},"comment":{"url":"https://api.github.com/repos/AvaloniaUI/Avalonia/issues/comments/420807768","html_url":"https://github.com/AvaloniaUI/Avalonia/pull/1889#issuecomment-420807768","issue_url":"https://api.github.com/repos/AvaloniaUI/Avalonia/issues/1889","id":420807768,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDgwNzc2OA==","user":{"login":"jkoritzinsky","id":1571408,"node_id":"MDQ6VXNlcjE1NzE0MDg=","avatar_url":"https://avatars2.githubusercontent.com/u/1571408?v=4","gravatar_id":"","url":"https://api.github.com/users/jkoritzinsky","html_url":"https://github.com/jkoritzinsky","followers_url":"https://api.github.com/users/jkoritzinsky/followers","following_url":"https://api.github.com/users/jkoritzinsky/following{/other_user}","gists_url":"https://api.github.com/users/jkoritzinsky/gists{/gist_id}","starred_url":"https://api.github.com/users/jkoritzinsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkoritzinsky/subscriptions","organizations_url":"https://api.github.com/users/jkoritzinsky/orgs","repos_url":"https://api.github.com/users/jkoritzinsky/repos","events_url":"https://api.github.com/users/jkoritzinsky/events{/privacy}","received_events_url":"https://api.github.com/users/jkoritzinsky/received_events","type":"User","site_admin":false},"created_at":"2018-09-12T21:42:15Z","updated_at":"2018-09-12T21:42:15Z","author_association":"MEMBER","body":"Contributes to #1292."}}
{"actor":{"display_login":"jkoritzinsky"}}