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

Issues when testing the drop-in replacement for the fortran pgplot library #48

Closed
xspector opened this issue Jan 5, 2024 · 3 comments · Fixed by #64 or #65
Closed

Issues when testing the drop-in replacement for the fortran pgplot library #48

xspector opened this issue Jan 5, 2024 · 3 comments · Fixed by #64 or #65

Comments

@xspector
Copy link

xspector commented Jan 5, 2024

I am investigating using giza as a drop-in replacement for pgplot in a large NASA software package (https://heasarc.gsfc.nasa.gov/docs/software/lheasoft/). I have run into three issues. Two of these I have solutions for, the third is more difficult.

  1. Center or right justified text are not plotted correctly. The problem here is the usual one of spaces at the end of the string not being handled correctly when going from Fortran to C. A simple fix is in giza-pgplot.f90 to replace call giza_ptext(X, Y, ANGLE, FJUST, TEXT) with call giza_ptext(X, Y, ANGLE, FJUST, TEXT(:LEN_TRIM(TEXT))).
  2. The giza version of PGDRAW does not update the current pen position. A simple fix in giza-pgplot.f90 is to add a call of PGMOVE immediately after the call to giza-draw. However, it might be better to fix the problem within giza-draw.
  3. Images are blurred. If I make eg a 10 pixel by 10 pixel image then the sharp edges between pixels are blurred out. I assume that this is something do with a cairo setting but I have been unable to find out how to turn it off. See example:
    xspector-issue-3.pdf
@danieljprice
Copy link
Owner

sorry for the slow reply here. Issues 1 and 2 now fixed by #64, please check if this works from your end

Issue 3 is more tricky, here a 10x10 pixel image has been interpolated to a larger pixel grid, by default this would be handled inside Cairo with a bilinear interpolation or similar, hence the blurring. So we'd need an additional setting to switch off the image interpolation and just plot 10 x 10 large pixels (i.e. tophat interpolation)

@danieljprice danieljprice reopened this Dec 5, 2024
danieljprice added a commit that referenced this issue Dec 5, 2024
… set the image interpolation algorithm; bump version to 1.5.0 due to incompatible interface
@danieljprice
Copy link
Owner

danieljprice commented Dec 5, 2024

also now fixed issue 3, as this requires a backwards-incompatible change to the giza_render interface, have bumped version number to 1.5.0

Now, an extra argument "filter" is passed to the giza_render routines. When called from the PGPLOT interface the filter is set to GIZA_FILTER_NEAREST, which uses nearest neighbour interpolation, giving the desired behaviour.

@danieljprice danieljprice linked a pull request Dec 5, 2024 that will close this issue
danieljprice added a commit that referenced this issue Dec 6, 2024
fix image blurring issue in PGPLOT interface #48
@xspector
Copy link
Author

Thank you for your response. I can confirm that my first and third issues are fixed by your changes. The second issue is not fixed however it is fixed if I move the call of cairo_move_to after the call of _giza_stroke in giza-draw.c.

I have a couple of other problems I am working on at the moment but I will open these as a new issue when I have them better defined.

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