ImageIO.h

Go to the documentation of this file.
00001 // YP  28/01/2005  \Yves120\Include\ImageIO.h
00002 
00003 #define __IMAGEIO_H
00004 
00005 #ifndef __HBITMAP_H
00006 #include "SDK/HBitmap.h"
00007 #endif
00008 
00009 #include "DLLPlugi.h"
00010 
00011 #define IMAGEIODLLVERSION 1
00012 
00013 
00014 class PLUGINEXPORT HOutputInfo {
00015 public:
00016    int         GetTime();
00017    int         GetStartTime();
00018    int         GetEndTime();
00019    int         GetStep();
00020    int         GetFPS();
00021    BOOL        GetIsAudioStereo();
00022    int         GetAudioFrequency();
00023    BOOL        GetIsAlpha();        // User requested that the alpha channel be saved in the file
00024    int         GetGammaPreset();    // One of the Gamma presets, the most characteristic being sRGB (or NTSC)
00025    float       GetOutputGamma();    // Gamma value for image data correction prior to storing to file.
00026    float       GetViewGamma();      // Gamma value of the user display setting
00027    String      GetUser();           // A string containing the user name to store as metadata in output files.
00028    String      GetOrganization();   // A string containing the user organisation (company, institution, etc).
00029    String      GetURL();            // A string containing the user URL (web page).
00030    String      GetEmail();          // A string containing the user email address.
00031    String      GetApplicationID();  // A string containing "Hash Animation:Master vn" where vn is the A:M version number.
00032 };
00033 
00034 
00035 class ImageIOInfo {
00036 public:
00037    union {
00038       ULONG m_flags;
00039       struct {                               // This plugin can :
00040          BOOL  m_candomultiframes      : 1;  // - process (read-write) multiple frames in one single file. QuickTime and AVI can do that. But Gif can too.
00041          BOOL  m_canwrite              : 1;  // - write to file. All plugins must have read from file capability but may not write to file
00042          BOOL  m_haswriteoptions       : 1;  // - Provides a callable Save Options dialog box. Most common are compression settings
00043          BOOL  m_canstorealpha         : 1;  // - store alpha channels with the image data
00044          BOOL  m_canstoresound         : 1;  // - store sound data. Either in same file as images or on separate file.
00045          BOOL  m_canstoremultibuffers  : 1;  // - store multiple buffers. OpenEXR and Jpeg2000 can do that.
00046          BOOL  m_closewrite         : 1;  // - needs to close animation file after saving frames
00047       };
00048    };
00049    String   m_openfilter;     // OpenFile dialog file filter. The format is "|Display string|filter string|Macintosh filetype||"
00050    String   m_savefilter;     // Save dialog file filter. The format is "|Display string|filter string|Macintosh filetype||"
00051    String   m_suffix;         // The prefered or most common file extension. Do not include the dot.
00052    String   m_localizedname;  // The name of the supported file type as displayed in the Render Option drop down list.
00053    String   m_matchname;      // A unique name used to identify the plugin. This name must be unique among plugins and does not contain spaces
00054    String   m_documentation;  // A HTML string describing the plugin and its usage.
00055 };
00056 
00057 // NOTE: A GammaType of GAMMA_NTSC is equivalent to 2.2 but ideally should follow the CIE Rec 709 with a slope of 4.5 below 0.018 and power 0.45 above 0.018
00058 enum GammaType { GAMMA_NONE, GAMMA_MONITOR, GAMMA_NTSC, GAMMA_CRT, GAMMA_CUSTOM };
00059 
00060 class ImageIO : public DLLPlugin {
00061 public:
00062    BOOL m_isopened;
00063    ImageIO() {m_isopened = FALSE;}
00064    ImageIO(HTreeObject *htreeobject) : DLLPlugin(htreeobject) {m_isopened = FALSE;}
00065    
00066    //ImageIO users should call this write and closewrite when done
00067    inline int  Write( HBitmapNode *bn, HOutputInfo *outputinfoconst, const String &filename, short *wavedata, BOOL hasaudio);
00068    inline void CloseWrite(BOOL hasaudio);
00069 
00070    //ImageIO developers should write these
00071    //virtual BOOL Load( BitmapNode &bn, const String &filename ) { return FALSE; }
00072 // virtual char *GetHandleFileType() { return NULL; }
00073    virtual BOOL CanLoadImage( const String &filename ) { return FALSE; }
00074    virtual void GetFilesStartEndFrame( const String &filename, int &start, int &end) { start = -1; end = -2; }
00075    virtual BOOL SetSaveOptions(CWnd *parent, const String &extension, float fps) { return FALSE; }
00076    virtual BOOL GetImageIOInfo(ImageIOInfo &iioinfo) { return FALSE; }
00077    virtual int  OpenWriteFrame( String filename, HBitmapNode *bn, HOutputInfo *outputinfo, BOOL hasaudio ) { return 0; }
00078    virtual int  WriteFrame( HBitmapNode *bn, HOutputInfo *outputinfo, const String &filename, short *wavedata, BOOL hasaudio) {return HBitmapNode::WRITE_NORESULT;}
00079    virtual void CloseWriteFrame( BOOL hasaudio) {}
00080    virtual int  LoadFrame( HBitmapNode *bn, const String &filename, int frame=-1, UINT flags = 0 ) { return HBitmapNode::LOAD_FAILED; }
00081    virtual int  IsFileOpen() { return FALSE; }
00082    /*
00083    virtual BOOL Save( const String &filename, const BitmapNode &bn ) { return FALSE; }
00084    virtual BOOL Save( const String &filename, const BitmapBuffer &buffer ) { return FALSE; }
00085    virtual BOOL SaveAs( const BitmapNode &bn ) { return FALSE; }
00086    virtual BOOL SaveAs( const BitmapBuffer &buffer ) { return FALSE; }
00087    */
00088 };
00089 
00090 int ImageIO::Write( HBitmapNode *bn, HOutputInfo *outputinfo, const String &filename, short *wavedata, BOOL hasaudio)
00091 {
00092    //always call this one so it calls OpenWriteFrame
00093    int rvalue;
00094    try {
00095       if (!m_isopened) {
00096          rvalue = OpenWriteFrame( filename, bn, outputinfo, hasaudio );
00097          if (rvalue == HBitmapNode::WRITE_ERROR)
00098             return rvalue;
00099          m_isopened = TRUE;
00100       }
00101       return WriteFrame( bn, outputinfo, filename, wavedata, hasaudio);
00102    }
00103 #ifndef _DEBUG
00104    catch (...) {
00105       /*String err = "Unhandled exception in the \"%1\" image io plugin.";
00106       //err.Replace("%1", GetClassName());
00107       MessageRequest(err);*/
00108       CString err;
00109       err.Format("Unhandled exception in the \"%s\" image io plugin.", GetClassName());
00110       AfxMessageBox( err, MB_OK );
00111 #ifdef DEBUG
00112       throw;
00113 #endif
00114    }
00115 #else
00116    catch (ImageIO e){} //an exception that won't be thrown to help find errors when debugging
00117 #endif
00118    return HBitmapNode::WRITE_ERROR;
00119 }
00120 
00121 void ImageIO::CloseWrite(BOOL hasaudio)
00122 {
00123    if (m_isopened)
00124       CloseWriteFrame(hasaudio);
00125    m_isopened = FALSE;
00126 }

This A:M SDK v12.0 documentation is maintained by Hash Inc. Please address any comments concerning this documentation to AMReports. If you have any information, knowledge, or documentation to share with the A:M developer community, please post them on the Hash SDK forum.

Generated on Thu Oct 27 11:46:44 2005 with doxygen 1.4.5 written by Dimitri van Heesch, © 1997-2001