Julian,
Thanks for the quick response. I have tried the scale factor with 0 and
1, actually forgot to change it when sending the snippet. Same result.
I have used the code in example3 successfully, but the rendering isn't
as sharp as what I get with cairo. I am converting some code over that
used another incomplete gerber parsing library and cairo gives me really
nice control of the final output.
I know the surface is declared properly and works because I can write
directly to it, example:
cairo_set_source_rgba (cr, 0,0,0, 1);
cairo_paint (cr);
if I change the RBG values, I get a different color background. What
doesn't seem to be working is the routine:
gerbv_render_layer_to_cairo_target (cr, mainProject->file[i],
&screenRenderInfo);
OR
gerbv_render_all_layers_to_cairo_target (mainProject, cr,
&screenRenderInfo);
Again, any pointers would be helpful. Perhaps I'm not delcaring
something else I need to in screenRenderInfo?
Curtis
On 4/1/2011 11:34 AM, Julian Lamb wrote:
> 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
>> [email protected]
>> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/gerbv-devel