3 ms·
I once made a persuasive argument that this was the proper interpretation of a pixel, and got a major app to adopt the convention. It wasn't until much later t
by mark-r 6y ago
I once made a persuasive argument that this was the proper interpretation of a pixel, and got a major app to adopt the convention. It wasn't until much later that I discovered the error.
The problem comes when you try to align raster images with vector ones. Instead of starting a line at 0,0 you need to start it at 0.5,0.5. And heaven help you if you're combining raster images at different resolutions, they'll never line up.
The proper way to work is to put the pixel center at 0,0 and let it extend from -0.5 to 0.5. This works out well with reconstruction or resizing filters, because they're symmetric around 0,0 too.
- codeflo 6y agoPixel centers at (0.5, 0.5) is the convention adopted by all major graphics APIs (OpenGL, DirectX, Vulkan, Metal). That’s because it makes the math, especially around image scaling, becomes a lot simpler. What exactly the alignment problem you say isn’t solvable? One common mistake is to not think in floating point coordinates all the way through. E.g. a rectangle that covers a single pixel should have coordinates like (100.0,100.0)-(101.0,101.0), NOT involving a 0.5 offset. You almost never offset anything by 0.5 in this convention. 1 pixel wide lines are an exception, but only because then the edges of the line are exactly at pixel boundaries.