gerbvhtdocs/doxygen/example2_8c-example.html

83 lines
6.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>gerbv: example2.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="dirs.html"><span>Directories</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>example2.c</h1><div class="fragment"><pre class="fragment"><span class="comment">/*------------------------------------------------------------------------------</span>
<span class="comment"> Filename: example2.c</span>
<span class="comment"> </span>
<span class="comment"> Description: Loads example2-input.gbx, duplicates it and offsets it to the</span>
<span class="comment"> right by the width of the layer, merges the two images, and exports</span>
<span class="comment"> the merged image back to another RS274X file. Note: this example</span>
<span class="comment"> code uses the gerbv_image_t interface as opposed to the</span>
<span class="comment"> gerb_project_t interface.</span>
<span class="comment"></span>
<span class="comment"> Instructions: Make sure you are in the example-code directory, and compile</span>
<span class="comment"> this program with the following command:</span>
<span class="comment"></span>
<span class="comment"> gcc -Wall -g `pkg-config --cflags gtk+-2.0 glib-2.0 libgerbv` `pkg-config \</span>
<span class="comment">--libs gtk+-2.0 glib-2.0 libgerbv` example2.c -o example2</span>
<span class="comment"></span>
<span class="comment"> Run with the following command:</span>
<span class="comment"> </span>
<span class="comment"> ./example2</span>
<span class="comment"></span>
<span class="comment">------------------------------------------------------------------------------*/</span>
<span class="preprocessor">#include "<a class="code" href="gerbv_8h.html" title="The main header file for the libgerbv library.">gerbv.h</a>"</span>
<span class="keywordtype">int</span>
main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) {
<a name="_a0"></a><a class="code" href="structgerbv__image__t.html">gerbv_image_t</a> *originalImage, *duplicatedImage;
<span class="comment">/* parse and create the first image (by default, the image will not be</span>
<span class="comment"> offset and will be in its true position */</span>
originalImage = <a name="a1"></a><a class="code" href="gerbv_8c.html#58e7e7e29c445f965db9a142af542931" title="Parse a RS274X file and return the parsed image.">gerbv_create_rs274x_image_from_filename</a> (<span class="stringliteral">"example2-input.gbx"</span>);
<span class="comment">/* make sure we parsed the file */</span>
<span class="keywordflow">if</span> (originalImage == NULL)
g_error (<span class="stringliteral">"There was an error parsing the file."</span>);
<span class="comment">/* duplicate the image and place it into a new gerbv_image_t */</span>
duplicatedImage = <a name="a2"></a><a class="code" href="gerb__image_8c.html#dc5939e771877c0a4f62427b0a63bf64" title="Duplicate an existing image and return the new copy.">gerbv_image_duplicate_image</a> (originalImage, NULL);
<span class="comment">/* create a transormation for the second image, and offset it the width</span>
<span class="comment"> of the first image in the x direction */</span>
<a name="_a3"></a><a class="code" href="structgerbv__user__transformation__t.html">gerbv_user_transformation_t</a> newTransformation = {originalImage-&gt;<a name="a4"></a><a class="code" href="structgerbv__image__t.html#ee14513fd6f516dc355948f49a10375c">info</a>-&gt;<a name="a5"></a><a class="code" href="structgerbv__image__info.html#07aaa71dfb30b7a1c3e88ce75af66800">max_x</a> -
originalImage-&gt;<a class="code" href="structgerbv__image__t.html#ee14513fd6f516dc355948f49a10375c">info</a>-&gt;<a name="a6"></a><a class="code" href="structgerbv__image__info.html#0fad6186a591051fbba6e0a7edf48f35">min_x</a>,
0, 0, 0, FALSE};
<span class="comment">/* merge the duplicated image onto the original image, but use the new</span>
<span class="comment"> offset to move the new copy to the right */</span>
<a name="a7"></a><a class="code" href="gerb__image_8c.html#8cd82de2992fbdc1b44b8fb1963214c9" title="Copy an image into an existing image, effectively merging the two together.">gerbv_image_copy_image</a> (duplicatedImage, &amp;newTransformation, originalImage);
<span class="comment">/* export the merged image to a new rs274x file */</span>
<a name="a8"></a><a class="code" href="export-rs274x_8c.html#49e264bfff8ce4ae783c173b48bba31d" title="Export an image to a new file in RS274X format.">gerbv_export_rs274x_file_from_image</a> (<span class="stringliteral">"example2-output.gbx"</span>, originalImage);
<span class="comment">/* destroy all created structures */</span>
<a name="a9"></a><a class="code" href="gerb__image_8c.html#2394060b1868594b1ae8b8edcca793e9" title="Free an image structure.">gerbv_destroy_image</a> (originalImage);
<a class="code" href="gerb__image_8c.html#2394060b1868594b1ae8b8edcca793e9" title="Free an image structure.">gerbv_destroy_image</a> (duplicatedImage);
<span class="keywordflow">return</span> 0;
}
</pre></div> </div>
<hr size="1"><address style="text-align: right;"><small>Generated on Tue Aug 19 00:14:47 2008 for gerbv by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>