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

GR.OPTION_FLIP_Y causes weird pixel spacing in drawimage #527

Closed
jusack opened this issue Oct 10, 2023 · 4 comments
Closed

GR.OPTION_FLIP_Y causes weird pixel spacing in drawimage #527

jusack opened this issue Oct 10, 2023 · 4 comments

Comments

@jusack
Copy link

jusack commented Oct 10, 2023

I encountered a weird bug in JuliaPlots/Plots.jl#4833 which I traced to the yflip parameter. I was able to reproduce it in a MWE using only GR. Do you have any idea, what might be the cause for the observed behavior? I am at version GR v0.72.10 and GR_jll v0.72.10+0

using GR
GR.clearws()
GR.setviewport(0,1,0,1)
GR.setwindow(0,50,0,50)
GR.setscale(GR.OPTION_FLIP_Y) # GR.setscale(0) is fine
GR.drawimage(0,300,300,0,300,300,rand(UInt32,90000))
GR.updatews()
@jheinen
Copy link
Owner

jheinen commented Oct 11, 2023

Could you please explain what the problem is? I tried the following example (with a real image) and could not see any problems:

using GR

w, h, d = readimage("tiger.png")

setviewport(0, 1, 0, 1)
setwindow(0, 50, 0, 50)

setscale(GR.OPTION_FLIP_Y)

drawimage(0, 100, 0, 100, w, h, d)
updatews()

Input image (tiger.png):
tiger

Result:
Screenshot 2023-10-11 at 11 01 08

@jusack
Copy link
Author

jusack commented Oct 11, 2023

I have posted some images of how it looks in the original issue in Plots linked above. This is the result of the pure GR version:
grafik.
In Plots.jl I observed that it depends on the size of the image that is plotted, if I crop the tiger.png to 300x300 (a size that I observed to show the pixel unevenness strongly)
tiger
I can also see the unevenness there: (using your code snippet, shown side by side with MS Paint)
grafik

jheinen pushed a commit to sciapp/gr that referenced this issue Oct 11, 2023
@IngoMeyer441
Copy link
Contributor

IngoMeyer441 commented Oct 11, 2023

@jusack Thanks for pointing us to this bug. We fixed the non-square pixels in C-GR commit b9aefa6, so (currently) you will need to use the latest GR runtime to get the fix.

@jusack
Copy link
Author

jusack commented Oct 12, 2023

Awesome, thanks for the quick fix!

@jusack jusack closed this as completed Oct 12, 2023
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