Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleImageLoad.cpp

Load an arbitrary format from disk trying all availbale libraries.

Author
woetzel
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
@example ExampleImageLoad.cpp
@relates ImageIO
@brief Load an arbitrary format from disk trying all availbale libraries.
@ingroup g_examples
@author woetzel
*/
//#include <Base/Common/LeakChecking.h>
#include <Base/Image/ImageBase.hh>
#include <Base/Image/ImageIO.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
if (argc!=2){
cout<<"no image given\nusage: "<<argv[0]<<" <image-file>"<<endl;
return -1;
}
int result = ImageIO::Load(argv[1], im);
if (result!=0){
BIASERR("error loading \n"<<argv[1]<<" with result="<<result);
return result; // for Dart testing
}
//im.Display("im",true,false,true,1000);
// OK, display some info about the succesfully loaded image:
cout<<"successfully loaded \n"<<argv[1]<<" "<<endl
<<im.GetWidth()<<"x"<<im.GetHeight()<<" pixel, "
<<im.GetChannelCount()<<" channels, "
<<" @"<<im.GetBitDepth()<<"bit ("<<im.GetDepth()<<"Byte)"
<<endl;
cout<<"UID "<<im.GetUID()<<" ";
if (!im.GetUID().IsValid())
cout<<"invalid! ";
else
cout<<"valid ";
if (!im.GetUID().IsNil())
cout<<"(IsNil) ";
cout<<endl;
//if (ImageIO::Save("out_image.mip", im, false, !im.GetUID().IsValid())!=0){
// BIASERR("error writing out_image.mip");
// return 0; // for Dart testing
//}
cout<<"done."<<endl;
return 0;
}