Curtis,
     A couple things....first, you have scale factors set to 0 in your 
snippet.  They will need to be non-zero to show anything (1 is the default).
     Have you looked at using the 
"gerbv_export_png_file_from_project_autoscaled" function?  It's probably 
the preferred method of outputting a PNG file, since it will handle 
scaling the board to fit your PNG resolution.  Look at example3.c in the 
doc/example-code directory within the git tree.  You can avoid ever 
having to deal with raw cairo surfaces using this function.  Hope this 
helps.

Cheers--
Julian

On 04/01/2011 11:26 AM, Curtis C. Pope wrote:
> Does anyone have a working example of using Cairo Rendering to a PNG
> file?  I am converting some existing cairo code and can't seem to get it
> to work.  I get it to create the surface and write the file, but none of
> the layer info is there.  I'm sure its something simple I am missing
> with libgerbv but can't figure it out.
>
> Here is a code snippet:
>
> #include "gerbv.h"
>
> int
> main(int argc, char *argv[]) {
>       /* create a top level libgerbv structure */
>       gerbv_project_t *mainProject = gerbv_create_project();
>       gerbv_render_info_t screenRenderInfo;
>           screenRenderInfo.renderType = GERBV_RENDER_TYPE_CAIRO_HIGH_QUALITY;
>       screenRenderInfo.displayWidth = 1024;
>       screenRenderInfo.displayHeight = 768;
>       screenRenderInfo.scaleFactorX = 0;
>       screenRenderInfo.scaleFactorY = 0;
>
>
>       /* parse my Gerber Files */
>
>       gerbv_open_layer_from_filename (mainProject, "Nixie Tube
> Breakout.GTO");
>       gerbv_open_layer_from_filename (mainProject, "Nixie Tube
> Breakout.GTS");
>       gerbv_open_layer_from_filename (mainProject, "Nixie Tube
> Breakout.TXT");
>       gerbv_open_layer_from_filename (mainProject, "Nixie Tube
> Breakout.GTL");
>
>       /* Invert the Solder Mask Layer */
>       mainProject->file[1]->transform.inverted = TRUE;
>
>       /* Create the Cairo Surface */
>       cairo_surface_t *surface;
>       surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1024, 768);
>          cairo_t *cr = cairo_create (surface);
>
>          /* render all layers using the simple method */
>           gerbv_render_all_layers_to_cairo_target (mainProject, cr,
> &screenRenderInfo);
>
>       /* Write the service to file */
>       cairo_surface_write_to_png(surface, "test.png");
>
>
>          cairo_destroy (cr);
>
>       return 0;
> }
>
> Thanks!
>
>
> ------------------------------------------------------------------------------
> Create and publish websites with WebMatrix
> Use the most popular FREE web apps or write code yourself;
> WebMatrix provides all the features you need to develop and
> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
> _______________________________________________
> Gerbv-devel mailing list
> Gerbv-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gerbv-devel

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Gerbv-devel mailing list
Gerbv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gerbv-devel

Reply via email to