[cairo] FW: cairo_write_func_t

Pablo Romero romero619 at hotmail.com
Thu Feb 12 09:16:27 PST 2009


apparently, hotmail truncated a bunch of the code I had listed, so Ive attached the source instead.
the write function seems to almost work, since I manage to print the first few bytes, and see "PNG" printed to STDOUT.
 
Im not sure what the "closure" argument is for (libpng documentation says that it can be NULL).
Do I need to include this closure argument?
 
 

----------------------------------------
> From: romero619 at hotmail.com
> To: cairo at cairographics.org
> Date: Thu, 12 Feb 2009 09:10:15 -0800
> Subject: [cairo] cairo_write_func_t
>
>
> hello,
> I need help setting up a write function for cairo_image_surface_write_to_png_stream()
>
> I've set up the following function to print to stdout...
>
>
> cairo_status_t my_stdout_write_fn(void *closure,unsigned char *data,unsigned int lngth){
> unsigned int i;
> printf("png length: %u\n",lngth);
>
> for(i=0;i
> #include
>
> cairo_status_t my_stdout_write_fn(void *closure,unsigned char *data, unsigned int lngth);
>
> int main (int argc, char *argv[])
> {
> cairo_surface_t *surface;
> cairo_t *cr;
>
> surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 200, 200);
> cr = cairo_create (surface);
>
> cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
> cairo_set_font_size (cr, 32.0);
> cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
> cairo_paint(cr);
>
> cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
> cairo_move_to (cr, 10.0, 50.0);
> cairo_show_text (cr, "Hello, world");
>
> cairo_surface_write_to_png_stream (surface,my_stdout_write_fn, NULL);
> cairo_surface_write_to_png(surface,"hello.png");
> return 0;
> }
>
>
> cairo_status_t my_stdout_write_fn(void *closure,unsigned char *data,unsigned int lngth){
> unsigned int i;
> printf("png length: %u\n",lngth);
>
> for(i=0;i
> _________________________________________________________________
> Windows Live™: E-mail. Chat. Share. Get more ways to connect.
> http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_022009
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
_________________________________________________________________
Windows Live™: E-mail. Chat. Share. Get more ways to connect. 
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_022009
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: write_func_test.c
Url: http://lists.cairographics.org/archives/cairo/attachments/20090212/ffffc119/attachment.c 


More information about the cairo mailing list