Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawing lines and rectangles #107

Open
FraserElectronics opened this issue Feb 6, 2023 · 8 comments
Open

Drawing lines and rectangles #107

FraserElectronics opened this issue Feb 6, 2023 · 8 comments

Comments

@FraserElectronics
Copy link

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

@drewnoakes
Copy link
Collaborator

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

@FraserElectronics
Copy link
Author

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

Andy

@jingwood
Copy link
Owner

jingwood commented Feb 8, 2023

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

@FraserElectronics
Copy link
Author

@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
Copy link
Author

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

@jingwood
Copy link
Owner

jingwood commented Feb 8, 2023

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?

@FraserElectronics
Copy link
Author

Do you mean something like this?

6

Andy

@FraserElectronics
Copy link
Author

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

7

Andy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants