#include <maya/MPxCommand.h>
#include <maya/MStatus.h>
#include <maya/MArgList.h>
#include <maya/MFnPlugin.h>
#include <maya/MObject.h>
#include <maya/MGlobal.h>
#include <maya/MString.h>
#include <maya/MPoint.h>
#include "iffreader.h"
#ifndef __APPLE__
#include <maya/MIOStream.h>
#endif
#define IFFCHECKERR(stat, call) \
if (!stat) { \
MString string = reader.errorString(); \
string += " in method "; \
string += #call; \
displayError (string); \
return MS::kFailure; \
}
{
public:
iffInfo();
~iffInfo() override;
static void* creator();
private:
};
iffInfo::iffInfo()
{
}
iffInfo::~iffInfo() {}
void* iffInfo::creator()
{
return new iffInfo;
}
bool iffInfo::isUndoable() const
{
return true;
}
{
return MS::kSuccess;
}
{
char buffer [256];
sprintf (buffer, "%d", n);
}
{
displayError ("Syntax: iffInfo file");
return MS::kFailure;
}
IFFimageReader reader;
stat = reader.open (fileName);
IFFCHECKERR (stat, open);
int bytesPerChannel = reader.getBytesPerChannel ();
int w,h;
stat = reader.getSize (w, h);
IFFCHECKERR (stat, getSize);
result = "\nResolution: ";
result += itoa (w);
result += "x";
result += itoa (h);
result += "\n";
if (reader.isRGB () || reader.isGrayscale ()) {
if (reader.isRGB ()) {
result += "RGB";
if (reader.hasAlpha ())
result += "A";
}
else
result += "Grayscale";
result += " data with ";
if (bytesPerChannel == 2)
result += "16";
else
result += "8";
result += " bits per channel\n";
}
if (reader.hasDepthMap ()) {
result += "Image has a depth map\n";
} else {
result += "Image does not have a depth map\n";
}
stat = reader.close ();
IFFCHECKERR (stat, close);
return redoIt();
}
{
clearResult();
appendToResult (result);
return MS::kSuccess;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerCommand( "iffInfo", iffInfo::creator );
if (!status)
status.
perror(
"registerCommand");
return status;
}
{
status = plugin.deregisterCommand( "iffInfo" );
if (!status)
status.
perror(
"deregisterCommand");
return status;
}