|
The very first thing you should do is to download the bits and build NGI. See How to Build NGI for more information about this. Then you are ready to explore the samples that are located in the ./samples/console directory. Most samples try to load images and they expect them to be in the ./images directory. The build process expands the images there. Make sure that the NGI_IMAGE_PATH environment variable points to this directory, so that the code can find the images.
All the samples come with sourcecode that you can read in order to understand what is going on.
Here is an example that should get you started with coding:
#include <ngi_l1_display_image.h> #include <ngi_l1_buffer_base.h> #include <ngi_l1_import_image.h> #include <ngi_l1_view.h> // use everything from namespace ngi without explicit qualification using namespace ngi; typedef buffer_base<unsigned char> image_type; typedef locator<image_type::iterator> locator_type; typedef view<locator_type> view_type; typedef widget_image<view_type> widget_type; typedef display_image<widget_type>::type display_type; int main(int argc, char* argv[]) { // load an image image_type img = import_image<image_type>("fish.pgm"); // open a window that contains the image display_type wnd( view_type(img), ngi::vector<int>(img.get_width(), img.get_height()), display_type::center, "Fish"); // run the Windows message loop to make the windows appear and // functional run_message_loop(); return 0; }
When run, this sample loads an image and displays it in a window. The sample quits when you either press the space bar while the image window has the focus, or close the image window with the close button. If this code does not appear to work, please check that the file "fish.pgm" could be found. The file "fish.pgm" is in the ./images directory (but only after the build process has expanded it), and this directory should be referenced by the NGI_IMAGE_PATH environment variable.
NGI comes with documentation that is created from source files by the build process. Thus, the documentation is only there if you have run the build. There is introductory, tutorial and conceptual information in the ./book/ngiBook/output directory, in HTML, HTMLHelp and PDF formats. There is reference documentation in the ./reference/generated/html directory.
NGI is supplied with full source code, and it is heavily documented. You can have a look at the files in the ./include directory in order to understand more about NGI.
Have fun!
|