Tutorial: Create Your First Project
In this tutorial, you will create a C/C++ Windows console application and use ImageGear to load an image, resize it, and convert it to a new raster format.
The following tutorial refers specifically to 64-bit installations. For 32-bit installations, throughout these instructions, substitute x64 with x86.
Using Visual Studio (2015 or later):
- Create a new "Win32 Console Application" project with name "IG_Tutorial_Console".
- Create a new solution platform for platform x64.
- Set the solution configuration to either "Debug|x64" or "Release|x64" and apply the following changes:
- Set Configuration Properties\General\Output Directory to the absolute path to the ImageGear binaries directory.
e.g. [INSTALLDIR]\ImageGear for C and C++ vXX\Build\Bin\x64\
- Modify project setting Configuration Properties\C/C++\General\Additional Include Directories to include the absolute path to ImageGear header files directory.
e.g. [INSTALLDIR]\ImageGear for C and C++ vXX\Build\Include
- Modify project setting Configuration Properties\Linker\General\Additional Library Directories to include the absolute path to ImageGear libraries directory.
e.g. [INSTALLDIR]\ImageGear for C and C++ vXX\Build\Lib\x64
- Modify project setting Configuration Properties\Linker\Input\Additional Library Dependencies to link with the ImageGear CORE component import library, igCOREXXd.lib.
- At this point, your project is ready for some sample code. We will highlight key snippets in the following steps. But first, open the source file, IG_Tutorial_Console.cpp, which Visual Studio created automatically, and replace with the following:
- If you are using a Deployment license (also known as "Runtime" license), then add the license initialization code. This is not necessary if you are using an Evaluation license or Development license (also known as a "Toolkit" license).
- We load the image using:
- We resize the image to 150x150 pixels by defining the width, the height, and the interpolation approach as follows:
- We save the image based on the saveFormat specified:
The majority of ImageGear functions return either an error code, enumIGErrorCodes, or an error count, AT_ERRCOUNT. For brevity, we ignore ImageGear return values in this sample except for saving. This will allow us to indicate that saving was successful with an appropriate message and exit code.
- Finally, release any ImageGear resources before exiting: