Discussion:
[cairo] how to copy a part from one surface to another ?
thom_schu
2007-06-27 09:57:31 UTC
Permalink
Is it possible (and how) to copy a part from one surface to another ?

something like

destSurface->set_source(srcSurface, xDest, yDest, xSrc, ySrc, widthSrc, heightSrc)


thanks in advance
--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
Carl Worth
2007-06-27 14:11:02 UTC
Permalink
Post by thom_schu
destSurface->set_source(srcSurface, xDest, yDest, xSrc, ySrc, widthSrc, heightSrc)
I'll write in C, and hopefully you can trivially translate to your
language of interest. Given cr that's targeting dest_surface you can
do:

cairo_set_source_surface (cr, src_surface, x_dest - x_src, y_dest - y_src);
cairo_rectangle (cr, x_dest, y_dest, width, height);
cairo_fill (cr);

If your source surface has any alpha, that will blend it over the
destination. If you want to copy the alpha directly, you'll want to
use the SOURCE operator something like this:

cairo_save (cr);
cairo_rectangle (cr, ...);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_fill (cr);
cairo_restore (cr);

If your source surface has no alpha then you can use either one---it
doesn't matter.

And do notice that cairo isn't providing a "copy surface" primitive
here, but instead that you're simply drawing something and using a
surface as the source pattern. So you can similarly draw anything,
(complex polygons, text, etc.), and have it be patterned with the
surface.

Have fun with cairo,

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://cairographics.org/archives/cairo/attachments/20070627/53c3afaf/attachment.pgp
Kreller, Marcus
2007-06-28 09:04:42 UTC
Permalink
Hi,

for one of my projects in Visual C++ 6.0 under WinXP I render SVGs with
librsvg 2.16.1. These SVGs
contain some text tags like this:

<text x="10" y="10" >...</text>

Cairo with librsvg works fine but all redered SVGs displayed without
text. No error or something else.
I put the sources of cairo, librsvg and pango (v 1.16) into my project
to debug someone, but I dont find the reason. I tested my svgs
additional with Firefox and Gimp and here the text was diplayed.
These programs also use cairo+librsvg+pango to picture svgs.

What am I doing wrong? A bug in pango?

Thanks,

Marcus
Emmanuel Pacaud
2007-06-28 09:30:22 UTC
Permalink
Post by Kreller, Marcus
Hi,
for one of my projects in Visual C++ 6.0 under WinXP I render SVGs with
librsvg 2.16.1. These SVGs
<text x="10" y="10" >...</text>
Cairo with librsvg works fine but all redered SVGs displayed without
text. No error or something else.
I put the sources of cairo, librsvg and pango (v 1.16) into my project
to debug someone, but I dont find the reason. I tested my svgs
additional with Firefox and Gimp and here the text was diplayed.
These programs also use cairo+librsvg+pango to picture svgs.
Could you send us a sample file ?
Did you try to render these files with the rsvg-view utility that comes
with librsvg ? Or rsvg-convert ?

Emmanuel.
--
Emmanuel PACAUD
Groupe Virgo
LAPP - Laboratoire d'Annecy-le-Vieux de physique des particules
9, chemin de Bellevue - BP 110
74941 Annecy-le-Vieux CEDEX
France
T?l: (+33)4 50 09 17 89 - Fax: (+33)4 50 27 94 95
Behdad Esfahbod
2007-06-28 15:10:12 UTC
Permalink
Post by Kreller, Marcus
Hi,
for one of my projects in Visual C++ 6.0 under WinXP I render SVGs with
librsvg 2.16.1. These SVGs
<text x="10" y="10" >...</text>
Cairo with librsvg works fine but all redered SVGs displayed without
text. No error or something else.
I put the sources of cairo, librsvg and pango (v 1.16) into my project
to debug someone, but I dont find the reason. I tested my svgs
additional with Firefox and Gimp and here the text was diplayed.
These programs also use cairo+librsvg+pango to picture svgs.
What am I doing wrong? A bug in pango?
Unlikely. Which version of cairo are you using? Unless you send test
code or SVG file there's not much we can do.

behdad
Post by Kreller, Marcus
Thanks,
Marcus
_______________________________________________
cairo mailing list
cairo at cairographics.org
http://cairographics.org/cgi-bin/mailman/listinfo/cairo
--
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
Emmanuel Pacaud
2007-06-28 12:00:41 UTC
Permalink
I dont now that exist some extra functions/utilities to open SVG and so I dont try rsvg-view or rsvg-convert but I will do this. Can you give me a code example how to use rsvg-view and/or rsvg-convert?
rsvg-view and rsvg-convert are applications included in librsvg, and
should be compiled by default.

The text in your sample file is hidden behind the tiger...

Emmanuel.
--
Emmanuel PACAUD
Groupe Virgo
LAPP - Laboratoire d'Annecy-le-Vieux de physique des particules
9, chemin de Bellevue - BP 110
74941 Annecy-le-Vieux CEDEX
France
T?l: (+33)4 50 09 17 89 - Fax: (+33)4 50 27 94 95
Kreller, Marcus
2007-06-28 13:01:26 UTC
Permalink
I tested the example file also with text-tag at the end of the svg and only with text but nothing
changed.

Can I compile rsvg-view and rsvg-convert under windows?

Marcus


-----Urspr?ngliche Nachricht-----
Von: Emmanuel Pacaud [mailto:emmanuel.pacaud at lapp.in2p3.fr]
Gesendet: Donnerstag, 28. Juni 2007 14:01
An: Kreller, Marcus
Cc: cairo at cairographics.org
Betreff: Re: AW: [cairo] cairo never render text in svg
I dont now that exist some extra functions/utilities to open SVG and so I dont try rsvg-view or rsvg-convert but I will do this. Can you give me a code example how to use rsvg-view and/or rsvg-convert?
rsvg-view and rsvg-convert are applications included in librsvg, and
should be compiled by default.

The text in your sample file is hidden behind the tiger...

Emmanuel.
--
Emmanuel PACAUD
Groupe Virgo
LAPP - Laboratoire d'Annecy-le-Vieux de physique des particules
9, chemin de Bellevue - BP 110
74941 Annecy-le-Vieux CEDEX
France
T?l: (+33)4 50 09 17 89 - Fax: (+33)4 50 27 94 95
Emmanuel Pacaud
2007-06-29 07:36:52 UTC
Permalink
Post by Kreller, Marcus
I tested the example file also with text-tag at the end of the svg and only with text but nothing
changed.
Have you checked with another renderer (inkscape, batik ...) ?
Post by Kreller, Marcus
Can I compile rsvg-view and rsvg-convert under windows?
I'm not sure about rsvg-view, but rsvg-convert should since it has the
same requirements as the rsvg library.

Emmanuel.
Post by Kreller, Marcus
-----Urspr?ngliche Nachricht-----
Von: Emmanuel Pacaud [mailto:emmanuel.pacaud at lapp.in2p3.fr]
Gesendet: Donnerstag, 28. Juni 2007 14:01
An: Kreller, Marcus
Cc: cairo at cairographics.org
Betreff: Re: AW: [cairo] cairo never render text in svg
I dont now that exist some extra functions/utilities to open SVG and so I dont try rsvg-view or rsvg-convert but I will do this. Can you give me a code example how to use rsvg-view and/or rsvg-convert?
rsvg-view and rsvg-convert are applications included in librsvg, and
should be compiled by default.
The text in your sample file is hidden behind the tiger...
Emmanuel.
--
Emmanuel PACAUD
Groupe Virgo
LAPP - Laboratoire d'Annecy-le-Vieux de physique des particules
9, chemin de Bellevue - BP 110
74941 Annecy-le-Vieux CEDEX
France
T?l: (+33)4 50 09 17 89 - Fax: (+33)4 50 27 94 95
Kreller, Marcus
2007-06-28 11:28:32 UTC
Permalink
Thanks for answer,

I dont now that exist some extra functions/utilities to open SVG and so I dont try rsvg-view or rsvg-convert but I will do this. Can you give me a code example how to use rsvg-view and/or rsvg-convert?

Thats the way I go:

/* Initialize rsvg */
rsvg_init();

/* Open handle for SVG-file */
g_my_svg = rsvg_handle_new_from_file(bufFilename, &pError);
.
/* Create Cairo surface */
cairo_surface_t *cairo_surface = cairo_win32_surface_create(hdc);
cairo_t *cr = cairo_create(cairo_surface);

/* Scale */
.
rsvg_handle_render_cairo(g_my_svg, cr);
.
/* Clean up cairo */
/* Clean up rsvg */



Marcus


-----Urspr?ngliche Nachricht-----
Von: cairo-bounces at cairographics.org [mailto:cairo-bounces at cairographics.org] Im Auftrag von Emmanuel Pacaud
Gesendet: Donnerstag, 28. Juni 2007 11:30
An: Kreller, Marcus
Cc: cairo at cairographics.org
Betreff: Re: [cairo] cairo never render text in svg
Post by Kreller, Marcus
Hi,
for one of my projects in Visual C++ 6.0 under WinXP I render SVGs with
librsvg 2.16.1. These SVGs
<text x="10" y="10" >...</text>
Cairo with librsvg works fine but all redered SVGs displayed without
text. No error or something else.
I put the sources of cairo, librsvg and pango (v 1.16) into my project
to debug someone, but I dont find the reason. I tested my svgs
additional with Firefox and Gimp and here the text was diplayed.
These programs also use cairo+librsvg+pango to picture svgs.
Could you send us a sample file ?
Did you try to render these files with the rsvg-view utility that comes
with librsvg ? Or rsvg-convert ?

Emmanuel.
--
Emmanuel PACAUD
Groupe Virgo
LAPP - Laboratoire d'Annecy-le-Vieux de physique des particules
9, chemin de Bellevue - BP 110
74941 Annecy-le-Vieux CEDEX
France
T?l: (+33)4 50 09 17 89 - Fax: (+33)4 50 27 94 95

_______________________________________________
cairo mailing list
cairo at cairographics.org
http://cairographics.org/cgi-bin/mailman/listinfo/cairo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tiger.svg
Type: application/octet-stream
Size: 97363 bytes
Desc: tiger.svg
Url : http://cairographics.org/archives/cairo/attachments/20070628/bd4d4335/attachment-0001.obj
Loading...