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

Change DPI to 96 #1781

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Change DPI to 96 #1781

wants to merge 3 commits into from

Conversation

Ruben2776
Copy link

Fixes #1780

@CLAassistant
Copy link

CLAassistant commented Jan 8, 2025

CLA assistant check
All committers have signed the CLA.

@dlemstra
Copy link
Owner

dlemstra commented Jan 9, 2025

Thanks for creating this PR but I am not sure if this would be the best solution. Maybe we could add an extra ToWriteableBitmapWithDensity method that uses the image.Density and change ToWriteableBitmap to use a density of 96? I can also make these changes myself if you don't want to do this. This should probably also include some tests to check if the dpi on the WriteableBitmap has the correct value. If that is even available in the api.

@Ruben2776
Copy link
Author

Yeah, okay, that sounds good.

@dlemstra
Copy link
Owner

dlemstra commented Jan 9, 2025

Will you be going to make these changes or do you want me to do this?

@Ruben2776
Copy link
Author

I don't know anything about how that dpi test would work. I think it would be better if you did it.

@dlemstra
Copy link
Owner

dlemstra commented Jan 9, 2025

In the unit test you would need to check if the Dpi property of the WriteableBitmap that was created has the correct value.

/// </summary>
/// <param name="self">The image.</param>
/// <typeparam name="TQuantumType">The quantum type.</typeparam>
/// <returns>A <see cref="WriteableBitmap"/>.</returns>
public static unsafe WriteableBitmap ToWriteableBitmap<TQuantumType>(this IMagickImage<TQuantumType> self)
where TQuantumType : struct, IConvertible
{
Copy link
Owner

@dlemstra dlemstra Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would create a private method that has the current implementation and specify either new Vector(96, 96) or new Vector(self.Density.X, self.Density.Y) as an argument to that method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it with ToWriteableBitmapInternal and sending argument between the two.

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

Successfully merging this pull request may close these issues.

Incorrect Size for ToWriteableBitmap Magick.NET.AvaloniaMediaImaging when DPI is not 96
3 participants