eLynx SDK
v3.3.0 C++ image processing API reference |
eLynx SDK supports loading and saving files easily. It's based on an architecture with plugins for encoding en decoding image file formats.
First you have to register once all plugins:
#include <elx/image/ImageFileManager.h> // relative path where to look for image file format plugins bool bSuccess = the_ImageFileManager.Register(PATH_BASE_PLUGIN); // if there is an assertion here, you've got a problem loading plugins // check pluginsPath path value. // you must have plugin files in relative path from exe : ./plugins/*.elxIFF elxASSERT( bSuccess );
You can have look at Supported Image File Format plugins.
Loading a missing image:
cout << endl << "Load a missing file" << endl; const char * filenameIn = "missing.tif"; cout << "Create an image from file: " << filenameIn; ImageVariant image; bool bSuccess = image.Load(filenameIn); cout << (bSuccess? " successfull" : " failed") << endl; cout << (image.IsValid() ? "VALID" : "INVALID"); cout << ", format " << elxToString( image.GetPixelFormat() ); cout << ", size " << image.GetWidth() << "x" << image.GetHeight() << "-" << image.GetBitsPerPixel() << "bits" << endl;
Output:
Load a missing file Create an image from file: missing.tif failed INVALID, format Undefined, size 0x0-0bits
Loading an image with constructor:
cout << "Load with constructor" << endl; const char * filenameIn = "../../datas/m31.jpg"; cout << "Create an image from file: " << filenameIn << endl; ImageVariant image(filenameIn); cout << (image.IsValid() ? "VALID" : "INVALID"); cout << ", format " << elxToString( image.GetPixelFormat() ); cout << ", size " << image.GetWidth() << "x" << image.GetHeight() << "-" << image.GetBitsPerPixel() << "bits" << endl; const char * filenameOut = "output/m31bis.png"; cout << "Save image with png format: " << filenameOut; bool bSuccess = image.Save(filenameOut); cout << " " << (bSuccess? "successfull" : "failed") << endl;
Output:
Load with constructor Create an image from file: ../../datas/m31.jpg VALID, format RGBub, size 1300x900-24bits Save image with png format: output/m31bis.png successfull