<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
Thank you for your email. The code I provided is just a sample. I need to show<br>connections between a number of coordinates; so, in the real scenario the output file<br>should display various lines.<br><br>The stroke() invoked on every 1000000th line produces the pdf file (otherwise, only one<br>stroke at the end will not produce the pdf file). I know this because the size of the output <br>file is around 100MB (otherwise, around 400kb). Clearly, I have problems displaying this<br>file.<br><br>As the way to get around this problem was to output PNG file, with the same strategy of<br>invoking stroke() on every 1000000th line. The code I sent (for PNG files) spends *very*<br>long time on each stroke() invoked.<br><br>Therefore, I wonder whether there is a way to get the png output with this large number of connections.<br>I tried to use similar strategy as with pdf files, but it is very time consuming.<br>Perhaps you could try to invoke the code; <br><br>#include <cairo.h><br>#include <cairo-pdf.h><br>#include
<sstream><br>#include <cmath> <br>#include <vector>
<br>#include <limits.h><br>#include <queue><br>#include
<algorithm><br>#include <numeric><br>#include
<iostream><br>int main() {<br> cairo_surface_t *surface;<br>
cairo_t *cr;<br><br> std::stringstream myOut; int k=1;<br>
//myOut<<"forGallery"<<k<< ".pdf";<br> //surface =
cairo_pdf_surface_create(myOut.str().c_str(), 1432, 1606);<br> surface
= cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1432, 1606);<br>
//surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, 1432, 1606);<br>
//surface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1432, 1606);<br>
//surface = cairo_image_surface_create(CAIRO_FORMAT_A1, 1432, 1606);<br>
cr = cairo_create(surface);<br> <br> //cairo_set_source_rgb(cr, 1, 1,
1);<br> //cairo_paint(cr);<br> //cairo_set_source_rgb(cr, 0, 0, 0);<br>
<br> cairo_translate (cr, -229770, 26573.7); // -40, 50: for margin
-37, 53<br><br> unsigned int t=0; unsigned int ITER_NO=20000000;<br>
while(t<ITER_NO) {<br> cairo_move_to (cr, 229770, -26573.7);<br>
cairo_line_to (cr, 231202, -24967.3);<br> if(t%1000000==0 ||
t==ITER_NO-1) {<br> cairo_stroke(cr);<br> }<br>
std::cout<<"Drawn so
far:"<<((double)t/(double)ITER_NO)*100<<"%"<<std::endl;<br>
++t;<br> }<br> <br> //cairo_show_page(cr); // for PDF<br>
cairo_surface_write_to_png(surface, "image.png"); // for PNG<br>
cairo_surface_destroy(surface);<br> cairo_destroy(cr);<br><br> return
0;<br><br>}<br><br>Thanks<br><br>> Date: Mon, 30 Aug 2010 18:35:44 +0200<br>> Subject: Re: [cairo] Very large number of lines<br>> From: ranma42@gmail.com<br>> To: opustenom@hotmail.com<br>> CC: a.g.nienhuis@gmail.com; cairo@cairographics.org<br>> <br>> On Mon, Aug 30, 2010 at 2:08 PM, necko necko <opustenom@hotmail.com> wrote:<br>> > Thank you for your email. I applied your approach of stoke() every Nth line<br>> > (but I take N=1000000 instead of 1000;<br>> > if you think it would be better to use smaller stride (N=1000), please let<br>> > me know).<br>> > This approach outputs the pdf file of size 1.5 MB, but the machine is still<br>> > trying to display it. I hope it will display<br>> > that single line. Did Evince display the pdf file properly at your machine?<br>> Please notice that you are testing a *very* degenerate case (all your<br>> segments overlap<br>> exactly) that triggers a slow path in cairo rasterizer. Please use<br>> real segment data.<br>> You might probably also want to check if all those strokes are actually needed.<br>> What are you trying to render?<br>> Andrea<br>                                            </body>
</html>