LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-30-2016, 07:43 PM   #1
01micko
Member
 
Registered: Mar 2009
Location: Gold Coast, Queensland, Australia
Distribution: Puppy, Slackware
Posts: 92

Rep: Reputation: 18
SVG bug in gtk2/3 in 14.2


I have come across a gtk rendering bug with SVG images that contain an embedded image. This bug appears in 14.2 but wasn't present in 14.1.

Any simple gtk image viewer will show the bug (such as gpicview, or the demo from gnome).

I can't seem to find the source of the bug. I thought it may have been in rsvg but no. I can simply convert my svg with embedded image with rsvg-convert to a PNG with no problem. Maybe a glib regression?

I have built a simple program to demonstrate:
gtk_svg_test.c
Code:
#include <gtk/gtk.h>

int main(int argc, char *argv[]) {
    
  if(argc != 2) return 1;
  
  GtkWidget *window;
  GtkWidget *image;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_title(GTK_WINDOW(window), "Image");

  image = gtk_image_new_from_file(argv[1]);
 
  gtk_container_add(GTK_CONTAINER(window), image);

  g_signal_connect(G_OBJECT(window), "destroy",
        G_CALLBACK(gtk_main_quit), NULL);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}
Just compile it against gtk+-2.0 or gtk+-3.0 like so:
Code:
gcc -o gtk_svg_test gtk_svg_test.c `pkg-config --libs --cflags gtk+-2.0`
Also, you need the svg image. (Attached is the demo0.png needed to build it - put them all in the same dir along with the script below).

Below is the svg source image (just a circle filled with yellow) that gets the PNG embedded and a script to do the work.

demo0.svg:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="200px" width="200px" viewBox="0 0 100 100">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="yellow" />
</svg>
The script to build the embedded png inside the svg (needed because the path needs to be absolute)
mk_icon.sh:
Code:
#!/bin/sh

CWD=`pwd`
infile=demo0.svg
outfile=demo1.svg
pngfile=demo0.png
newline="  <image xlink:href=\"${CWD}/${pngfile}\" width=\"100\" height=\"100\" id=\"image0\"/>"

cat ${infile}|while read -r line;do
	[ "$line" == "</svg>" ] && break || echo -e "$line" >> ./${outfile}
done
echo -e "$newline" >> ./${outfile}
echo '</svg>' >> ./${outfile}
Once you have everything built just pass the demo1.svg as an arg to gtk_svg_test binary. You will see the difference running it in 14.1 as to 14.2. I tested in 32 bit and 64 bit. Note that the generated image opens fine in a browser or an image editor such as inkscape or gimp.

I can work around this bug for my purposes using rsvg-convert but it would be nice if anyone can identify the source of the issue.

Thanks for any feedback.
Attached Thumbnails
Click image for larger version

Name:	demo0.png
Views:	29
Size:	2.3 KB
ID:	22610  

Last edited by 01micko; 07-30-2016 at 08:16 PM. Reason: typos and more info
 
Old 08-02-2016, 05:30 PM   #2
zk1234
4MLinux Maintainer
 
Registered: Oct 2010
Location: Poland
Distribution: 4MLinux, Slackware
Posts: 1,255

Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by 01micko View Post
Note that the generated image opens fine in a browser or an image editor such as inkscape or gimp.
Both GIMP and your web browser (Firefox?) are using GTK, so it's not a GTK error.

.
 
Old 08-06-2016, 02:45 AM   #3
01micko
Member
 
Registered: Mar 2009
Location: Gold Coast, Queensland, Australia
Distribution: Puppy, Slackware
Posts: 92

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by zk1234 View Post
Both GIMP and your web browser (Firefox?) are using GTK, so it's not a GTK error.

.
Thanks for your reply.

Browsers use their own engine to render SVG. I tried in Konqueror and SeaMonkey as well. It works in any browser that supports SVG standards, which is all modern graphical browsers these days.

Although GTK stands for Gimp Tool Kit I'm not sure that Gimp uses pure GTK to render SVG images. Apart from that it is an editor. BTW, Geeqie, which ships with stock Slackware, fails to render the image in 14.2; does in 14.1. And the same can be said of emacs.

I'll mark this as solved for my purposes (work around with rsvg-convert), but the bug remains a mystery.

Cheers
 
Old 08-06-2016, 05:49 AM   #4
zk1234
4MLinux Maintainer
 
Registered: Oct 2010
Location: Poland
Distribution: 4MLinux, Slackware
Posts: 1,255

Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by 01micko View Post
Thanks for your reply.

Browsers use their own engine to render SVG. I tried in Konqueror and SeaMonkey as well. It works in any browser that supports SVG standards, which is all modern graphical browsers these days.

Although GTK stands for Gimp Tool Kit I'm not sure that Gimp uses pure GTK to render SVG images. Apart from that it is an editor. BTW, Geeqie, which ships with stock Slackware, fails to render the image in 14.2; does in 14.1. And the same can be said of emacs.

I'll mark this as solved for my purposes (work around with rsvg-convert), but the bug remains a mystery.

Cheers
I see.
 
  


Reply

Tags
gtk+, svg



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: SVG Web: Google Brings SVG Support to Internet Explorer LXer Syndicated Linux News 0 08-25-2009 04:12 PM
svg not worked Dimon-z Slackware 9 06-02-2008 03:52 AM
.svg icons bjb_nyj101 Linux - Software 1 05-02-2007 04:26 PM
cant use svg icons iwen Slackware 12 05-01-2005 11:01 PM
what is svg really? ZaphyR Linux - General 2 01-10-2005 02:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration