#include "TImage.h"
#include "TROOT.h"
#include "TPluginManager.h"
#include "TApplication.h"
#include "TSystem.h"
ClassImp(TImage)
TImage *TImage::Create()
{
static TPluginHandler *h = 0;
if (!h) {
h = gROOT->GetPluginManager()->FindHandler("TImage");
if (!h) return 0;
if (h->LoadPlugin() == -1) {
h = 0;
return 0;
}
}
TImage *img = (TImage *) h->ExecPlugin(0);
if (img) img->SetName("dummy_image");
return img;
}
TImage::EImageFileTypes TImage::GetImageFileTypeFromFilename(const char* filename)
{
if (!filename) return kUnknown;
TString sFilename(filename);
if (sFilename.EndsWith(".xpm.gz", TString::kIgnoreCase))
return kGZCompressedXpm;
else if (sFilename.EndsWith(".xpm.z", TString::kIgnoreCase))
return kZCompressedXpm;
else if (sFilename.EndsWith(".png", TString::kIgnoreCase))
return kPng;
else if (sFilename.EndsWith(".jpeg", TString::kIgnoreCase))
return kJpeg;
else if (sFilename.EndsWith(".jpg", TString::kIgnoreCase))
return kJpeg;
else if (sFilename.EndsWith(".xcf", TString::kIgnoreCase))
return kXcf;
else if (sFilename.EndsWith(".ppm", TString::kIgnoreCase))
return kPpm;
else if (sFilename.EndsWith(".pnm", TString::kIgnoreCase))
return kPnm;
else if (sFilename.EndsWith(".bmp", TString::kIgnoreCase))
return kBmp;
else if (sFilename.EndsWith(".ico", TString::kIgnoreCase))
return kIco;
else if (sFilename.EndsWith(".cur", TString::kIgnoreCase))
return kCur;
else if (sFilename.EndsWith(".gif", TString::kIgnoreCase))
return kGif;
else if (sFilename.EndsWith(".tiff", TString::kIgnoreCase))
return kTiff;
else if (sFilename.EndsWith(".tif", TString::kIgnoreCase))
return kTiff;
else if (sFilename.EndsWith(".xbm", TString::kIgnoreCase))
return kXbm;
else if (sFilename.EndsWith(".fits", TString::kIgnoreCase))
return kFits;
else if (sFilename.EndsWith(".tga", TString::kIgnoreCase))
return kTga;
else if (sFilename.EndsWith(".xml", TString::kIgnoreCase))
return kXml;
else if (sFilename.EndsWith(".anim.gif", TString::kIgnoreCase))
return kAnimGif;
return kUnknown;
}
TImage *TImage::Open(const char *file, EImageFileTypes type)
{
TImage *img = Create();
char *fullname = gSystem->ExpandPathName(file);
if (img)
img->ReadImage(fullname, type);
delete [] fullname;
return img;
}
TImage *TImage::Open(const char *name, const Double_t *imageData, UInt_t width,
UInt_t height, TImagePalette *palette)
{
TImage *img = Create();
if (img) {
img->SetImage(imageData, width, height, palette);
img->SetName(name);
}
return img;
}
TImage *TImage::Open(const char *name, const TArrayD &imageData, UInt_t width,
TImagePalette *palette)
{
TImage *img = Create();
if (img) {
img->SetImage(imageData, width, palette);
img->SetName(name);
}
return img;
}
TImage *TImage::Open(const char *name, const TVectorD &imageData, UInt_t width,
TImagePalette *palette)
{
TImage *img = Create();
if (img) {
img->SetImage(imageData, width, palette);
img->SetName(name);
}
return img;
}
TImage *TImage::Open(char **data)
{
TImage *img = Create();
if (img) {
img->SetImageBuffer(data, TImage::kXpm);
img->SetName("XPM_image");
}
return img;
}
TImage operator+(const TImage &i1, const TImage &i2) { TImage ret(i1); ret.Append(&i2, "+"); return ret; }
TImage operator/(const TImage &i1, const TImage &i2) { TImage ret(i1); ret.Append(&i2, "/"); return ret; }