Basic Image AlgorithmS Library 2.8.0

ExampleImageMagickIO.cpp

00001 /* 
00002 This file is part of the BIAS library (Basic ImageAlgorithmS).
00003 
00004 Copyright (C) 2003-2009    (see file CONTACT for details)
00005 Multimediale Systeme der Informationsverarbeitung
00006 Institut fuer Informatik
00007 Christian-Albrechts-Universitaet Kiel
00008 
00009 
00010 BIAS is free software; you can redistribute it and/or modify
00011 it under the terms of the GNU Lesser General Public License as published by
00012 the Free Software Foundation; either version 2.1 of the License, or
00013 (at your option) any later version.
00014 
00015 BIAS is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU Lesser General Public License for more details.
00019 
00020 You should have received a copy of the GNU Lesser General Public License
00021 along with BIAS; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 */
00024 
00025 
00026 /**
00027      @example ExampleImageMagickIO.cpp
00028      @relates ImageIO
00029      @brief How to use the ImageMagick IO routines directly instead of
00030      all vailable routines from BIAS::ImageIO::Load
00031      @ingroup g_examples
00032      @author Jan Woetzel
00033 */
00034 
00035 #include <iostream>
00036 
00037 #include <Base/Image/ImageBase.hh>
00038 #include <Base/Image/Image.hh>
00039 #include <Base/Image/ImageIO.hh>
00040 
00041 #ifndef BIAS_HAVE_IMAGEMAGICKLIB
00042 #  error BIAS_HAVE_IMAGEMAGICKLIB not defined. Recompile BIAS with ImageMagick
00043 #endif
00044 
00045 
00046 using namespace std;
00047 using namespace BIAS;
00048 
00049 void usage(int argc, char** argv)
00050 {
00051   cerr<<"usage: ";
00052   if (argc>0) cerr<<argv[0]<<" <image-filename>"<<endl;
00053 }
00054 
00055 int main(int argc, char** argv)
00056 { 
00057   if (argc!=2) {
00058     usage(argc, argv);
00059     return 0;
00060   };
00061   
00062   BIAS::Image<unsigned char> img;
00063   BIASASSERT(argc>1);
00064   string filename=argv[1];
00065   
00066   // BIAS::ImageIO::ImportImage(filename, img);
00067   BIAS::ImageIO::ImportMagickPPAutoconvert(filename, img);
00068   
00069   BIAS::ImageIO::ExportMagickPP("out_Magick.png", img);
00070   BIAS::ImageIO::ExportMagickPP("out_Magick_default.jpg", img);
00071   // BIAS::ImageIO::WriteMagickPP("out_Magick005.jpg", img, 5);
00072   // BIAS::ImageIO::WriteMagickPP("out_Magick100.jpg", img, 100);
00073   
00074   if (BIAS::ImageIO::Save("out_Magick_ExportImage_FF_png.png", img, BIAS::ImageIO::FF_png ) !=BIAS_IO_SUCCESS){
00075     BIASERR("an error occurred using ExportImage");
00076   };
00077   
00078   //if (BIAS::ImageIO::Save("out_Magick_Write.mip", img ) !=BIAS_IO_SUCCESS){
00079   if (BIAS::ImageIO::Save("out_Magick_Write.mip", img ) !=BIAS_IO_SUCCESS){
00080     BIASERR("an error occurred writing mip");
00081   };  
00082   
00083   cout<<"done"<<endl;
00084   return 0;
00085 }
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends