[prev in list] [next in list] [prev in thread] [next in thread]
List: cairo
Subject: [cairo] Question regarding recording surfaces
From: Zoltán Turányi <teknos () gmail ! com>
Date: 2011-02-25 16:26:09
Message-ID: AANLkTikGD82X1DDbsJs_Dw5_6qnjN6yNRkyJ-KKCshXa () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi,
I plan to use recording surfaces to create a drawing and then replay it into
a window using different scaling factors (as the user zooms in). I read the
documentation and it seems to say that recording surfaces record the
high-level drawing commands - from which I would expect a high resolution
output if replayed on a high resolution target surface (appropriate scaling
applied to the context onto which it is being replayed).
I do not seem to be able to get this behaviour. In the below code I draw
some text and I replay it onto a PNG surface with 2x magnification. Yet the
text and line comes out as blurred - as if it were already rendered to some
bitmap on the recording surface (instead of just being recorded as a
show_text and a stroke). (See attachment.)
Is this something fundamental or am I doing something wrong?
As an additional comment: if I create the recording surface with no extents
given (NULL), the text and line does not replay onto the target surface at
all. Any hints on why?
Thanks in advance,
Zoltan
[Attachment #5 (text/html)]
<div>Hi,</div><div>=C2=A0</div><div>I plan to use recording surfaces to cre=
ate a drawing and then replay it into a window using different scaling fact=
ors (as the user zooms in). I read the documentation and it seems to say th=
at recording surfaces record the high-level drawing commands - from which I=
would expect a high resolution output if replayed on a high resolution tar=
get surface (appropriate scaling applied to the context onto which it is be=
ing replayed).</div>
<div>=C2=A0</div><div>I do not seem to be able to get this behaviour. In th=
e below code I draw some text and I replay it onto a PNG surface with 2x ma=
gnification. Yet the text and line comes out as blurred - as if it were alr=
eady rendered to some bitmap on the recording surface (instead of just bein=
g recorded as a show_text and a stroke). (See attachment.)</div>
<div>=C2=A0</div><div>Is this something fundamental or am I doing something=
wrong?</div><div>=C2=A0</div><div>As an additional comment: if I create th=
e recording surface with no extents given (NULL), the text and line does no=
t replay onto the target surface at all. Any hints on why?</div>
<div>=C2=A0</div><div>Thanks in advance,</div><div>Zoltan</div><div>=C2=A0<=
/div>
--0015174479eaa2ac94049d1dc9f9--
["result.png" (image/png)]
["test.c" (text/x-csrc)]
#include "cairo.h"
#include "stdio.h"
cairo_status_t write_func(void * closure, const unsigned char *data, unsigned length)
{
if (closure==NULL) return CAIRO_STATUS_SUCCESS;
if (length == fwrite(data, 1, length, (FILE*)closure))
return CAIRO_STATUS_SUCCESS;
else
return CAIRO_STATUS_WRITE_ERROR;
}
int main()
{
//Create recorded surface with text
cairo_rectangle_t ext = {0, 0, 100, 100};
cairo_surface_t *recording = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &ext);
cairo_t *cr = cairo_create(recording);
cairo_move_to(cr, 10, 20);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_show_text(cr, "Text - Recorded");
cairo_stroke(cr);
cairo_destroy(cr);
//Create target surface
cairo_surface_t *target = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 200, 200);
cr = cairo_create(target);
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_rectangle(cr, 0, 0, 200, 200);
cairo_fill(cr);
//Scale x2
cairo_scale(cr, 2, 2);
//Replay recorded surface
cairo_set_source_surface (cr, recording, 0.0, 0.0);
cairo_paint (cr);
//Draw text for comparison
cairo_move_to(cr, 10, 40);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_show_text(cr, "Text - Direct");
cairo_stroke(cr);
//Clean up, write file
cairo_destroy (cr);
FILE *file = fopen("result.png", "wb");
cairo_surface_write_to_png_stream (target, write_func, file);
cairo_surface_destroy(target);
fclose(file);
}
--
cairo mailing list
cairo@cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic