Workaround for erroneous gaps in rendering?

Post questions on how to use or achieve an effect in Inkscape.
chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Workaround for erroneous gaps in rendering?

Postby chrisjj » Thu Mar 21, 2013 12:27 am

Can anyone suggest program settings adjustment(s) to workaround the erroneous gaps I often find between coincident edges e.g. the vertical white line between these polygons:

Image

(SVG attached.)

The same occurs on exported bitmaps, and on the SVG viewed in web browsers. This is not due to SVG numeric precision - the coincident edges' points have identical coordinate values.

I do not want to adjust the drawing.

Thanks.

This is Inkspace V0.48, Win 7 Pro 64-bit.
Attachments
Gap between coincident edges.svg
(2.55 KiB) Downloaded 257 times
Last edited by chrisjj on Thu Mar 21, 2013 2:40 am, edited 1 time in total.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Workaround for erroneous gaps in rendering?

Postby ragstian » Thu Mar 21, 2013 1:43 am

Hi

The SVG spec for rendering addresses this issue here; http://www.w3.org/TR/SVG/painting.html#ShapeRenderingProperty
See this as well; http://stackoverflow.com/questions/11695967/space-between-hexagons-in-svg

How this can be done without "Adjust the drawing" is beyond me.

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Workaround for erroneous gaps in rendering?

Postby Lazur » Thu Mar 21, 2013 1:55 am

Those path's coordinates fit perfectly to the pixel grid.
With multple numbers of 90 dpi at the exporting the rendering issue doesn't show up.
This works with straight horizontal or vertical edges only, at exporting.
But you better avoid the problem by adjusting the drawing itself.

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Thu Mar 21, 2013 2:39 am

Thanks R, but none of the three shape-rendering options solves the problem in Inkscape here (EDIT: despite that shape-rendering="crispEdges" solves it in Firefox and Chrome.

In particular it seems Inkscape ignores shape-rendering="crispEdges":
http://img824.imageshack.us/img824/9372/regionsu.png

ragstian wrote:How this can be done without "Adjust the drawing" is beyond me.


I was hoping for e.g. program preference.
Last edited by chrisjj on Thu Mar 21, 2013 2:56 am, edited 1 time in total.

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Thu Mar 21, 2013 2:55 am

Lazur URH wrote:But you better avoid the problem by adjusting the drawing itself.

Thanks> Looks like I'll have to add a stroke of e.g. 0.2px and accept the loss of accuracy.

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Thu Mar 21, 2013 2:55 am

chrisjj wrote:
Lazur URH wrote:But you better avoid the problem by adjusting the drawing itself.

Thanks. Looks like I'll have to add a stroke of e.g. 0.2px and accept the loss of accuracy.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Workaround for erroneous gaps in rendering?

Postby Lazur » Thu Mar 21, 2013 3:09 am

You could combine the paths. That would merge such gaps in the rendering, result in an accurate shape, and keep all nodes separated.
So select them all, and press Ctrl+K.

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Thu Mar 21, 2013 3:32 am

Thanks for the suggestion, but the paths need to be kept separate for CAM output.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Workaround for erroneous gaps in rendering?

Postby ragstian » Thu Mar 21, 2013 4:03 am

Hi.

The work around to get it to display accurately in Inkscape and export to png without gaps is to snap the objects to a pixel grid.

Then export with dots per inch (in the export menu) set to multiples of 72. (72, 144, 288, 576 - etc.)

See attached SVG - the shapes were copied into "drubans" default Inkscape file and snapped to the grid.
( Thanks to "druban" for sharing this file!)
See this thread; http://www.inkscapeforum.com/viewtopic.php?f=5&t=13681&p=52994&hilit=default.svg#p52994

Good Luck

RGDS
Ragnar
Attachments
Gap_between_coincident_edges_snapped_2.svg
(3.88 KiB) Downloaded 228 times
Last edited by ragstian on Thu Mar 21, 2013 5:02 am, edited 2 times in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Thu Mar 21, 2013 4:24 am

ragstian wrote:The work around to get it to display accurately in Inkscape and export to png without gaps is to snap the objects to a pixel grid.


Thanks, but fails here, e.g.
Image

ragstian wrote:See attached SVG


That too fails here:

Image

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Workaround for erroneous gaps in rendering?

Postby ragstian » Thu Mar 21, 2013 4:39 am

Hi.

Try again - the file attached was not the correct one!
(Download the file again)
I can get it to show the gap at some combinations of window size and zoom settings while other combinations displays OK.
Try experimenting to get a setting which works OK.
The PNG export works Ok on my system.
Image
Click Image for larger version.

Good Luck
RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Thu Mar 21, 2013 5:11 am

ragstian wrote:Try again - the file attached was not the correct one!


Thanks, but still fails:

Image

ragstian wrote:I can get it to show the gap at some combinations of window size and zoom settings while other displays OK.


Me too. And trying my original, I find the same.

E.g. on your latest, 100% is faulty, 800% OK.

ragstian wrote:The PNG export works Ok on my system.


Not on mine. Some dpi values succeed, some fail e.g. your file at 300dpi:

Image

ragstian wrote:Try experimenting to get a setting which works OK.


Thanks for the suggestion, but what I'm really experimenting for is a program that works OK.

I think this bug https://bugs.launchpad.net/inkscape/+bug/166252 has the same cause. And I there see apparent confirmation that Inkscape ignores crispEdges. Sad.

Thanks anyway for your suggestions.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Workaround for erroneous gaps in rendering?

Postby ragstian » Thu Mar 21, 2013 6:14 am

Hi.

crisjj;
Not on mine. Some dpi values succeed, some fail e.g. your file at 300dpi:

As I said;
regstian;
Then export with dots per inch (in the export menu) set to multiples of 72. (72, 144, 288, 576 - etc.)

300 is not a multiple of 72.
crisjj;
Thanks for the suggestion, but what I'm really experimenting for is a program that works OK.

I totally agree with you, it would be fine if everything worked perfectly but I feel at the price of Inkscape we have to accept some bugs,
keep in mind that the current version is 0.48, we can expect a version which follows the SVG specs at version 1.0!
In my opinion the developers of Inkscape are doing a fantastic job - for free.

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Workaround for erroneous gaps in rendering?

Postby druban » Thu Mar 21, 2013 7:05 am

This is a constant problem and recurring thread in this forum, often ending with some unhappiness and frustration. My suggestion is that the very able moderators combine all the threads - there are quite a few! - that refer to this issue into a folder and stick it to the top of the forum or maybe even give it its own forum in the board index.
That way lazy people (like me) don't have to tediously search through all the posts to find and refer to the various proposed solutions.

Here is a topic about this problem and Ivan Louette's very nice filter solution. Another thread that contains some possibly useful info - not to the OP but perhaps to others.
This might explain the difference between 'combine' and 'union'. CAM output doesn't care if your PNG export has gaps in it so you could have two files, one for CAM and one for PNG export. Admittedly this is extra work.

At one time I did some experimentation and found this solution. Unfortunately if you read the followup post changes were made to the renderer that resulted in this solution not working and it may not have been a complete solution anyway.(Using multiples of 5 for lineless onscreen display still works, though, if nice clean screenshots are your goal.)
A more complicated way to look at it is to say that if the objects are strokeless and are snapped to the pixel grid, multiples of 90 will always work. Some other multiples of numbers will work as well. The seam needs to fall on a whole number and the PPI also needs to be a whole number. 300 ppi does not work because 70 (width of the left object)/90 times 300 = 233.33, so the seam does not fall on a whole number pixel. But 72 Ppi works because 70/90 times 72 = 56. If you have more than one seam you can see that only multiples of 90 are going to be practical for export, as Lazur suggested.

The whole subject of bitmap export with sharp edges is troublesome if, as you say, you don't want to 'alter' the drawing. Combining paths is the least destructive solution to exporting at random (in relation to object dimension) DPIs but it also seems to be unsatisfactory...

Although some people have called it a bug in my current build of Inkscape the DPI is altered from what you enter if you make an impossible request. So in this case when I ask for a 300PPI export of an object that is 110 pixels wide at 90 PPI (internal Inkscape resolution), Inkscape corrects the request to reflect that the closest possible export is 367 px wide at 300.27 PPI. (Sometimes you have to click in both the width and height boxes to see this). So in fact I - or anyone! - can't ever export the drawing in question at 300PPI. This upsets some people much more than it should!
Last edited by druban on Thu Mar 21, 2013 11:20 am, edited 3 times in total.
Your mind is what you think it is.

chriswww
Posts: 383
Joined: Fri Nov 19, 2010 3:04 pm

Re: Workaround for erroneous gaps in rendering?

Postby chriswww » Thu Mar 21, 2013 10:48 am

Whilst it would be nice if the renderer worked a bit of magick to make the situation better, in the end this is a generic problem with a lot of graphics programs that use vectors, including 3D CSG creation programs like povray and blender. In 3D the problem gets worse as you can have entire planes show abberations when renderred. The proper solution is to use union operations as you build the objects or laternately nudge up the sizes of the lower object primitives. Since all objects have an order in SVG, the second solution is pretty workable if you can't use the union solution.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Workaround for erroneous gaps in rendering?

Postby brynn » Thu Mar 21, 2013 11:03 am

I didn't read this whole entire thread, so this may have been mentioned (although I didn't see it). There's a filter which can fix that, until 0.49 comes out, in which the bug is fixed. Stitch filter: viewtopic.php?f=5&t=9034&p=33279&hilit=stitch#p32882

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Fri Mar 22, 2013 2:48 am

ragstian wrote:I totally agree with you, it would be fine if everything worked perfectly but I feel at the price of Inkscape we have to accept some bugs,


I agree. There are many bugs that I accept in Inkscape.

ragstian wrote:keep in mind that the current version is 0.48


I am. I also keep in mind that this bug was first reported 8 years ago.

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Fri Mar 22, 2013 3:23 am

druban wrote: if the objects are strokeless and are snapped to the pixel grid, multiples of 90 [b]


Thanks for the suggestion. Trying that: http://img801.imageshack.us/img801/333/regionea.png

druban wrote:[b]will always work.


Fails here: http://img600.imageshack.us/img600/2797/temppx.png

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Fri Mar 22, 2013 3:24 am

brynn wrote: 0.49 comes out, in which the bug is fixed.


Great new. Thanks. I can't find the Launchpad record of that fix, so it would be good to have a link.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Workaround for erroneous gaps in rendering?

Postby ~suv » Fri Mar 22, 2013 4:50 am

chrisjj wrote:
brynn wrote: 0.49 comes out, in which the bug is fixed.

Great new. Thanks. I can't find the Launchpad record of that fix, so it would be good to have a link.

It is not yet fixed in current development builds (and it looks like it won't be fixed in the next major release 0.49 either) - maybe brynn confused the issue discussed here (gaps due to antialiasing artefacts at the object boundary) with the one mentioned in the release notes (draft version), which is about gaps in pattern fills - a different issue.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Workaround for erroneous gaps in rendering?

Postby Lazur » Fri Mar 22, 2013 5:13 am

chrisjj wrote:
druban wrote: if the objects are strokeless and are snapped to the pixel grid, multiples of 90 [b]


Thanks for the suggestion. Trying that: http://img801.imageshack.us/img801/333/regionea.png

druban wrote:[b]will always work.


Fails here: http://img600.imageshack.us/img600/2797/temppx.png



Lazur URH wrote:Those path's coordinates fit perfectly to the pixel grid.
With multple numbers of 90 dpi at the exporting the rendering issue doesn't show up.
This works with straight horizontal or vertical edges only, at exporting.
But you better avoid the problem by adjusting the drawing itself.

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Fri Mar 22, 2013 5:49 am

Lazur URH wrote:This works with straight horizontal or vertical edges only, at exporting.


Thanks, L. No such limitation is mentioned in D's formula. D, may I suggest a mention be added, for the record? This should save the time of the typical user given that, I think, he does use edges in different directions. Thanks.

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Workaround for erroneous gaps in rendering?

Postby druban » Fri Mar 22, 2013 7:30 am

chrisjj wrote:No such limitation is mentioned in D's formula.


Sorry for the confusion! That's why formulas are no substitute for understanding the problem. I tried to offer an explanation in my own poor way when I said
druban wrote:The seam needs to fall on a whole number...

but I was just not clear enough. So I will try to explain:

For an oblique line, many, if not all, of the pixels used to represent it in a bitmap will not fall on a whole-number pixel location and therefore will have to be approximated using anti-aliasing methods which in the case of contiguous objects of the same value will not be an appropriate representation. This is a problem caused by Inkscape's rendering of separate objects separately without considering their context.

Perhaps this small addition here might be helpful to both the OP and any others following this topic: There is no way to convert an oblique vector line to pixels without incurring some inaccuracy, either in the form of anti-aliasing or jaggedness. The same is true of curved lines.

Disclaimer: my understanding of the problem, upon which I have based my explanation, does imply that being able to turn off AA would solve some aspects of this problem. This opinion is not in any way based on experience with the actual source code involved and may be entirely erroneous. Please consult an Inkscape developer before pursuing this in any way.

Sorry for any misunderstanding. I hope I have slightly advanced the ability of Inkscape users to conceptualize the process and problems with converting vector data to a bitmap representation here as well as in a few other threads.

Apologies to both Lazur and Ragnar for muddying up their clear explanations with my clumsy additions!
Last edited by druban on Fri Mar 22, 2013 6:05 pm, edited 1 time in total.
Your mind is what you think it is.

chrisjj
Posts: 153
Joined: Thu Jan 17, 2013 10:45 am

Re: Workaround for erroneous gaps in rendering?

Postby chrisjj » Fri Mar 22, 2013 9:31 am

Thanks for the clarification, D.

User avatar
ryanlerch
Posts: 107
Joined: Thu Jun 07, 2007 8:36 am
Location: Brisbane, Australia
Contact:

Re: Workaround for erroneous gaps in rendering?

Postby ryanlerch » Thu Nov 06, 2014 5:05 am

I find this is the simplest way (although a rough workaround) to stop the gaps from rendering:
http://inkscapetutorials.org/2014/11/04/inkscape-workaround-to-fix-the-white-gaps-between-objects/


Return to “Help with using Inkscape”