[cairo] parse svg with cairo

Kreller, Marcus MKreller at ime-actia.de
Thu Jun 7 04:13:06 PDT 2007


Hi,

I tried to open svg-files with cairo. In a code example 
svg_cairo_parse(svgc, "file.svg") is called to open a file. 
I have looked at the Internet and saw that the function 
doesn´t used in cario 1.0.4.

Is there a way to open svg-files with cario 1.0.4, without rsvg handle ? 

////////////////////////////////////////////////////////////////////////

My code example:

  RsvgHandle* g_my_svg = NULL;
  RsvgDimensionData g_dimension = {0};
  HDC hdc;
  GError* pError = NULL;
  
  /* Convert Filename */
  CString l_szTemp(_T("C:\\svg-viewer.svg"));
  char* buf = (char*) malloc(10000);
  UtoAConvert( l_szTemp , buf, 1000 );

  /* Initialize rsvg */
  rsvg_init();
  
  /* Open handle for SVG-File */
  g_my_svg = rsvg_handle_new_from_file(buf, &pError);
  
  /* Get HWND */
  hdc = GetDC(hwnd);
       
  /* Create Cairo surface */
  cairo_surface_t *cairo_surface = cairo_win32_surface_create(hdc);
  cairo_t *cr = cairo_create(cairo_surface);

  /* Scale */
  cairo_save(cr);
  cairo_scale(cr, p_Cx, p_Cy);
  
  /* Paint Background */
  cairo_set_source_rgba(cr, 1, 1, 1, 1);
  cairo_paint(cr); 

  rsvg_handle_render_cairo_sub(g_my_svg, cr, NULL);  -> I dont wanna use rsvg, only cairo 
  cairo_restore(cr);
      
  /* Force pipeline out. */
  cairo_surface_flush(cairo_surface);

  /* Clean up. */
  cairo_destroy(cr);
  cairo_surface_destroy(cairo_surface);




More information about the cairo mailing list