drawing - How can I create beveled corners on a border in WPF? -


i'm trying simple drawing in subclass of decorator, similar they're doing here...

how can draw border squared corners in wpf?

...except single-pixel border thickness instead of 2 they're using there. however, no matter do, wpf decides needs 'smoothing' (e.g. instead of rendering single-pixel line, renders two-pixel line each 'half' 50% of opacity.) in other words, it's trying anti-alias drawing. not want anti-aliased drawing. want if draw line 0,0 10,0 single-pixel-wide line that's 10 pixels long without smoothing.

now know wpf that, thought that's why introduced snapstodevicepixels , uselayoutrounding, both of i've set 'true' in xaml. i'm making sure numbers i'm using actual integers , not fractional numbers, still i'm not getting nice, crisp, one-pixel-wide lines i'm hoping for.

help!!!

mark

have @ article: draw lines on physical device pixels

upd

some valuable quotes link:

the reason why lines appear blurry, our points center points of lines not edges. pen width of 1 edges drawn excactly between 2 pixels.

a first approach round each point integer value (snap logical pixel) give offset of half pen width. ensures, edges of line align logical pixels.

fortunately developers of milcore (mil stands media integration layer, that's wpfs rendering engine) give way guide rendering engine align logical coordinate excatly on physical device pixels. achieve this, need create guidelineset

protected override void onrender(drawingcontext drawingcontext) {     pen pen = new pen(brushes.black, 1);     rect rect = new rect(20,20, 50, 60);      double halfpenwidth = pen.thickness / 2;      // create guidelines set     guidelineset guidelines = new guidelineset();     guidelines.guidelinesx.add(rect.left + halfpenwidth);     guidelines.guidelinesx.add(rect.right + halfpenwidth);     guidelines.guidelinesy.add(rect.top + halfpenwidth);     guidelines.guidelinesy.add(rect.bottom + halfpenwidth);      drawingcontext.pushguidelineset(guidelines);     drawingcontext.drawrectangle(null, pen, rect);     drawingcontext.pop(); } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -