1 /* 2 * helpere.hpp -- help encoding images 3 * by pts@fazekas.hu at Tue Dec 9 10:53:21 CET 2003 4 */ 5 6 /* Don't use this here, because we don't have helpere.cpp 7 #ifdef __GNUC__ 8 #ifndef __clang__ 9 #pragma interface 10 #endif 11 #endif 12 */ 13 14 #ifndef HELPERE_HPP 15 #define HELPERE_HPP 1 16 17 #include "image.hpp" 18 #include "error.hpp" 19 #include "gensio.hpp" 20 21 /** Ugly multiple inheritance. !! unify with PNG, TIFF etc. */ 22 class HelperE: public Filter::NullE, public Filter::PipeE { 23 public: HelperE(char const * filter_cmd,char const * mainfn=NULL)24 inline HelperE(char const*filter_cmd, char const*mainfn=NULL): Filter::NullE(), Filter::PipeE(*(Filter::NullE*)this, filter_cmd, (slendiff_t)mainfn) { 25 /* ^^^ (slendiff_t) is unsafe cast */ 26 // GenBuffer::Writable &out_, char *pipe_tmpl, slendiff_t i=0) 27 } vi_copy(FILE * f)28 inline virtual void vi_copy(FILE *f) { 29 // img=Image::load("-", SimBuffer::B(), (Image::filep_t)f, (char const*)"PNM"); 30 Filter::UngetFILED ufd((char const*)NULLP, f, Filter::UngetFILED::CM_closep|Filter::UngetFILED::CM_keep_stdinp); 31 img=Image::load((Image::Loader::UFD*)(long)&ufd, SimBuffer::B(), (char const*)"PNM"); 32 /* We must close f, this is part of the vi_copy contract. If we fail to 33 * close it, cleanup_remove won't be able to remove the tmp files at 34 * Error::runCleanups() time. 35 */ 36 fclose(f); 37 } getImg() const38 inline Image::Sampled *getImg() const { return img; } 39 protected: 40 Image::Sampled *img; 41 }; 42 43 #endif 44