00001 /* 00002 This file is part of the CVD Library. 00003 00004 Copyright (C) 2005 The Authors 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 00019 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 #ifndef PNM_SAVE_POSTSCRIPT_H 00022 #define PNM_SAVE_POSTSCRIPT_H 00023 00024 #include <iostream> 00025 #include <string> 00026 #include <memory> 00027 #include <cvd/image.h> 00028 #include <cvd/byte.h> 00029 #include <cvd/rgb.h> 00030 #include <cvd/internal/convert_pixel_types.h> 00031 #include <cvd/internal/io/parameter.h> 00032 00033 namespace CVD 00034 { 00035 namespace PS 00036 { 00037 00038 class WritePimpl; 00039 00040 00041 class writer 00042 { 00043 public: 00044 writer(std::ostream&, ImageRef size, const std::string& type, const std::map<std::string, Parameter<> >& p); 00045 ~writer(); 00046 00047 void write_raw_pixel_line(const byte*); 00048 void write_raw_pixel_line(const Rgb<byte>*); 00049 00050 template<class Incoming> struct Outgoing 00051 { 00052 typedef byte type; 00053 }; 00054 00055 protected: 00056 std::auto_ptr<WritePimpl> t; 00057 }; 00058 00059 template<class C> struct writer::Outgoing<Rgb<C> > 00060 { 00061 typedef Rgb<byte> type; 00062 }; 00063 00064 00065 template<class C> struct writer::Outgoing<Rgba<C> > 00066 { 00067 typedef Rgb<byte> type; 00068 }; 00069 00070 template<> struct writer::Outgoing<Rgb8> 00071 { 00072 typedef Rgb<byte> type; 00073 }; 00074 00075 00076 class eps_writer 00077 { 00078 public: 00079 eps_writer(std::ostream&, ImageRef size, const std::string& type, const std::map<std::string, Parameter<> >& p); 00080 ~eps_writer(); 00081 00082 void write_raw_pixel_line(const byte*); 00083 void write_raw_pixel_line(const Rgb<byte>*); 00084 00085 template<class Incoming> struct Outgoing 00086 { 00087 typedef typename writer::Outgoing<Incoming>::type type; 00088 }; 00089 00090 protected: 00091 std::auto_ptr<WritePimpl> t; 00092 }; 00093 00094 } 00095 } 00096 #endif 00097