Author Topic: Rendering issues with SVG files  (Read 5127 times)

Offline rga218

  • Newcomer
  • Posts: 37
Rendering issues with SVG files
« on: 2013 December 28 20:39:48 »
Hi, I'm writing a PCL module to generate Photometric Superflats and am using PixInsight's built-in gnuplot executable to produce diagnostic plots for the user. These plots are produced as SVG files which are then displayed within PixInsight. However, I'm seeing some rendering issues with the SVG files. Here are two plots that illustrate the issues I've encountered. The first is a coloured image map:

https://dl.dropboxusercontent.com/u/110230258/graphics1.svg

This looks fine when viewed with a web browser (I tried it in Chrome, Firefox and Safari) but it shows strong patchwork aliasing when opened with PI. The next example is an X-Y graph that shows points in red (as intended) when viewed with a web browser, but which renders the points in black when opened with PI:

https://dl.dropboxusercontent.com/u/110230258/graphics2.svg

Am I doing something incorrect when generating SVG graphics for display within PixInsight?

Thank you,

Bob

P.S. In case it's relevant, I'm using PI 1.8 (Ripley) on a Mac OS X machine running v. 10.9 (Mavericks).

Roberto Abraham
Professor of Astronomy & Astrophysics
University of Toronto

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Rendering issues with SVG files
« Reply #1 on: 2014 January 01 09:54:12 »
Hi Bob,

I confirm these problems. PixInsight's SVG rendering engine is based on QtSvg. While QtSvg works reasonably well in most cases, it has some issues and limitations, which you're facing now.

Unfortunately, there's no workaround to these problems. You could render the SVG file as a Bitmap created with much larger dimensions than the original drawing, then downsample it to the actual size:

Bitmap b( 800*6, 600*6 );
b.Load( "/path/to/file.svg" );
b = b.ScaledToSize( 800, 600 );


This will reduce the "patchwork" problem, but won't eliminate it completely.

The only solution is replacing the current SVG engine with something much better. I plan on integrating Cairo as a new vector drawing backend in PixInsight, but this is a complex and time-consuming task that won't happen in the short term. As a starting point, I'll try to rewrite Bitmap::Load() using Cairo for the SVG format. This should be relatively easy, and will fix all of these problems. Sorry for not being able to offer a better solution.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline rga218

  • Newcomer
  • Posts: 37
Re: Rendering issues with SVG files
« Reply #2 on: 2014 January 02 08:00:59 »
Thanks Juan - I'll implement the suggested resizing + downsampling as a temporary fix for now.

Regards,

Bob
Roberto Abraham
Professor of Astronomy & Astrophysics
University of Toronto

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Rendering issues with SVG files
« Reply #3 on: 2014 January 08 09:43:41 »
Hi Bob,

All SVG rendering problems are now fixed in build 1073 of the PixInsight Core application, which I'll release in a few days for all platforms. See for example:


I have replaced the old SVG renderer based on QtSvg with a new one that uses WebKit. With this new engine we have improved PixInsight's SVG support by orders of magnitude.

Thank you for pointing out what was an important weakness of the PixInsight platform.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline rga218

  • Newcomer
  • Posts: 37
Re: Rendering issues with SVG files
« Reply #4 on: 2014 January 21 17:22:21 »
Juan - I need to start looking at the forum daily instead of every couple of weeks - I just noticed you implemented this bug fix now. THANK YOU!!! This is really terrific!

Bob
Roberto Abraham
Professor of Astronomy & Astrophysics
University of Toronto