Basic Image AlgorithmS Library 2.8.0

ExampleJPEGDecompress.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    @example ExampleJPEGDecompress.cpp
00027    @relates CompressJpeg
00028    @brief Reads a JPEG image from disk and prints image info.
00029    @ingroup g_examples
00030    @author Arne Petersen
00031 */
00032 
00033 //#include <Base/Common/LeakChecking.h>
00034 #include <Base/Image/ImageBase.hh>
00035 #include <Base/Image/ImageIO.hh>
00036 #include <Base/Image/CompressJpeg.hh>
00037 
00038 using namespace BIAS;
00039 using namespace std;
00040 
00041 int main(int argc, char *argv[])
00042 {
00043   if (argc != 2) {
00044     cout << "Usage: " << argv[0] << " <image file>" << endl;
00045     return -1;
00046   }
00047 
00048   int res = 0;
00049   BIAS::Image<unsigned char> image;
00050   JpegHandler jHandler;
00051   jHandler.Init();
00052 
00053   res = jHandler.ReadJPEG(argv[1]);
00054   if (res < 0) {
00055     BIASERR("Reading JPEG failed (returned "<< res <<")!");
00056     return -1;
00057   }
00058   res = jHandler.Decompress(image, true);
00059   if (res < 0) {
00060     BIASERR("Decompression failed (returned "<< res <<")!");
00061     return -1;
00062   }
00063 
00064   cout << "Image size: " << image.GetWidth() << "x"
00065        << image.GetHeight() << endl;
00066   cout << "Channel count: " << image.GetChannelCount() << endl;
00067 
00068   if (image.GetMetaData()) {
00069     cout << "Image metadata:" << endl;
00070     image.GetMetaData()->Dump();
00071   } else {
00072     cout << "No image metadata found." << endl;
00073   }
00074 
00075   return 0;
00076 }
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends