After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 105316 - SVG used as background scales as pixmap
SVG used as background scales as pixmap
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Background
2.5.x
Other All
: High minor
: 2.6.1
Assigned To: Control-Center Maintainers
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2003-02-05 16:01 UTC by Christian Fredrik Kalager Schaller
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
SVG image used in screenshot (94.93 KB, text/plain)
2003-02-05 16:02 UTC, Christian Fredrik Kalager Schaller
  Details
simple gnome-logo background SVG, overlay for dark background colors (3.53 KB, image/svg)
2004-03-06 02:59 UTC, Richard Hoelscher
  Details
Scales SVGs as vector when drawing to screen. (8.04 KB, patch)
2004-03-11 18:56 UTC, Chris Lahey
none Details | Review
New patch. More fixes. (15.75 KB, patch)
2004-03-12 20:45 UTC, Chris Lahey
none Details | Review

Description Christian Fredrik Kalager Schaller 2003-02-05 16:01:33 UTC
Testing using SVG's as background images I noticed that the SVG gets scaled
as a pixmap not as a SVG file. This means that even SVG files gets jagged
etc. when scaled up.

Look at the tiger in this image and you see for instance how his teeth are
jagged:
http://librsvg.sourceforge.net/images/tigerandgorilla.png
Comment 1 Christian Fredrik Kalager Schaller 2003-02-05 16:02:32 UTC
Created attachment 14127 [details]
SVG image used in screenshot
Comment 2 Ben FrantzDale 2003-02-06 03:12:49 UTC
I saw that screenshot too. However I tried opening that attachment and
although Sodipodi can open it, I got an error that it wasn't a
supported file type for the desktop background. Weird.
Comment 3 Luis Villa 2003-02-06 06:46:32 UTC
Ben: what version of librsvg do you have? Alex L. couldn't duplicate
Uraeus's problem with latest librsvg, he said, on nautilus-list.
Comment 4 Alex Duggan 2003-02-06 06:50:34 UTC
The same thing happens if you try to view the svg in eog.  It appears
it's being converted to a raster graphic in eog and
 when you zoom in, it appears jagged.
Comment 5 Alex Duggan 2003-02-06 07:02:11 UTC
That svg looks bad for me too as a stretch background.  Using
librsvg-2.2.3 and gtk+-2.2.1
Comment 6 Christian Fredrik Kalager Schaller 2003-02-06 08:51:40 UTC
To help people reproduce. I use the background capplet, choose the
tiger and select the scaled button to make it fullscreen.
Comment 7 Christian Fredrik Kalager Schaller 2003-02-21 09:57:27 UTC
Adding Seth to CC as he is the creator/owner of the background
settings capplet.
Comment 8 Seth Nickell 2003-02-22 21:38:11 UTC
I'm neither the owner nor the creator ;-) The code was completely
rewritten from what I originally wrote... Not sure who's the owner at
this point.
Comment 9 Christian Fredrik Kalager Schaller 2004-02-02 17:51:22 UTC
Anything that sets the background should be scaling using
from_file_at_size.

Would be great to have this fixed for 2.6
Comment 10 Dominic Lachowicz 2004-02-02 19:40:59 UTC
this really should be considered a blocker for gnome 2.6. if not, you
get really pixellated backgrounds if your background is a SVG image.

it should be pretty trivial to
s/gdk_pixbuf_new/gdk_pixbuf_new_at_size/g in the capplet and the
actual bit that sets the background(nautilus? gnome-settings-daemon?)

cc'ing dobey, as he owns the new capplet. raising priority.
Comment 11 Dominic Lachowicz 2004-02-02 19:50:14 UTC
cc'ing myself
Comment 12 Andrew Sobala 2004-02-02 21:49:11 UTC
This is unpleasant but not a blocker.

Also, Uraeus: fwiw, GNOMEVER2.6 is for bugs in 2.6. 2.6 is not
released yet, so please don't use the keyword ;-)
Comment 13 Chris Lahey 2004-03-03 18:21:06 UTC
I've tried it and it doesn't seem to help.  I'm definitely doing
at_size 1280 x 1024, but I'm still getting a scaled image.  I believe
the problem is the following:

(gnome-settings-daemon:1285): GdkPixbuf-CRITICAL **: file
gdk-pixbuf-io.c: line 811 (size_prepared_cb): assertion `width > 0 &&
height > 0' failed
 
(gnome-settings-daemon:1285): librsvg-WARNING **: rsvg_start_svg:
width and height not specified in the SVG, nor supplied by the size
callback

Not sure what to do about this, though it does explain why it's still
pixelated.  This is running librsvg 2.5.0 and gtk+ 2.3.4.

Also, is there any way to tell gdk pixbuf that you want it to use the
exact dimensions you give, instead of keeping the aspect ratio?  It
seems like this would be preferable when setting the background to
fill the screen.  Sorta silly, for example, to draw the tiger at
1024x1024 and then do pixelated scaling to 1280x1024.
Comment 14 Dominic Lachowicz 2004-03-03 19:17:29 UTC
i guess a good test would be to see why this gdk-pixbuf warning happend:

gdk-pixbuf-io.c: line 811 (line 806 in my CVS)

its value is passed directly into RSVG, which explains the next
warning. if you can, chris, set a breakpoint/printf around there and
see what happens.

it looks like gdk-pixbuf always tries to keep the aspect ratio the
same (size_prepared_cb), unfortunately. i'd say that was a bug and
should be fixed ASAP (fwiw, this was not in my original patch)... you
didn't ask for a 1024x1024 image, you asked for 1280x1024, regardless
if the specs now say:

"830  * The image will be scaled to fit in the requested size,
preserving its aspect ratio."
Comment 15 Chris Lahey 2004-03-04 22:56:26 UTC
If you do change this (which makes total sense to me) the background
applier code is also going to need to be able to request the size of
the image before loading it, so that it can scale keeping aspect
ratio.  This would have to happen before loading the image, of course,
so we don't have to load the image twice.

Also, this would reintroduce the problem that your change would fix
since rsvg doesn't seem to report a size for that particular svg.
Comment 16 Dominic Lachowicz 2004-03-05 03:46:20 UTC
rsvg can't report a size if the SVG doesn't have one. technically,
it's legal to omit the width && height <svg> parameters, which means
that the SVG is drawn at its "natural size". unfortunately, that means
that you can't know how big it is without rendering the SVG first.
chicken. egg.

as such, i'd file a bug against any particular SVG that omits a width
and height argument. as you can see, I've never been a fan of that
part of the SVG spec. add a width && height param to your SVGs, damnit.

i'm not in a position to change the aspect ratio bug in GTK+. you'll
have to talk with owen and matthias. it would break API, which may be
frowned upon. then again, maybe you could convince them to add yet
another API for from_file_at_size_i_really_mean_it_damnit()

the "size_prepared" callback does pass in the width && height of the
image. at least it does so when one exists...

if you fix the gtk+ bug, you'll handle the 99% case which is certainly
a big step in the right direction.
Comment 17 Chris Lahey 2004-03-05 16:35:35 UTC
I'm pretty sure that if you use an image with a width and height in
the svg, this won't be a bug.  I don't have one to test with though. 
Could you attach one?
Comment 18 Dominic Lachowicz 2004-03-05 16:55:31 UTC
inside of librsvg, you'll find:

tests/Artwork.svg (.75 aspect ratio)
tests/Picasso.svg (1.48 aspect ratio)

these are both good tests. "Artwork" is probably better suited to a
desktop background, as it more closely follows the aspect ratio of
most monitors (unless you rotate picasso.svg 90deg, in which case it
has a 1.333 aspect ratio). you should see a picture of San Francisco
and a Picasso drawing, respectively.
Comment 19 Richard Hoelscher 2004-03-06 02:59:09 UTC
Created attachment 25253 [details]
simple gnome-logo background SVG, overlay for dark background colors
Comment 20 Dominic Lachowicz 2004-03-06 18:21:06 UTC
see also bug #136395
Comment 21 Dominic Lachowicz 2004-03-08 04:29:02 UTC
clahey - it reports 500x500 now for bogus SVGs
Comment 22 Dominic Lachowicz 2004-03-11 02:13:53 UTC
clahey - i just tried this and things "just worked" for me.

rsvg --x-zoom=.5 --y-zoom=.5 tiger.svg out.png

gave me a 250x250 image (with most of the tiger cropped)
Comment 23 Chris Lahey 2004-03-11 18:45:51 UTC
Attaching a fix for this problem, but with svgs, there are still some
issues.  I'll include them in the following.

I think perhaps the default should be changed to 512.  No reason not to.

I changed the code in settings daemon to allow for unset sizes, just
in case (it assumes a 500 pixel square also.)  However, the pixbuf
loader for svg doesn't seem to be scaling the image from 500x500 up to
whatever size the screen specifies.  Instead it just draws it on a
larger background.

It would be optimal, I believe, to scale the image as if the
width/height were given as 500 in the file.

Also, even if the size is given, text doesn't change aspect ratio if
the aspect ratio of the output changes.  This means, for example, that
if you have a wide svg with text across it and are set it to fill the
screen, the text goes off the screen.  Not sure if the text scales
with the height or with the greater of the two dimensions.

As soon as this patch is committed, I'll file these all as separate bugs.
Comment 24 Chris Lahey 2004-03-11 18:47:38 UTC
Sure, but shouldn't the tiger be scaled down by 50% so that it mostly
fits?  (A little would get cut off, but most of it should be there.)
Comment 25 Chris Lahey 2004-03-11 18:56:02 UTC
Created attachment 25531 [details] [review]
Scales SVGs as vector when drawing to screen.
Comment 26 Dominic Lachowicz 2004-03-11 19:17:44 UTC
chris - librsvg's text support is broken, and i'm not taking bugs
against it until Sven and I get to do some work on it. just fyi.

i can make the "assumed size" 512x512 if none is specified. that'll be
about 10 seconds worht of work. in the case where a width and height
aren't specified, i can make it so that the picture scales up/down
correctly. that'll be a bit more work.

again, however, i think that you need to get a new test SVG. my
patience for working around broken parts of the SPEC and broken SVG
producers is wearing thin.

the important part is that you get this checked into egg and into
Gnome. the rest is just tedium in librsvg that i can work around in my
spare time.
Comment 27 Chris Lahey 2004-03-11 19:26:36 UTC
I've been using a number of SVGs from your test directory.  Actually,
some of the ones there have no width and height.

I really don't care too much about fixing files without width or
height.  Very minor as far as bugs go.
Comment 28 Dominic Lachowicz 2004-03-12 02:59:29 UTC
we're now assuming a 512x512 canvas and can scale those annoying
unsized SVGs.
Comment 29 Jody Goldberg 2004-03-12 15:58:03 UTC
The sizing patch looks good and should go in as soon as 2.6.0 ships.
I'd rather see a slightly different approach to the application timer.
Rather than ignoring subsequent changes and just using the existing timers it
should clear existing timers and create a new one.  Otherwise if a user pages
through things quickly

eg
    autorepeat downarrow

we could end up with no delay again
Comment 30 Chris Lahey 2004-03-12 20:45:36 UTC
Created attachment 25576 [details] [review]
New patch.  More fixes.
Comment 31 Chris Lahey 2004-03-12 20:52:31 UTC
This new patch fixes that last request as well as fixing bug #136715.
 I'd love it if these were separate patches, but they interfere majorly.
Comment 32 Jody Goldberg 2004-03-12 21:23:21 UTC
Nice.  Please commit as soon as 2.6.0 ships
Comment 33 Vincent Untz 2004-03-14 15:17:29 UTC
Adding BLOCKED_BY_FREEZE keyword.
Comment 34 Jody Goldberg 2004-04-07 04:49:17 UTC
Applied.
Thanks