Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleImageMagickIO.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 /**
27  @example ExampleImageMagickIO.cpp
28  @relates ImageIO
29  @brief How to use the ImageMagick IO routines directly instead of
30  all vailable routines from BIAS::ImageIO::Load
31  @ingroup g_examples
32  @author Jan Woetzel
33 */
34 
35 #include <iostream>
36 
37 #include <Base/Image/ImageBase.hh>
38 #include <Base/Image/Image.hh>
39 #include <Base/Image/ImageIO.hh>
40 
41 #ifndef BIAS_HAVE_IMAGEMAGICKLIB
42 # error BIAS_HAVE_IMAGEMAGICKLIB not defined. Recompile BIAS with ImageMagick
43 #endif
44 
45 
46 using namespace std;
47 using namespace BIAS;
48 
49 void usage(int argc, char** argv)
50 {
51  cerr<<"usage: ";
52  if (argc>0) cerr<<argv[0]<<" <image-filename>"<<endl;
53 }
54 
55 int main(int argc, char** argv)
56 {
57  if (argc!=2) {
58  usage(argc, argv);
59  return 0;
60  };
61 
63  BIASASSERT(argc>1);
64  string filename=argv[1];
65 
66  // BIAS::ImageIO::ImportImage(filename, img);
68 
69  BIAS::ImageIO::ExportMagickPP("out_Magick.png", img);
70  BIAS::ImageIO::ExportMagickPP("out_Magick_default.jpg", img);
71  // BIAS::ImageIO::WriteMagickPP("out_Magick005.jpg", img, 5);
72  // BIAS::ImageIO::WriteMagickPP("out_Magick100.jpg", img, 100);
73 
74  if (BIAS::ImageIO::Save("out_Magick_ExportImage_FF_png.png", img, BIAS::ImageIO::FF_png ) !=BIAS_IO_SUCCESS){
75  BIASERR("an error occurred using ExportImage");
76  };
77 
78  //if (BIAS::ImageIO::Save("out_Magick_Write.mip", img ) !=BIAS_IO_SUCCESS){
79  if (BIAS::ImageIO::Save("out_Magick_Write.mip", img ) !=BIAS_IO_SUCCESS){
80  BIASERR("an error occurred writing mip");
81  };
82 
83  cout<<"done"<<endl;
84  return 0;
85 }
static int ImportMagickPPAutoconvert(const std::string &FileName, ImageBase &result, const bool &assumeGrey=false, const bool &readMetaData=false)
Reads an image from disk using the ImageMagick++ library.
Definition: ImageIO.cpp:1450
static int ExportMagickPP(const std::string &FileName, const ImageBase img, const int &quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool &writeMetaData=false, const bool &forceBinaryPNMformat=true, const bool &losslesJpgMode=false, const bool &writeGZipped=false, const std::string &comment=std::string(""))
Reads an image from disk using the ImageMagick++ library.
Definition: ImageIO.cpp:1652
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
Definition: ImageIO.cpp:725