LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-16-2007, 11:33 PM   #1
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Rep: Reputation: 15
Thumbs down open an svg file using rsvg and cairo


I am new to both libraries so I can't get the right functions in the right order.
If anyone knows how to do this please help.I am going to post some embarrassing code now.

Code:
void
on_button_open_clicked                    (GtkButton      *Button,
										gpointer		user_data)
                    
{

  gchar *filename;
  filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooserdialog1));
  cr = gdk_cairo_create (canvas1->window);
  if(cr==NULL)g_message("cairo reference NULL");
  rsvg_handle=rsvg_handle_new();
  rsvg_handle=rsvg_handle_new_from_file(filename,NULL);
  if(rsvg_handle==NULL)g_printerr("\n file open failed %s ",filename);
  cairo_set_source_rgb (cr, 1,1,1);
  rsvg_handle_render_cairo(rsvg_handle,cr);	
//  rsvg_handle_write(rsvg_handle,"test",2000,NULL); 
  cairo_surface=cairo_svg_surface_create(filename,500,800);	
  cairo_paint (cr);
  rsvg_handle_close(rsvg_handle,NULL);
  gtk_widget_destroy (filechooserdialog1);
cairo_stroke (cr);

cairo_destroy (cr);

}
This is the gtk function that is called when you select the file and click open.I don't know what it does right now but it doesn't open the file image into a window ,that's for sure. I've put in every function I thought would work in various orders.

Does any one have suggestions ?
 
Old 06-17-2007, 12:51 PM   #2
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Original Poster
Rep: Reputation: 15
The rsvg_handle=rsvg_handle_new_from_file(filename,NULL); line is not opening the file .The handle is NULL.
The filename and path print correctly though.

Last edited by cyb0rg777; 06-17-2007 at 12:52 PM.
 
Old 06-18-2007, 10:29 PM   #3
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Original Poster
Rep: Reputation: 15
This is what I have so far.It loads the image except for the text.
I get this error.
Pango-CRITICAL **: pango_font_description_set_size: assertion `size >= 0' failed

Code:
void
on_button_open_clicked                    (GtkButton      *Button,
					gpointer		user_data)
                    
{
  gchar *filename;
  GError **crap;
  filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooserdialog1));
  gtk_widget_destroy (filechooserdialog1);
  cr = gdk_cairo_create (canvas1->window);
  if(cr==NULL)g_message("cairo reference NULL");
  rsvg_handle=rsvg_handle_new_from_file(filename,crap);
  if(rsvg_handle==NULL)g_printerr("\n file open failed %s ",filename);
  rsvg_handle_render_cairo(rsvg_handle,cr);	
// rsvg_handle_close(rsvg_handle,NULL);
  cairo_destroy (cr);

}
and the redraw function has to redraw it...

Code:
//canvas events

void
paint (GtkWidget      *widget,
       GdkEventExpose *eev,
       gpointer        data)
{


  gint width, height;
  gint i;

  width  = widget->allocation.width;
  height = widget->allocation.height;

   
  cr = gdk_cairo_create (widget->window);

// clear background 
    cairo_set_source_rgb (cr, 1,1,1);
    cairo_paint (cr);
    cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
                                        CAIRO_FONT_WEIGHT_BOLD);
    cairo_set_font_size (cr, 20);

  if(!rsvg_handle==NULL)
  rsvg_handle_render_cairo(rsvg_handle,cr);  

}
Does anyone know why my font doesn't load?

Last edited by cyb0rg777; 06-18-2007 at 10:58 PM.
 
Old 06-24-2007, 10:23 PM   #4
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Original Poster
Rep: Reputation: 15
I found my text problem.It was something I did earlier in the code.
So the program moves forward.
I don't want to clutter the forum so I'll add my next question here.

Does anyone know where I can get a small code example or tutorial for a GTK iconview ?

Thanks

Last edited by cyb0rg777; 06-24-2007 at 10:24 PM.
 
Old 08-02-2007, 10:52 AM   #5
srinireddy07
LQ Newbie
 
Registered: Aug 2007
Posts: 6

Rep: Reputation: 0
Thumbs down require rsvg libraries

Hi,

I am developing an application in which I am trying to load a SVG file on Cairo surface. I have got some of these files but still missing some like gdk-pixbuf, libxml etc. Could you tell me how I can get them or provide me a weblink so that I can download. Please mention all possible dependent file links.

Appreciate your help.

Thanks in advance

Srini

Last edited by srinireddy07; 08-02-2007 at 10:56 AM.
 
Old 08-03-2007, 06:43 AM   #6
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Original Poster
Rep: Reputation: 15
I didn't have to look for all that because the anjuta ide did everything automatically.
If you are developing a large application in c or c++ you should use a good ide like anjuta.I installed everything using the apt-get package manager so I didn't have to download the source code either.

I had to add librsvg-2.0 flag to the configuration by following the help file instructions in anjuta.

If you are looking for source code for those packages their sites can be found by searching google.

Sorry I couldn't be more help. Good luck.
 
Old 08-03-2007, 02:26 PM   #7
srinireddy07
LQ Newbie
 
Registered: Aug 2007
Posts: 6

Rep: Reputation: 0
Thanks for the info

Quote:
Originally Posted by cyb0rg777
I didn't have to look for all that because the anjuta ide did everything automatically.
If you are developing a large application in c or c++ you should use a good ide like anjuta.I installed everything using the apt-get package manager so I didn't have to download the source code either.

I had to add librsvg-2.0 flag to the configuration by following the help file instructions in anjuta.

If you are looking for source code for those packages their sites can be found by searching google.

Sorry I couldn't be more help. Good luck.

Hi,

Thanks for your immediate reply. Let me explore more on Google and try to get the required files.

Thanks a lot.

Thanks
Srini
 
Old 08-05-2007, 04:50 PM   #8
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Original Poster
Rep: Reputation: 15
What is your idea for your program ,if you don't mind me asking? If we are making the same thing we should work together.You have got to be good at searching the web though to find all the info. I'm new at this too.
 
Old 08-08-2007, 10:49 AM   #9
srinireddy07
LQ Newbie
 
Registered: Aug 2007
Posts: 6

Rep: Reputation: 0
Loading SVG image on Cairo surface

Quote:
Originally Posted by cyb0rg777
What is your idea for your program ,if you don't mind me asking? If we are making the same thing we should work together.You have got to be good at searching the web though to find all the info. I'm new at this too.
Hi,
Thanks for your concern. But anyway, I could manage to get the required libraries from various sources on the Net. Basically I was requiring librsvg library files. But all the files are not kept at the same location on the web(to my knowledge). I have found them on Google search. Now, I am able to develop the application with the required Cairo and RSVG features. But there seemed to be too many library dependencies like png, xml, freetype, croco etc.

Now I am trying to see if I could reduce those dependencies.

My basic aim is to create a Cairo surface and load SVG image on the Cairo surface and be able to manipulate the SVG image like loading, repositioning, resizing etc.

So far I am able load to the SVG file on Cairo surface. If there is any alternative to load SVG image on a Cairo surface, please let me know.

We can always share info if we are into same problem domain.

Appreciate your concern.

Thanks
Srini
 
  


Reply

Tags
cairo, svg


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cairo in testing gefst Slackware 4 10-08-2006 04:19 PM
installing cairo? lilili Linux - Newbie 9 02-01-2006 12:19 PM
Geting error loop QFike:getch: File not open QFile:atEnd: this file is not open badgerbox76 Linux - Newbie 6 01-07-2006 05:30 PM
gtk+2.8 and cairo John Velman Slackware 3 10-19-2005 04:16 PM
How to open SVG (SVGZ) images? kule Linux - Software 2 04-02-2005 05:27 AM


All times are GMT -5. The time now is 02:40 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration