gerbv
example3.c
/*------------------------------------------------------------------------------
Filename: example3.c
Description: Loads example3-input.gbx, duplicates it and offsets it to the
right by the width of the layer, changed the rendered color of the
second image, then exports a PNG rendering of the overlaid images.
Instructions: Make sure you are in the example-code directory, and compile
this program with the following command:
gcc -Wall -g `pkg-config --cflags libgerbv` `pkg-config --libs libgerbv` example3.c -o example3
Run with the following command:
./example3
Common compiling problems:
1. If you are compiling gerbv from source, make sure you run
"make install" before trying to compile this example. This
ensures libgerbv is correctly installed and can be found.
2. If you installed gerbv to "/usr/local" (the default), many
distributions don't correctly point pkgconfig to this target.
To fix this, add the following to your ~/.bashrc file:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/usr/lib/pkgconfig/
------------------------------------------------------------------------------*/
#include "gerbv.h"
int
main(int argc, char *argv[]) {
/* create a top level libgerbv structure */
/* parse a Gerber file and store it in the gerbv_project_t struct, and
then immediately parse a second copy */
/* make sure we parsed the files */
if ((mainProject->file[0] == NULL) || (mainProject->file[1] == NULL))
g_error ("There was an error parsing the files.");
/* translate the second image (file[1]) up and right by 0.02 inches */
/* change the color of the first image (file[0]) to green */
GdkColor greenishColor = {0, 10000, 65000, 10000};
mainProject->file[0]->color = greenishColor;
/* export a rendered PNG image of the project, using the autoscale version
to automatically center the image */
"example3-output.png");
/* destroy the project, which will in turn destroy all child images */
return 0;
}
void gerbv_export_png_file_from_project_autoscaled(gerbv_project_t *gerbvProject, int widthInPixels, int heightInPixels, gchar const *filename)
Render a project to a PNG file, autoscaling the layers to fit inside the specified image dimensions.
Definition: export-image.c:219
void gerbv_destroy_project(gerbv_project_t *gerbvProject)
Free a project and all related variables.
Definition: gerbv.c:207
gerbv_project_t * gerbv_create_project(void)
Create a new project structure and initialize some important variables.
Definition: gerbv.c:190
void gerbv_open_layer_from_filename(gerbv_project_t *gerbvProject, gchar const *filename)
Open a file, parse the contents, and add a new layer to an existing project.
Definition: gerbv.c:242
The main header file for the libgerbv library.
gerbv_project_t * mainProject
Global state variable to keep track of what's happening on the screen.
Definition: main.c:201
gerbv_user_transformation_t transform
Definition: gerbv.h:743
GdkColor color
Definition: gerbv.h:737
gerbv_fileinfo_t ** file
Definition: gerbv.h:752