|
degate 0.1.1
|
00001 /* -*-c++-*- 00002 00003 This file is part of the IC reverse engineering tool degate. 00004 00005 Copyright 2008, 2009, 2010 by Martin Schobert 00006 00007 Degate is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 any later version. 00011 00012 Degate is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with degate. If not, see <http://www.gnu.org/licenses/>. 00019 00020 */ 00021 00022 #ifndef __IPIMAGEWRITER_H__ 00023 #define __IPIMAGEWRITER_H__ 00024 00025 #include <string> 00026 #include <ImageProcessorBase.h> 00027 #include <ImageHelper.h> 00028 00029 namespace degate { 00030 00031 /** 00032 * Processor: Write an image to file. 00033 */ 00034 00035 template<typename ImageType> 00036 class IPImageWriter : public ImageProcessorBase { 00037 00038 private: 00039 std::string filename; 00040 00041 public: 00042 00043 /** 00044 * The constructor. 00045 */ 00046 00047 IPImageWriter(std::string _filename) : 00048 ImageProcessorBase("IPImageWriter", 00049 "Write an image.", 00050 false, 00051 typeid(typename ImageType::pixel_type), 00052 typeid(typename ImageType::pixel_type)), 00053 filename(_filename) { } 00054 00055 /** 00056 * The destructor. 00057 */ 00058 00059 virtual ~IPImageWriter() {} 00060 00061 virtual ImageBase_shptr run(ImageBase_shptr _in) { 00062 00063 assert(_in != NULL); 00064 00065 std::tr1::shared_ptr<ImageType> img_in = 00066 std::tr1::dynamic_pointer_cast<ImageType>(_in); 00067 00068 00069 std::tr1::shared_ptr<ImageType> 00070 img_out(new ImageType(_in->get_width(), _in->get_height())); 00071 00072 assert(img_in != NULL); 00073 assert(img_out != NULL); 00074 00075 std::cout << "writing file: " << filename << std::endl; 00076 00077 normalize<ImageType, ImageType>(img_out, img_in, 0, 255); 00078 00079 save_image<ImageType>(filename, img_out); 00080 00081 return img_in; 00082 } 00083 00084 00085 }; 00086 00087 } 00088 00089 #endif 00090
1.7.4