next up previous contents
Next: 4. VImage operations Up: 3. The VImage class Previous: 3.7 Type conversions   Contents

3.8 Example

Here is an example of a simple function in C and in C++. Figure 3.1 shows the example from section 5 of the VIPS Application Programmers' Guide, and figure 3.2 shows the same function in C++.

This example is supposed to show a lot of operations joined together -- it is not actually very useful, nor the most efficient way to code up this problem. There's im_lintra_vec() which does exactly this much more quickly.

Figure 3.1: apply_factors function in C
\begin{figure}\begin{quote}
\begin{verbatim}/* Apply a scale and offset to eac...
...t, 3 ) )
return( -1 );return( 0 );
}\end{verbatim}
\end{quote}
\end{figure}

Figure 3.2: apply_factors function in C++
\begin{figure}\begin{quote}
\begin{verbatim}/* Apply a scale and offset to eac...
...bandjoin( green2 ).bandjoin( blue2 ) );
}\end{verbatim}
\end{quote}
\end{figure}


John Cupitt 2005-04-11