简体   繁体   中英

What is PixelOffsetMode?

MSDN doesn't explain it for someone who doesn't already know what it is. I've searched, but only found that it sets the quality of rendering. But in what way? What, for example, does

Specifies that pixels are offset by -.5 units, both horizontally and vertically, for high speed antialiasing. ( MSDN )

mean?

During painting you're using double values to present your logical graphic objects, for example lines, circles, etc.

But during rendering, framework should convert your logical doubles into physical integer pixels.

During this process framework uses some kind of rounding, smoothing ( anti-aliasing )

So, during anti-aliasing you can have different algorithms which will provide different results; Usually all they need to calculate "distance" between logical pixel and its physical coordinates, so different modes of this setting affects precision of this distance.

Here is nice example of different modes (basically different shades of gray - different distance):

在此处输入图片说明

NOTE: .net framework also has setting for actual smoothing ( SmoothingMode ) which basically means - how we smooth, not how we calculate distance internally

When rendering images, PixelOffsetMode specifies where the respective center points of the pixels end up:

  • PixelOffsetMode.Half means coordinate (0.5, 0.5) aligns with the middle (=half) of the top left pixel, or to put it more clearly: (0, 0) is the top left of the top left pixel.
  • PixelOffsetMode.None means coordinate (0.5, 0.5) aligns with the top left corner of the top left pixel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM