www.pudn.com > vcmatlab20060426WaterMark.zip > imfinfo.cpp


// 
// MATLAB Compiler: 2.2 
// Date: Tue May 10 11:47:30 2005 
// Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on" 
// "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O" 
// "array_indexing:on" "-O" "optimize_conditionals:on" "-B" "sglcpp" "-p" "-W" 
// "main" "-L" "Cpp" "-t" "-T" "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg" 
// "libmwsglm.mlib" "huatu"  
// 
#include "imfinfo.hpp" 
#include "iofun_private_imbmpinfo.hpp" 
#include "iofun_private_imcurinfo.hpp" 
#include "iofun_private_imftype.hpp" 
#include "iofun_private_imgifinfo.hpp" 
#include "iofun_private_imhdfinfo.hpp" 
#include "iofun_private_imicoinfo.hpp" 
#include "iofun_private_imjpginfo.hpp" 
#include "iofun_private_impcxinfo.hpp" 
#include "iofun_private_impnginfo.hpp" 
#include "iofun_private_imtifinfo.hpp" 
#include "iofun_private_imxwdinfo.hpp" 
#include "libmatlbm.hpp" 
#include "libmmfile.hpp" 
 
static mxChar _array1_[132] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ', 
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i', 
                                'l', 'e', ':', ' ', 'i', 'm', 'f', 'i', 'n', 
                                'f', 'o', ' ', 'L', 'i', 'n', 'e', ':', ' ', 
                                '1', ' ', 'C', 'o', 'l', 'u', 'm', 'n', ':', 
                                ' ', '1', ' ', 'T', 'h', 'e', ' ', 'f', 'u', 
                                'n', 'c', 't', 'i', 'o', 'n', ' ', '"', 'i', 
                                'm', 'f', 'i', 'n', 'f', 'o', '"', ' ', 'w', 
                                'a', 's', ' ', 'c', 'a', 'l', 'l', 'e', 'd', 
                                ' ', 'w', 'i', 't', 'h', ' ', 'm', 'o', 'r', 
                                'e', ' ', 't', 'h', 'a', 'n', ' ', 't', 'h', 
                                'e', ' ', 'd', 'e', 'c', 'l', 'a', 'r', 'e', 
                                'd', ' ', 'n', 'u', 'm', 'b', 'e', 'r', ' ', 
                                'o', 'f', ' ', 'o', 'u', 't', 'p', 'u', 't', 
                                's', ' ', '(', '2', ')', '.' }; 
static mwArray _mxarray0_ = mclInitializeString(132, _array1_); 
 
static mxChar _array3_[131] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ', 
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i', 
                                'l', 'e', ':', ' ', 'i', 'm', 'f', 'i', 'n', 
                                'f', 'o', ' ', 'L', 'i', 'n', 'e', ':', ' ', 
                                '1', ' ', 'C', 'o', 'l', 'u', 'm', 'n', ':', 
                                ' ', '1', ' ', 'T', 'h', 'e', ' ', 'f', 'u', 
                                'n', 'c', 't', 'i', 'o', 'n', ' ', '"', 'i', 
                                'm', 'f', 'i', 'n', 'f', 'o', '"', ' ', 'w', 
                                'a', 's', ' ', 'c', 'a', 'l', 'l', 'e', 'd', 
                                ' ', 'w', 'i', 't', 'h', ' ', 'm', 'o', 'r', 
                                'e', ' ', 't', 'h', 'a', 'n', ' ', 't', 'h', 
                                'e', ' ', 'd', 'e', 'c', 'l', 'a', 'r', 'e', 
                                'd', ' ', 'n', 'u', 'm', 'b', 'e', 'r', ' ', 
                                'o', 'f', ' ', 'i', 'n', 'p', 'u', 't', 's', 
                                ' ', '(', '2', ')', '.' }; 
static mwArray _mxarray2_ = mclInitializeString(131, _array3_); 
static mwArray _mxarray4_ = mclInitializeDouble(1.0); 
static mwArray _mxarray5_ = mclInitializeDouble(2.0); 
static mwArray _mxarray6_ = mclInitializeDoubleVector(0, 0, (double *)NULL); 
static mwArray _mxarray7_ = mclInitializeCharVector(0, 0, (mxChar *)NULL); 
 
static mxChar _array9_[1] = { 'r' }; 
static mwArray _mxarray8_ = mclInitializeString(1, _array9_); 
static mwArray _mxarray10_ = mclInitializeDouble(-1.0); 
 
static mxChar _array12_[36] = { 'U', 'n', 'a', 'b', 'l', 'e', ' ', 't', 'o', 
                                ' ', 'o', 'p', 'e', 'n', ' ', 'f', 'i', 'l', 
                                'e', ' ', '"', '%', 's', '"', ' ', 'f', 'o', 
                                'r', ' ', 'r', 'e', 'a', 'd', 'i', 'n', 'g' }; 
static mwArray _mxarray11_ = mclInitializeString(36, _array12_); 
 
static mxChar _array14_[31] = { 'U', 'n', 'a', 'b', 'l', 'e', ' ', 't', 
                                'o', ' ', 'd', 'e', 't', 'e', 'r', 'm', 
                                'i', 'n', 'e', ' ', 'f', 'i', 'l', 'e', 
                                ' ', 'f', 'o', 'r', 'm', 'a', 't' }; 
static mwArray _mxarray13_ = mclInitializeString(31, _array14_); 
 
static mxChar _array16_[4] = { 't', 'i', 'f', 'f' }; 
static mwArray _mxarray15_ = mclInitializeString(4, _array16_); 
 
static mxChar _array18_[3] = { 't', 'i', 'f' }; 
static mwArray _mxarray17_ = mclInitializeString(3, _array18_); 
 
static mxChar _array20_[4] = { 'j', 'p', 'e', 'g' }; 
static mwArray _mxarray19_ = mclInitializeString(4, _array20_); 
 
static mxChar _array22_[3] = { 'j', 'p', 'g' }; 
static mwArray _mxarray21_ = mclInitializeString(3, _array22_); 
 
static mxChar _array24_[3] = { 'h', 'd', 'f' }; 
static mwArray _mxarray23_ = mclInitializeString(3, _array24_); 
 
static mxChar _array26_[4] = { '.', 'h', 'd', 'f' }; 
static mwArray _mxarray25_ = mclInitializeString(4, _array26_); 
 
static mxChar _array28_[3] = { 'b', 'm', 'p' }; 
static mwArray _mxarray27_ = mclInitializeString(3, _array28_); 
 
static mxChar _array30_[4] = { '.', 'b', 'm', 'p' }; 
static mwArray _mxarray29_ = mclInitializeString(4, _array30_); 
 
static mxChar _array32_[3] = { 'p', 'c', 'x' }; 
static mwArray _mxarray31_ = mclInitializeString(3, _array32_); 
 
static mxChar _array34_[4] = { '.', 'p', 'c', 'x' }; 
static mwArray _mxarray33_ = mclInitializeString(4, _array34_); 
 
static mxChar _array36_[3] = { 'x', 'w', 'd' }; 
static mwArray _mxarray35_ = mclInitializeString(3, _array36_); 
 
static mxChar _array38_[4] = { '.', 'x', 'w', 'd' }; 
static mwArray _mxarray37_ = mclInitializeString(4, _array38_); 
 
static mxChar _array40_[3] = { 'p', 'n', 'g' }; 
static mwArray _mxarray39_ = mclInitializeString(3, _array40_); 
 
static mxChar _array42_[4] = { '.', 'p', 'n', 'g' }; 
static mwArray _mxarray41_ = mclInitializeString(4, _array42_); 
 
static mxChar _array44_[3] = { 'g', 'i', 'f' }; 
static mwArray _mxarray43_ = mclInitializeString(3, _array44_); 
 
static mxChar _array46_[4] = { '.', 'g', 'i', 'f' }; 
static mwArray _mxarray45_ = mclInitializeString(4, _array46_); 
 
static mxChar _array48_[4] = { '.', 'j', 'p', 'g' }; 
static mwArray _mxarray47_ = mclInitializeString(4, _array48_); 
 
static mxChar _array50_[5] = { '.', 'j', 'p', 'e', 'g' }; 
static mwArray _mxarray49_ = mclInitializeString(5, _array50_); 
 
static mxChar _array52_[4] = { '.', 't', 'i', 'f' }; 
static mwArray _mxarray51_ = mclInitializeString(4, _array52_); 
 
static mxChar _array54_[5] = { '.', 't', 'i', 'f', 'f' }; 
static mwArray _mxarray53_ = mclInitializeString(5, _array54_); 
 
static mxChar _array56_[3] = { 'i', 'c', 'o' }; 
static mwArray _mxarray55_ = mclInitializeString(3, _array56_); 
 
static mxChar _array58_[4] = { '.', 'i', 'c', 'o' }; 
static mwArray _mxarray57_ = mclInitializeString(4, _array58_); 
 
static mxChar _array60_[3] = { 'c', 'u', 'r' }; 
static mwArray _mxarray59_ = mclInitializeString(3, _array60_); 
 
static mxChar _array62_[4] = { '.', 'c', 'u', 'r' }; 
static mwArray _mxarray61_ = mclInitializeString(4, _array62_); 
 
static mxChar _array64_[39] = { 'U', 'n', 'r', 'e', 'c', 'o', 'g', 'n', 
                                'i', 'z', 'e', 'd', ' ', 'o', 'r', ' ', 
                                'u', 'n', 's', 'u', 'p', 'p', 'o', 'r', 
                                't', 'e', 'd', ' ', 'f', 'o', 'r', 'm', 
                                'a', 't', ' ', '"', '%', 's', '"' }; 
static mwArray _mxarray63_ = mclInitializeString(39, _array64_); 
 
static mxChar _array66_[28] = { 'C', 'a', 'n', 'n', 'o', 't', ' ', 
                                'o', 'p', 'e', 'n', ' ', '"', '%', 
                                's', '"', ' ', 'f', 'o', 'r', ' ', 
                                'r', 'e', 'a', 'd', 'i', 'n', 'g' }; 
static mwArray _mxarray65_ = mclInitializeString(28, _array66_); 
 
void InitializeModule_imfinfo() { 
} 
 
void TerminateModule_imfinfo() { 
} 
 
static mwArray Mimfinfo(mwArray * msg, 
                        int nargout_, 
                        mwArray filename, 
                        mwArray format); 
 
_mexLocalFunctionTable _local_function_table_imfinfo 
  = { 0, (mexFunctionTableEntry *)NULL }; 
 
// 
// The function "Nimfinfo" contains the nargout interface for the "imfinfo" 
// M-function from file "D:\matlab\matlab\toolbox\matlab\iofun\imfinfo.m" 
// (lines 1-223). This interface is only produced if the M-function uses the 
// special variable "nargout". The nargout interface allows the number of 
// requested outputs to be specified via the nargout argument, as opposed to 
// the normal interface which dynamically calculates the number of outputs 
// based on the number of non-NULL inputs it receives. This function processes 
// any input arguments and passes them to the implementation version of the 
// function, appearing above. 
// 
mwArray Nimfinfo(int nargout, mwArray * msg, mwArray filename, mwArray format) { 
    mwArray info(mclGetUninitializedArray()); 
    mwArray msg__(mclGetUninitializedArray()); 
    info = Mimfinfo(&msg__, nargout, filename, format); 
    if (msg != NULL) { 
        *msg = msg__; 
    } 
    return info; 
} 
 
// 
// The function "imfinfo" contains the normal interface for the "imfinfo" 
// M-function from file "D:\matlab\matlab\toolbox\matlab\iofun\imfinfo.m" 
// (lines 1-223). This function processes any input arguments and passes them 
// to the implementation version of the function, appearing above. 
// 
mwArray imfinfo(mwArray * msg, mwArray filename, mwArray format) { 
    int nargout(1); 
    mwArray info(mclGetUninitializedArray()); 
    mwArray msg__(mclGetUninitializedArray()); 
    if (msg != NULL) { 
        ++nargout; 
    } 
    info = Mimfinfo(&msg__, nargout, filename, format); 
    if (msg != NULL) { 
        *msg = msg__; 
    } 
    return info; 
} 
 
// 
// The function "Vimfinfo" contains the void interface for the "imfinfo" 
// M-function from file "D:\matlab\matlab\toolbox\matlab\iofun\imfinfo.m" 
// (lines 1-223). The void interface is only produced if the M-function uses 
// the special variable "nargout", and has at least one output. The void 
// interface function specifies zero output arguments to the implementation 
// version of the function, and in the event that the implementation version 
// still returns an output (which, in MATLAB, would be assigned to the "ans" 
// variable), it deallocates the output. This function processes any input 
// arguments and passes them to the implementation version of the function, 
// appearing above. 
// 
void Vimfinfo(mwArray filename, mwArray format) { 
    mwArray info(mwArray::UNDEFINED); 
    mwArray msg(mwArray::UNDEFINED); 
    info = Mimfinfo(&msg, 0, filename, format); 
} 
 
// 
// The function "mlxImfinfo" contains the feval interface for the "imfinfo" 
// M-function from file "D:\matlab\matlab\toolbox\matlab\iofun\imfinfo.m" 
// (lines 1-223). The feval function calls the implementation version of 
// imfinfo through this function. This function processes any input arguments 
// and passes them to the implementation version of the function, appearing 
// above. 
// 
void mlxImfinfo(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) { 
    MW_BEGIN_MLX(); 
    { 
        mwArray mprhs[2]; 
        mwArray mplhs[2]; 
        int i; 
        mclCppUninitializeArrays(2, mplhs); 
        if (nlhs > 2) { 
            error(_mxarray0_); 
        } 
        if (nrhs > 2) { 
            error(_mxarray2_); 
        } 
        for (i = 0; i < 2 && i < nrhs; ++i) { 
            mprhs[i] = mwArray(prhs[i], 0); 
        } 
        for (; i < 2; ++i) { 
            mprhs[i].MakeDIN(); 
        } 
        mplhs[0] = Mimfinfo(&mplhs[1], nlhs, mprhs[0], mprhs[1]); 
        plhs[0] = mplhs[0].FreezeData(); 
        for (i = 1; i < 2 && i < nlhs; ++i) { 
            plhs[i] = mplhs[i].FreezeData(); 
        } 
    } 
    MW_END_MLX(); 
} 
 
// 
// The function "Mimfinfo" is the implementation version of the "imfinfo" 
// M-function from file "D:\matlab\matlab\toolbox\matlab\iofun\imfinfo.m" 
// (lines 1-223). It contains the actual compiled code for that M-function. It 
// is a static function and must only be called from one of the interface 
// functions, appearing below. 
// 
// 
// function [info,msg] = imfinfo(filename, format) 
// 
static mwArray Mimfinfo(mwArray * msg, 
                        int nargout_, 
                        mwArray filename, 
                        mwArray format) { 
    mwLocalFunctionTable save_local_function_table_ 
      (&_local_function_table_imfinfo); 
    int nargin_(nargin(2, mwVarargin(filename, format))); 
    mwArray info(mclGetUninitializedArray()); 
    mwArray fid(mclGetUninitializedArray()); 
    mwArray ans(mclGetUninitializedArray()); 
    // 
    // %IMFINFO Information about graphics file. 
    // %   INFO = IMFINFO(FILENAME,FMT) returns a structure whose 
    // %   fields contain information about an image in a graphics 
    // %   file.  FILENAME is a string that specifies the name of the 
    // %   graphics file, and FMT is a string that specifies the format 
    // %   of the file.  The file must be in the current directory or in 
    // %   a directory on the MATLAB path.  If IMFINFO cannot find a 
    // %   file named FILENAME, it looks for a file named FILENAME.FMT. 
    // %    
    // %   The possible values for FMT include: 
    // %    
    // %      'bmp'           Windows Bitmap (BMP) 
    // %      'cur'           Windows Cursor resources (CUR) 
    // %      'gif'           Graphics Interchange Format (GIF) 
    // %      'hdf'           Hierarchical Data Format (HDF) 
    // %      'ico'           Windows Icon resources (ICO) 
    // %      'jpg' or 'jpeg' Joint Photographric Experts Group 
    // %      'pcx'           Windows Paintbrush (PCX) 
    // %      'png'           Portable Network Graphics (PNG) 
    // %      'tif' or 'tiff' Tagged Image File Format (TIFF) 
    // %      'xwd'           X Window Dump (XWD) 
    // % 
    // %   If FILENAME is a TIFF, HDF, ICO, or CUR file containing more 
    // %   than one image, INFO is a structure array with one element for 
    // %   each image in the file.  For example, INFO(3) would contain 
    // %   information about the third image in the file. 
    // % 
    // %   INFO = IMFINFO(FILENAME) attempts to infer the format of the 
    // %   file from its content. 
    // % 
    // %   The set of fields in INFO depends on the individual file and 
    // %   its format.  However, the first nine fields are always the 
    // %   same.  These common fields are: 
    // % 
    // %   Filename       A string containing the name of the file 
    // % 
    // %   FileModDate    A string containing the modification date of 
    // %                  the file 
    // % 
    // %   FileSize       An integer indicating the size of the file in 
    // %                  bytes 
    // % 
    // %   Format         A string containing the file format, as 
    // %                  specified by FMT; for JPEG and TIFF files, the 
    // %                  three-letter variant is returned 
    // % 
    // %   FormatVersion  A string or number specifying the file format 
    // %                  version  
    // % 
    // %   Width          An integer indicating the width of the image 
    // %                  in pixels 
    // % 
    // %   Height         An integer indicating the height of the image 
    // %                  in pixels 
    // % 
    // %   BitDepth       An integer indicating the number of bits per 
    // %                  pixel  
    // % 
    // %   ColorType      A string indicating the type of image; either 
    // %                  'truecolor' for a truecolor (RGB) image, 
    // %                  'grayscale' for a grayscale intensity image, 
    // %                  or 'indexed', for an indexed image  
    // % 
    // %    
    // %   See also IMREAD, IMWRITE. 
    //  
    // %   Steven L. Eddins, June 1996 
    // %   Copyright 1984-2001 The MathWorks, Inc.  
    // %   $Revision: 1.17 $  $Date: 2001/04/15 12:02:21 $ 
    //  
    // error(nargchk(1, 2, nargin)); 
    // 
    error(mwVe(nargchk(_mxarray4_, _mxarray5_, nargin_))); 
    // 
    //  
    // info = []; 
    // 
    info = _mxarray6_; 
    // 
    // msg = ''; 
    // 
    *msg = _mxarray7_; 
    // 
    //  
    // if (nargin < 2) 
    // 
    if (nargin_ < 2) { 
        // 
        // % With 1 input argument, we must be able to open the file 
        // % exactly as given.  Try it. 
        // fid = fopen(filename, 'r'); 
        // 
        fid = fopen(mwVa(filename, "filename"), _mxarray8_); 
        // 
        // if (fid == -1) 
        // 
        if (mclEqBool(mwVv(fid, "fid"), _mxarray10_)) { 
            // 
            // msg = sprintf('Unable to open file "%s" for reading', filename); 
            // 
            *msg = sprintf(_mxarray11_, mwVarargin(mwVa(filename, "filename"))); 
            // 
            // if (nargout < 2) 
            // 
            if (nargout_ < 2) { 
                // 
                // error(msg); 
                // 
                error(mwVv(*msg, "msg")); 
            // 
            // else 
            // 
            } else { 
                // 
                // return; 
                // 
                goto return_; 
            // 
            // end 
            // 
            } 
        // 
        // else 
        // 
        } else { 
            // 
            // filename = fopen(fid);  % Get the full pathname if not in pwd 
            // 
            filename = fopen(mwVv(fid, "fid")); 
            // 
            // fclose(fid); 
            // 
            ans.EqAns(fclose(mwVv(fid, "fid"))); 
        // 
        // end 
        // 
        } 
        // 
        //  
        // format = imftype(filename); 
        // 
        format = iofun_private_imftype(mwVa(filename, "filename")); 
        // 
        // if (isempty(format)) 
        // 
        if (tobool(mwVe(isempty(mwVa(format, "format"))))) { 
            // 
            // msg = 'Unable to determine file format'; 
            // 
            *msg = _mxarray13_; 
            // 
            // if (nargout < 2) 
            // 
            if (nargout_ < 2) { 
                // 
                // error(msg); 
                // 
                error(mwVv(*msg, "msg")); 
            // 
            // else 
            // 
            } else { 
                // 
                // return; 
                // 
                goto return_; 
            // 
            // end 
            // 
            } 
        // 
        // end 
        // 
        } 
    // 
    // else 
    // 
    } else { 
        // 
        // % Allow for some variance in specifying file format 
        // format = lower(format); 
        // 
        format = lower(mwVa(format, "format")); 
        // 
        // if (strcmp(format,'tiff')) 
        // 
        if (tobool(mwVe(strcmp(mwVa(format, "format"), _mxarray15_)))) { 
            // 
            // format = 'tif'; 
            // 
            format = _mxarray17_; 
        // 
        // elseif (strcmp(format,'jpeg')) 
        // 
        } else if (tobool(mwVe(strcmp(mwVa(format, "format"), _mxarray19_)))) { 
            // 
            // format = 'jpg'; 
            // 
            format = _mxarray21_; 
        // 
        // end 
        // 
        } 
        // 
        //  
        // % See if we can open the file.  If we can't, and since 
        // % the user explicitly specified the format, see if we 
        // % can find the file using an extension. 
        // fid = fopen(filename,'r'); 
        // 
        fid = fopen(mwVa(filename, "filename"), _mxarray8_); 
        // 
        // if (fid == -1) 
        // 
        if (mclEqBool(mwVv(fid, "fid"), _mxarray10_)) { 
            // 
            // switch format 
            // 
            mwArray v_(mwVa(format, "format")); 
            if (switchcompare(v_, _mxarray23_)) { 
                // 
                // case 'hdf' 
                // fid = fopen([filename '.hdf'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray25_)), 
                      _mxarray8_); 
            // 
            //  
            // case 'bmp' 
            // 
            } else if (switchcompare(v_, _mxarray27_)) { 
                // 
                // fid = fopen([filename '.bmp'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray29_)), 
                      _mxarray8_); 
            // 
            //  
            // case 'pcx' 
            // 
            } else if (switchcompare(v_, _mxarray31_)) { 
                // 
                // fid = fopen([filename '.pcx'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray33_)), 
                      _mxarray8_); 
            // 
            //  
            // case 'xwd' 
            // 
            } else if (switchcompare(v_, _mxarray35_)) { 
                // 
                // fid = fopen([filename '.xwd'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray37_)), 
                      _mxarray8_); 
            // 
            //  
            // case 'png' 
            // 
            } else if (switchcompare(v_, _mxarray39_)) { 
                // 
                // fid = fopen([filename '.png'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray41_)), 
                      _mxarray8_); 
            // 
            //  
            // case 'gif' 
            // 
            } else if (switchcompare(v_, _mxarray43_)) { 
                // 
                // fid = fopen([filename '.gif'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray45_)), 
                      _mxarray8_); 
            // 
            //  
            // case 'jpg' 
            // 
            } else if (switchcompare(v_, _mxarray21_)) { 
                // 
                // fid = fopen([filename '.jpg'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray47_)), 
                      _mxarray8_); 
                // 
                // if (fid == -1) 
                // 
                if (mclEqBool(mwVv(fid, "fid"), _mxarray10_)) { 
                    // 
                    // fid = fopen([filename '.jpeg'], 'r'); 
                    // 
                    fid 
                      = fopen( 
                          horzcat( 
                            mwVarargin( 
                              mwVa(filename, "filename"), _mxarray49_)), 
                          _mxarray8_); 
                // 
                // end 
                // 
                } 
            // 
            //  
            // case 'tif' 
            // 
            } else if (switchcompare(v_, _mxarray17_)) { 
                // 
                // fid = fopen([filename '.tif'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray51_)), 
                      _mxarray8_); 
                // 
                // if (fid == -1) 
                // 
                if (mclEqBool(mwVv(fid, "fid"), _mxarray10_)) { 
                    // 
                    // fid = fopen([filename '.tiff'], 'r'); 
                    // 
                    fid 
                      = fopen( 
                          horzcat( 
                            mwVarargin( 
                              mwVa(filename, "filename"), _mxarray53_)), 
                          _mxarray8_); 
                // 
                // end 
                // 
                } 
            // 
            //  
            // case 'ico' 
            // 
            } else if (switchcompare(v_, _mxarray55_)) { 
                // 
                // fid = fopen([filename '.ico'], 'r');            
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray57_)), 
                      _mxarray8_); 
            // 
            //  
            // case 'cur'   
            // 
            } else if (switchcompare(v_, _mxarray59_)) { 
                // 
                // fid = fopen([filename '.cur'], 'r'); 
                // 
                fid 
                  = fopen( 
                      horzcat( 
                        mwVarargin(mwVa(filename, "filename"), _mxarray61_)), 
                      _mxarray8_); 
            // 
            //  
            // otherwise 
            // 
            } else { 
                // 
                // if (nargout > 1) 
                // 
                if (nargout_ > 1) { 
                    // 
                    // msg = sprintf('Unrecognized or unsupported format "%s"', format); 
                    // 
                    *msg 
                      = sprintf( 
                          _mxarray63_, mwVarargin(mwVa(format, "format"))); 
                    // 
                    // return; 
                    // 
                    goto return_; 
                // 
                // else	     
                // 
                } else { 
                    // 
                    // error(sprintf('Unrecognized or unsupported format "%s"', format)); 
                    // 
                    error( 
                      mwVe( 
                        sprintf( 
                          _mxarray63_, mwVarargin(mwVa(format, "format"))))); 
                // 
                // end 
                // 
                } 
            // 
            // end 
            // 
            } 
            // 
            //  
            // if (fid == -1) 
            // 
            if (mclEqBool(mwVv(fid, "fid"), _mxarray10_)) { 
                // 
                // if (nargout > 1) 
                // 
                if (nargout_ > 1) { 
                    // 
                    // msg = sprintf('Cannot open "%s" for reading', filename); 
                    // 
                    *msg 
                      = sprintf( 
                          _mxarray65_, mwVarargin(mwVa(filename, "filename"))); 
                    // 
                    // return; 
                    // 
                    goto return_; 
                // 
                // else 
                // 
                } else { 
                    // 
                    // error(sprintf('Cannot open "%s" for reading', filename)); 
                    // 
                    error( 
                      mwVe( 
                        sprintf( 
                          _mxarray65_, 
                          mwVarargin(mwVa(filename, "filename"))))); 
                // 
                // end 
                // 
                } 
            // 
            // end 
            // 
            } 
        // 
        // end 
        // 
        } 
        // 
        //  
        // filename = fopen(fid);  % gets the full pathname if not in pwd 
        // 
        filename = fopen(mwVv(fid, "fid")); 
        // 
        // fclose(fid); 
        // 
        ans.EqAns(fclose(mwVv(fid, "fid"))); 
    // 
    //  
    // end 
    // 
    } 
    // 
    //  
    // msg = ''; 
    // 
    *msg = _mxarray7_; 
    // 
    //  
    // switch format 
    // 
    { 
        mwArray v_(mwVa(format, "format")); 
        if (switchcompare(v_, _mxarray23_)) { 
            // 
            // case 'hdf' 
            // [info,msg] = imhdfinfo(filename); 
            // 
            info = iofun_private_imhdfinfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'bmp' 
        // 
        } else if (switchcompare(v_, _mxarray27_)) { 
            // 
            // [info,msg] = imbmpinfo(filename); 
            // 
            info = iofun_private_imbmpinfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'pcx' 
        // 
        } else if (switchcompare(v_, _mxarray31_)) { 
            // 
            // [info,msg] = impcxinfo(filename); 
            // 
            info = iofun_private_impcxinfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'xwd' 
        // 
        } else if (switchcompare(v_, _mxarray35_)) { 
            // 
            // [info,msg] = imxwdinfo(filename); 
            // 
            info = iofun_private_imxwdinfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'jpg' 
        // 
        } else if (switchcompare(v_, _mxarray21_)) { 
            // 
            // [info,msg] = imjpginfo(filename); 
            // 
            info = iofun_private_imjpginfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'tif' 
        // 
        } else if (switchcompare(v_, _mxarray17_)) { 
            // 
            // [info,msg] = imtifinfo(filename); 
            // 
            info = iofun_private_imtifinfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'png' 
        // 
        } else if (switchcompare(v_, _mxarray39_)) { 
            // 
            // [info,msg] = impnginfo(filename); 
            // 
            info = iofun_private_impnginfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'gif' 
        // 
        } else if (switchcompare(v_, _mxarray43_)) { 
            // 
            // [info,msg] = imgifinfo(filename); 
            // 
            info = iofun_private_imgifinfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'ico' 
        // 
        } else if (switchcompare(v_, _mxarray55_)) { 
            // 
            // [info,msg] = imicoinfo(filename); 
            // 
            info = iofun_private_imicoinfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // case 'cur' 
        // 
        } else if (switchcompare(v_, _mxarray59_)) { 
            // 
            // [info,msg] = imcurinfo(filename); 
            // 
            info = iofun_private_imcurinfo(msg, mwVa(filename, "filename")); 
        // 
        //  
        // otherwise 
        // 
        } else { 
            // 
            // if (nargout > 1) 
            // 
            if (nargout_ > 1) { 
                // 
                // msg = sprintf('Unrecognized or unsupported format "%s"', format); 
                // 
                *msg = sprintf(_mxarray63_, mwVarargin(mwVa(format, "format"))); 
                // 
                // return; 
                // 
                goto return_; 
            // 
            // else 
            // 
            } else { 
                // 
                // error(sprintf('Unrecognized or unsupported format "%s"', format)); 
                // 
                error( 
                  mwVe( 
                    sprintf(_mxarray63_, mwVarargin(mwVa(format, "format"))))); 
            // 
            // end 
            // 
            } 
        // 
        //  
        // end 
        // 
        } 
    } 
    // 
    //  
    // if ((nargout < 2) & (isempty(info))) 
    // 
    { 
        mwArray a_(nargout_ < 2); 
        if (tobool(a_) && tobool(a_ & mwVe(isempty(mwVv(info, "info"))))) { 
            // 
            // error(msg); 
            // 
            error(mwVv(*msg, "msg")); 
        } else { 
        } 
    // 
    // end 
    // 
    } 
    return_: 
    mwValidateOutput(info, 1, nargout_, "info", "imfinfo"); 
    mwValidateOutput(*msg, 2, nargout_, "msg", "imfinfo"); 
    return info; 
}