d2dlib icon indicating copy to clipboard operation
d2dlib copied to clipboard

Drawing lines and rectangles

Open FraserElectronics opened this issue 2 years ago • 8 comments

I would like to draw a one pixel width rectangle on my D2DControl surface using DrawRectangle with the default stroke width of 1. However, the rectangle is two pixels wide on my monitor and seems to be a blend of the foreground and background colours.

5

The line should be Red i.e. R:255,G:0,B:0 but you can see it is not. Two questions:

  1. How to I get a single pixel line (is this related to DPI as per my previous issues)?
  2. How to not blend the pen colour with the background colour?

Andy

FraserElectronics avatar Feb 06 '23 22:02 FraserElectronics

This Stack Overflow question might be helpful: https://stackoverflow.com/questions/10763762/pixels-in-direct2d

drewnoakes avatar Feb 08 '23 09:02 drewnoakes

Yes, I suspected that this might be the case - thanks for the link 👍

Andy

FraserElectronics avatar Feb 08 '23 11:02 FraserElectronics

There are two issues in this case.

First, you have to configure your .NET application to allow the high DPI support accoding to this document.

Second, the current D2DControl can't calculate and set a correct DPI value for high DPI supported .NET application (a bug from d2dlib).

You can add a normal .NET control on your winform, and compare the rendering quality between normal .NET control and d2dlib as below. high-dpi-support-winform

jingwood avatar Feb 08 '23 14:02 jingwood

@jingwood Are you saying that even if I configure my application to support high DPI I will still have a problem because of a bug in d2dlib?

Andy

FraserElectronics avatar Feb 08 '23 14:02 FraserElectronics

Actually, I can answer that as I have followed the steps you link and it has made no change to the rendering on the D2DControl :-(

Andy

FraserElectronics avatar Feb 08 '23 14:02 FraserElectronics

Are you saying that even if I configure my application to support high DPI I will still have a problem because of a bug in d2dlib?

Yes, but it's another problem.

For the antialias, could you please post an image that shows how the normal .NET control is rendered like my above?

jingwood avatar Feb 08 '23 15:02 jingwood

Do you mean something like this?

6

Andy

FraserElectronics avatar Feb 08 '23 15:02 FraserElectronics

This is what it looks like if I remove all the suggestions from the link you mentioned.

7

Andy

FraserElectronics avatar Feb 08 '23 15:02 FraserElectronics