www.pudn.com > vcmatlab20060426WaterMark.zip > iofun_private_imcurinfo.cpp
//
// MATLAB Compiler: 2.2
// Date: Tue May 10 11:47:31 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 "iofun_private_imcurinfo.hpp"
#include "libmatlbm.hpp"
#include "libmmfile.hpp"
static mxChar _array1_[164] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
'l', 'e', ':', ' ', 'i', 'o', 'f', 'u', 'n',
'/', 'p', 'r', 'i', 'v', 'a', 't', 'e', '/',
'i', 'm', 'c', 'u', 'r', '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', 'o', 'f',
'u', 'n', '/', 'p', 'r', 'i', 'v', 'a', 't',
'e', '/', 'i', 'm', 'c', 'u', 'r', '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(164, _array1_);
static mxChar _array3_[163] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
'l', 'e', ':', ' ', 'i', 'o', 'f', 'u', 'n',
'/', 'p', 'r', 'i', 'v', 'a', 't', 'e', '/',
'i', 'm', 'c', 'u', 'r', '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', 'o', 'f',
'u', 'n', '/', 'p', 'r', 'i', 'v', 'a', 't',
'e', '/', 'i', 'm', 'c', 'u', 'r', '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', ' ', '(', '1', ')',
'.' };
static mwArray _mxarray2_ = mclInitializeString(163, _array3_);
static mwArray _mxarray4_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
static mwArray _mxarray5_ = mclInitializeCharVector(0, 0, (mxChar *)NULL);
static mxChar _array7_[25] = { 'F', 'I', 'L', 'E', 'N', 'A', 'M', 'E', ' ',
'm', 'u', 's', 't', ' ', 'b', 'e', ' ', 'a',
' ', 's', 't', 'r', 'i', 'n', 'g' };
static mwArray _mxarray6_ = mclInitializeString(25, _array7_);
static mxChar _array9_[1] = { 'r' };
static mwArray _mxarray8_ = mclInitializeString(1, _array9_);
static mxChar _array11_[7] = { 'i', 'e', 'e', 'e', '-', 'l', 'e' };
static mwArray _mxarray10_ = mclInitializeString(7, _array11_);
static mwArray _mxarray12_ = mclInitializeDouble(-1.0);
static mxChar _array14_[3] = { 'c', 'u', 'r' };
static mwArray _mxarray13_ = mclInitializeString(3, _array14_);
static mwArray _mxarray15_ = mclInitializeDouble(2.0);
static mxChar _array17_[6] = { 'u', 'i', 'n', 't', '1', '6' };
static mwArray _mxarray16_ = mclInitializeString(6, _array17_);
static mxChar _array19_[10] = { 'E', 'm', 'p', 't', 'y',
' ', 'f', 'i', 'l', 'e' };
static mwArray _mxarray18_ = mclInitializeString(10, _array19_);
static double _array21_[2] = { 0.0, 2.0 };
static mwArray _mxarray20_ = mclInitializeDoubleVector(2, 1, _array21_);
static mxChar _array23_[15] = { 'N', 'o', 't', ' ', 'a', ' ', 'C', 'U',
'R', ' ', 'f', 'i', 'l', 'e', '.' };
static mwArray _mxarray22_ = mclInitializeString(15, _array23_);
static mwArray _mxarray24_ = mclInitializeDouble(1.0);
static mwArray _mxarray25_ = mclInitializeDouble(6.0);
static mwArray _mxarray26_ = mclInitializeDouble(16.0);
static mxChar _array28_[3] = { 'b', 'o', 'f' };
static mwArray _mxarray27_ = mclInitializeString(3, _array28_);
static mxChar _array30_[5] = { 'u', 'i', 'n', 't', '8' };
static mwArray _mxarray29_ = mclInitializeString(5, _array30_);
static mxChar _array32_[3] = { 'c', 'o', 'f' };
static mwArray _mxarray31_ = mclInitializeString(3, _array32_);
static mxChar _array34_[6] = { 'u', 'i', 'n', 't', '3', '2' };
static mwArray _mxarray33_ = mclInitializeString(6, _array34_);
static mwArray _mxarray35_ = mclInitializeDouble(8.0);
static mwArray _mxarray36_ = mclInitializeDouble(4.0);
static mxChar _array38_[23] = { 'T', 'r', 'u', 'n', 'c', 'a', 't', 'e',
'd', ' ', 'c', 'o', 'l', 'o', 'r', 'm',
'a', 'p', ' ', 'd', 'a', 't', 'a' };
static mwArray _mxarray37_ = mclInitializeString(23, _array38_);
static mwArray _mxarray39_ = mclInitializeDouble(3.0);
static mwArray _mxarray40_ = mclInitializeDouble(255.0);
static mxChar _array42_[7] = { 'i', 'n', 'd', 'e', 'x', 'e', 'd' };
static mwArray _mxarray41_ = mclInitializeString(7, _array42_);
static mxChar _array44_[4] = { 'n', 'o', 'n', 'e' };
static mwArray _mxarray43_ = mclInitializeString(4, _array44_);
static mwArray _mxarray45_ = mclInitializeDouble(0.0);
static mxChar _array47_[39] = { 'C', 'o', 'r', 'r', 'u', 'p', 't', ' ',
'C', 'U', 'R', ' ', 'f', 'i', 'l', 'e',
':', ' ', 'b', 'a', 'd', ' ', 'i', 'm',
'a', 'g', 'e', ' ', 'd', 'i', 'm', 'e',
'n', 's', 'i', 'o', 'n', 's', '.' };
static mwArray _mxarray46_ = mclInitializeString(39, _array47_);
void InitializeModule_iofun_private_imcurinfo() {
}
void TerminateModule_iofun_private_imcurinfo() {
}
static mwArray Miofun_private_imcurinfo(mwArray * msg,
int nargout_,
mwArray filename);
_mexLocalFunctionTable _local_function_table_iofun_private_imcurinfo
= { 0, (mexFunctionTableEntry *)NULL };
//
// The function "iofun_private_imcurinfo" contains the normal interface for the
// "iofun/private/imcurinfo" M-function from file
// "D:\matlab\matlab\toolbox\matlab\iofun\private\imcurinfo.m" (lines 1-155).
// This function processes any input arguments and passes them to the
// implementation version of the function, appearing above.
//
mwArray iofun_private_imcurinfo(mwArray * msg, mwArray filename) {
int nargout(1);
mwArray info(mclGetUninitializedArray());
mwArray msg__(mclGetUninitializedArray());
if (msg != NULL) {
++nargout;
}
info = Miofun_private_imcurinfo(&msg__, nargout, filename);
if (msg != NULL) {
*msg = msg__;
}
return info;
}
//
// The function "mlxIofun_private_imcurinfo" contains the feval interface for
// the "iofun/private/imcurinfo" M-function from file
// "D:\matlab\matlab\toolbox\matlab\iofun\private\imcurinfo.m" (lines 1-155).
// The feval function calls the implementation version of
// iofun/private/imcurinfo through this function. This function processes any
// input arguments and passes them to the implementation version of the
// function, appearing above.
//
void mlxIofun_private_imcurinfo(int nlhs,
mxArray * plhs[],
int nrhs,
mxArray * prhs[]) {
MW_BEGIN_MLX();
{
mwArray mprhs[1];
mwArray mplhs[2];
int i;
mclCppUninitializeArrays(2, mplhs);
if (nlhs > 2) {
error(_mxarray0_);
}
if (nrhs > 1) {
error(_mxarray2_);
}
for (i = 0; i < 1 && i < nrhs; ++i) {
mprhs[i] = mwArray(prhs[i], 0);
}
for (; i < 1; ++i) {
mprhs[i].MakeDIN();
}
mplhs[0] = Miofun_private_imcurinfo(&mplhs[1], nlhs, mprhs[0]);
plhs[0] = mplhs[0].FreezeData();
for (i = 1; i < 2 && i < nlhs; ++i) {
plhs[i] = mplhs[i].FreezeData();
}
}
MW_END_MLX();
}
//
// The function "Miofun_private_imcurinfo" is the implementation version of the
// "iofun/private/imcurinfo" M-function from file
// "D:\matlab\matlab\toolbox\matlab\iofun\private\imcurinfo.m" (lines 1-155).
// 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] = imcurinfo(filename)
//
static mwArray Miofun_private_imcurinfo(mwArray * msg,
int nargout_,
mwArray filename) {
mwLocalFunctionTable save_local_function_table_
(&_local_function_table_iofun_private_imcurinfo);
mwArray info(mclGetUninitializedArray());
mwArray cmap(mclGetUninitializedArray());
mwArray count(mclGetUninitializedArray());
mwArray data(mclGetUninitializedArray());
mwArray cdpos(mclGetUninitializedArray());
mwArray p(mclGetUninitializedArray());
mwArray imcount(mclGetUninitializedArray());
mwArray ans(mclGetUninitializedArray());
mwArray sig(mclGetUninitializedArray());
mwArray d(mclGetUninitializedArray());
mwArray m(mclGetUninitializedArray());
mwArray fid(mclGetUninitializedArray());
//
// %IMICURINFO Get information about the image in a CUR file.
// % [INFO,MSG] = IMCURINFO(FILENAME) returns information about
// % the image contained in a CUR file containing one or more
// % Microsoft Windows cursor resources. If the attempt fails for
// % some reason (e.g. the file does not exist or is not a CUR
// % file), then INFO is empty and MSG is a string containing a
// % diagnostic message.
// %
// % See also IMREAD, IMWRITE, IMFINFO.
//
// % Copyright 1984-2001 The MathWorks, Inc.
// % $Revision: 1.4 $ $Date: 2001/04/15 12:02:05 $
// % $ Revision $ $ Date $
//
// % This function should not call error()!
//
// info = [];
//
info = _mxarray4_;
//
// msg = '';
//
*msg = _mxarray5_;
//
//
// if (~ischar(filename))
//
if (mclNotBool(mwVe(ischar(mwVa(filename, "filename"))))) {
//
// msg = 'FILENAME must be a string';
//
*msg = _mxarray6_;
//
// return;
//
goto return_;
//
// end
//
}
//
//
// [fid, m] = fopen(filename, 'r', 'ieee-le'); % CUR files are little-endian
//
fid = fopen(&m, mwVa(filename, "filename"), _mxarray8_, _mxarray10_);
//
// if (fid == -1)
//
if (mclEqBool(mwVv(fid, "fid"), _mxarray12_)) {
//
// info = [];
//
info = _mxarray4_;
//
// msg = m;
//
*msg = mwVsv(m, "m");
//
// return;
//
goto return_;
//
// end
//
}
//
// filename = fopen(fid); % Get the full path name if not in pwd
//
filename = fopen(mwVv(fid, "fid"));
//
// d = dir(filename); % Read directory information
//
d = Ndir(1, mwVa(filename, "filename"));
//
//
// %
// % Initialize universal structure fields to fix the order
// %
// info.Filename = filename;
//
info.field("Filename") = mwVsa(filename, "filename");
//
// info.FileModDate = d.date;
//
info.field("FileModDate") = mwVsv(d, "d").field("date");
//
// info.FileSize = d.bytes;
//
info.field("FileSize") = mwVsv(d, "d").field("bytes");
//
// info.Format = 'cur';
//
info.field("Format") = _mxarray13_;
//
// info.FormatVersion = [];
//
info.field("FormatVersion") = _mxarray4_;
//
// info.Width = [];
//
info.field("Width") = _mxarray4_;
//
// info.Height = [];
//
info.field("Height") = _mxarray4_;
//
// info.BitDepth = [];
//
info.field("BitDepth") = _mxarray4_;
//
// info.ColorType = [];
//
info.field("ColorType") = _mxarray4_;
//
// info.FormatSignature = [];
//
info.field("FormatSignature") = _mxarray4_;
//
//
// %
// % Initialize CUR-specific structure fields to fix the order
// %
// info.NumColormapEntries = [];
//
info.field("NumColormapEntries") = _mxarray4_;
//
// info.Colormap = [];
//
info.field("Colormap") = _mxarray4_;
//
//
// % Read the resource header to verify the correct type
// sig = fread(fid, 2, 'uint16');
//
sig = fread(mwVv(fid, "fid"), _mxarray15_, _mxarray16_);
//
// if (isempty(sig))
//
if (tobool(mwVe(isempty(mwVv(sig, "sig"))))) {
//
// info = [];
//
info = _mxarray4_;
//
// msg = 'Empty file';
//
*msg = _mxarray18_;
//
// fclose(fid);
//
ans.EqAns(fclose(mwVv(fid, "fid")));
//
// return;
//
goto return_;
//
// end
//
}
//
//
// if (~isequal(sig, [0; 2]))
//
if (mclNotBool(mwVe(isequal(mwVv(sig, "sig"), mwVarargin(_mxarray20_))))) {
//
// info = [];
//
info = _mxarray4_;
//
// msg = 'Not a CUR file.';
//
*msg = _mxarray22_;
//
// fclose(fid);
//
ans.EqAns(fclose(mwVv(fid, "fid")));
//
// return;
//
goto return_;
//
// end
//
}
//
//
// % Find the number of cursors in the file
// imcount = fread(fid, 1, 'uint16');
//
imcount = fread(mwVv(fid, "fid"), _mxarray24_, _mxarray16_);
//
//
// for p = 1:imcount
//
{
int v_(mclForIntStart(1));
int e_(mclForIntEnd(mwVv(imcount, "imcount")));
if (v_ > e_) {
p = _mxarray4_;
} else {
//
// info(p).Filename = filename;
// info(p).FileModDate = d.date;
// info(p).FileSize = d.bytes;
// info(p).Format = 'cur';
// info(p).FormatSignature = sig';
//
// % Offset to the current cursor directory entry
// cdpos = 6 + 16*(p - 1);
// fseek(fid, cdpos, 'bof');
//
// % Read the cursor directory
// info(p).Width = fread(fid, 1, 'uint8');
// info(p).Height = fread(fid, 1, 'uint8');
//
// fseek(fid, 2, 'cof');
//
// info(p).HotSpot(1,1) = fread(fid, 1, 'uint16') + 1; % zero-based
// info(p).HotSpot(1,2) = fread(fid, 1, 'uint16') + 1; % zero-based
//
// info(p).ResourceSize = fread(fid, 1, 'uint32');
// info(p).ResourceDataOffset = fread(fid, 1, 'uint32');
//
// % Start reading bitmap header info
// fseek(fid, info(p).ResourceDataOffset, 'bof');
//
// info(p).BitmapHeaderSize = fread(fid, 1, 'uint32');
//
// fseek(fid, 8, 'cof');
//
// info(p).NumPlanes = fread(fid, 1, 'uint16');
// info(p).BitDepth = fread(fid, 1, 'uint16');
//
// fseek(fid, 4, 'cof');
//
// info(p).BitmapSize = fread(fid, 1, 'uint32');
//
// % Headers must be at least 40 bytes, but they may be larger.
// % Skip ahead to the begining of the colormap data.
// info(p).ColormapOffset = info(p).ResourceDataOffset + ...
// info(p).BitmapHeaderSize;
//
// fseek(fid, info(p).ColormapOffset, 'bof');
//
// % Read the RGBQUAD colormap: [blue green red reserved]
// info(p).NumColormapEntries = info(p).NumPlanes * ...
// 2^(info(p).BitDepth);
//
// [data, count] = fread(fid, (info(p).NumColormapEntries)*4, 'uint8');
//
// if (count ~= info(p).NumColormapEntries*4)
// info = [];
// msg = 'Truncated colormap data';
// fclose(fid);
// return;
// end
//
// % Throw away the reserved byte, swap red and blue, and rescale
// data = reshape(data, 4, info(p).NumColormapEntries)';
// cmap = data(:,1:3);
// cmap = fliplr(cmap);
// cmap = cmap ./ 255;
//
// info(p).Colormap = cmap;
//
// info(p).ColorType = 'indexed';
// info(p).CompressionType = 'none';
// info(p).ImageDataOffset = ftell(fid);
//
// %
// % Other validity checks
// %
// if ((info(p).Width < 0) | (info(p).Height < 0))
// info = [];
// msg = 'Corrupt CUR file: bad image dimensions.';
// fclose(fid);
// return;
// end
// end
//
for (; ; ) {
info(v_).field("Filename") = mwVsa(filename, "filename");
info(v_).field("FileModDate") = mwVsv(d, "d").field("date");
info(v_).field("FileSize") = mwVsv(d, "d").field("bytes");
info(v_).field("Format") = _mxarray13_;
info(v_).field("FormatSignature")
= ctranspose(mwVv(sig, "sig"));
cdpos = _mxarray25_ + _mxarray26_ * (v_ - 1);
ans.EqAns(
fseek(mwVv(fid, "fid"), mwVv(cdpos, "cdpos"), _mxarray27_));
info(v_).field("Width")
= fread(mwVv(fid, "fid"), _mxarray24_, _mxarray29_);
info(v_).field("Height")
= fread(mwVv(fid, "fid"), _mxarray24_, _mxarray29_);
ans.EqAns(fseek(mwVv(fid, "fid"), _mxarray15_, _mxarray31_));
info(v_).field("HotSpot")(_mxarray24_, _mxarray24_)
= mwVe(fread(mwVv(fid, "fid"), _mxarray24_, _mxarray16_))
+ _mxarray24_;
info(v_).field("HotSpot")(_mxarray24_, _mxarray15_)
= mwVe(fread(mwVv(fid, "fid"), _mxarray24_, _mxarray16_))
+ _mxarray24_;
info(v_).field("ResourceSize")
= fread(mwVv(fid, "fid"), _mxarray24_, _mxarray33_);
info(v_).field("ResourceDataOffset")
= fread(mwVv(fid, "fid"), _mxarray24_, _mxarray33_);
ans.EqAns(
feval(
mwAnsVarargout(),
mlxFseek,
mwVarargin(
mwVv(fid, "fid"),
mwVe(mwVsv(info, "info")(v_).field("ResourceDataOffset")),
_mxarray27_)));
info(v_).field("BitmapHeaderSize")
= fread(mwVv(fid, "fid"), _mxarray24_, _mxarray33_);
ans.EqAns(fseek(mwVv(fid, "fid"), _mxarray35_, _mxarray31_));
info(v_).field("NumPlanes")
= fread(mwVv(fid, "fid"), _mxarray24_, _mxarray16_);
info(v_).field("BitDepth")
= fread(mwVv(fid, "fid"), _mxarray24_, _mxarray16_);
ans.EqAns(fseek(mwVv(fid, "fid"), _mxarray36_, _mxarray31_));
info(v_).field("BitmapSize")
= fread(mwVv(fid, "fid"), _mxarray24_, _mxarray33_);
info(v_).field("ColormapOffset")
= feval(
mwValueVarargout(),
mlxPlus,
mwVarargin(
mwVe(
mwVsv(info, "info")(v_).field("ResourceDataOffset")),
mwVe(
mwVsv(info, "info")(v_).field("BitmapHeaderSize"))));
ans.EqAns(
feval(
mwAnsVarargout(),
mlxFseek,
mwVarargin(
mwVv(fid, "fid"),
mwVe(mwVsv(info, "info")(v_).field("ColormapOffset")),
_mxarray27_)));
info(v_).field("NumColormapEntries")
= feval(
mwValueVarargout(),
mlxMtimes,
mwVarargin(
mwVe(mwVsv(info, "info")(v_).field("NumPlanes")),
feval(
mwValueVarargout(),
mlxMpower,
mwVarargin(
_mxarray15_,
mwVe(mwVsv(info, "info")(v_).field("BitDepth"))))));
data
= fread(
&count,
mwVv(fid, "fid"),
feval(
mwValueVarargout(),
mlxMtimes,
mwVarargin(
mwVe(
mwVsv(info, "info")(v_).field("NumColormapEntries")),
_mxarray36_)),
_mxarray29_);
if (mclNeBool(
mwVv(count, "count"),
feval(
mwValueVarargout(),
mlxMtimes,
mwVarargin(
mwVe(
mwVsv(info, "info")(v_).field(
"NumColormapEntries")),
_mxarray36_)))) {
info = _mxarray4_;
*msg = _mxarray37_;
ans.EqAns(fclose(mwVv(fid, "fid")));
goto return_;
}
data
= ctranspose(
mwVe(
reshape(
mwVv(data, "data"),
mwVarargin(
_mxarray36_,
mwVe(
mwVsv(info, "info")(v_).field(
"NumColormapEntries"))))));
cmap
= mclArrayRef(
mwVsv(data, "data"),
colon(),
colon(_mxarray24_, _mxarray39_));
cmap = fliplr(mwVv(cmap, "cmap"));
cmap = rdivide(mwVv(cmap, "cmap"), _mxarray40_);
info(v_).field("Colormap") = mwVsv(cmap, "cmap");
info(v_).field("ColorType") = _mxarray41_;
info(v_).field("CompressionType") = _mxarray43_;
info(v_).field("ImageDataOffset") = ftell(mwVv(fid, "fid"));
{
mwArray a_
(feval(
mwValueVarargout(),
mlxLt,
mwVarargin(
mwVe(mwVsv(info, "info")(v_).field("Width")),
_mxarray45_)));
if (tobool(a_)
|| tobool(
a_
| feval(
mwValueVarargout(),
mlxLt,
mwVarargin(
mwVe(
mwVsv(info, "info")(v_).field("Height")),
_mxarray45_)))) {
info = _mxarray4_;
*msg = _mxarray46_;
ans.EqAns(fclose(mwVv(fid, "fid")));
goto return_;
} else {
}
}
if (v_ == e_) {
break;
}
++v_;
}
p = v_;
}
}
//
//
// fclose(fid);
//
ans.EqAns(fclose(mwVv(fid, "fid")));
return_:
mwValidateOutput(info, 1, nargout_, "info", "iofun/private/imcurinfo");
mwValidateOutput(*msg, 2, nargout_, "msg", "iofun/private/imcurinfo");
return info;
}