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

With version 7, the WMS image gets blurry in many cases #14718

Closed
sbrunner opened this issue May 2, 2023 · 6 comments · Fixed by #14719
Closed

With version 7, the WMS image gets blurry in many cases #14718

sbrunner opened this issue May 2, 2023 · 6 comments · Fixed by #14719
Labels

Comments

@sbrunner
Copy link
Member

sbrunner commented May 2, 2023

Describe the bug
If the ratio is not a round int, or map width or map height is not even, the image is blurry...

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://sbrunner.github.io/ngeo/ol7b.html'
  2. See that the map is a little blurry

Expected behavior
The map is pixel perfect

@sbrunner sbrunner added the bug label May 2, 2023
@mike-000
Copy link
Contributor

mike-000 commented May 2, 2023

The image will be drawn at a fractional pixel position on the layer canvas, so some blurring is to be expected unless interpolation is disabled (which would have the same effect as offsetting the drawn image to an integer pixel position - pixel perfect but in slightly wrong position).

@sbrunner
Copy link
Member Author

sbrunner commented May 2, 2023

I understand that, but why don't create a WMS query do not have fractional pixel (I hope that a pull request will be accepted :-) )

@mike-000
Copy link
Contributor

mike-000 commented May 2, 2023

I think it is the calculation of the size that is at fault, it should be an integer value greater than the view size on both sides

e.g instead of

const requestWidth = ceil(
  (this.ratio_ * getWidth(extent)) / imageResolution,
  DECIMALS
);

use

let requestWidth = ceil(
  getWidth(extent) / imageResolution,
  DECIMALS
);
requestWidth += 2 * ceil(
  ((this.ratio_ - 1) * requestWidth) / 2,
  DECIMALS
);

and similarly for requestHeight.
That would also apply to other subclasses of ImageSource which have a ratio option.

@sbrunner
Copy link
Member Author

sbrunner commented May 2, 2023

Looks good, thanks, I will try with it :-)

@mike-000
Copy link
Contributor

mike-000 commented May 2, 2023

There could still be a problem if the map center is changed, but no image update is needed if it does not exceed the margin. If it moves a fraction of a pixel the output would blur again. I think a user drag is always a whole pixel, but a programmatic change or change of map size could do it, as can be seen with ImageCanvas where bright red and green pixels are blurred into dull yellow https://codesandbox.io/s/simple-forked-0g8ckv?file=/main.js

@sbrunner
Copy link
Member Author

sbrunner commented May 3, 2023

Effectively, but I don't think that we want to automatically query again the layer in this case...

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

Successfully merging a pull request may close this issue.

2 participants