Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tnzimage.h"
Toshihiro Shimizu 890ddd
#include "tiio.h"
Toshihiro Shimizu 890ddd
#include "tfiletype.h"
justburner 64e039
#include "thirdparty.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Shinya Kitaoka 120a6e
    TImageReader::load MUST throw an exception in case of error (file not found,
Shinya Kitaoka 120a6e
   ...)
Shinya Kitaoka 120a6e
    TImageWriter::save MUST throw an exception in case of error (write denied,
Shinya Kitaoka 120a6e
                                                                 disk full, ...)
Toshihiro Shimizu 890ddd
    N.B.: gestire nei TImageWriter il caso "disk full"!!!
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// Math needs to be included before the rest on MAC - but I've not figured out
Shinya Kitaoka 120a6e
// why (it would be included anyway though)
Toshihiro Shimizu 890ddd
#include <math.h></math.h>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// Platform-specific includes
Campbell Barton d869b5
#if defined(_WIN32)
Toshihiro Shimizu 890ddd
db7f14
#if !defined(x64) && !defined(__GNUC__)
Shinya Kitaoka 6526c7
Shinya Kitaoka fd19c4
#define list QuickTime_list
Shinya Kitaoka fd19c4
#define map QuickTime_map
Shinya Kitaoka fd19c4
#define iterator QuickTime_iterator
Shinya Kitaoka fd19c4
#define float_t QuickTime_float_t
Shinya Kitaoka fd19c4
#define GetProcessInformation QuickTime_GetProcessInformation
Shinya Kitaoka fd19c4
#define int_fast8_t QuickTime_int_fast8_t
Shinya Kitaoka fd19c4
#define int_fast16_t QuickTime_int_fast16_t
Shinya Kitaoka fd19c4
#define uint_fast16_t QuickTime_uint_fast16_t
Shinya Kitaoka 6526c7
Toshihiro Shimizu 890ddd
#include "QuickTimeComponents.h"
Toshihiro Shimizu 890ddd
#include "tquicktime.h"
Shinya Kitaoka 6526c7
Shinya Kitaoka fd19c4
#undef list
Shinya Kitaoka fd19c4
#undef map
Shinya Kitaoka fd19c4
#undef iterator
Toshihiro Shimizu 890ddd
#undef float_t
Toshihiro Shimizu 890ddd
#undef GetProcessInformation
Shinya Kitaoka fd19c4
#undef int_fast8_t
Shinya Kitaoka fd19c4
#undef int_fast16_t
Shinya Kitaoka fd19c4
#undef uint_fast16_t
Shinya Kitaoka 6526c7
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "./mov/tiio_mov.h"
Toshihiro Shimizu 890ddd
#include "./3gp/tiio_3gp.h"
Toshihiro Shimizu 890ddd
#include "./zcc/tiio_zcc.h"
Toshihiro Shimizu 890ddd
Campbell Barton d869b5
#elif defined(MACOSX)
Toshihiro Shimizu 890ddd
#include "./mov/tiio_movM.h"
Toshihiro Shimizu 890ddd
#include "./3gp/tiio_3gpM.h"
Toshihiro Shimizu 890ddd
Rozhuk Ivan ac51ab
#elif defined(LINUX) || defined(FREEBSD)  // No more supported by the way...
Campbell Barton 89a491
// #include "./mov/tiio_movL.h"
Campbell Barton 89a491
#include "./mov/tiio_mov_proxy.h"
Campbell Barton 89a491
#include "./3gp/tiio_3gp_proxy.h"
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// Common includes
Toshihiro Shimizu 890ddd
#include "./quantel/tiio_quantel.h"
Toshihiro Shimizu 890ddd
#include "./sgi/tiio_sgi.h"
Toshihiro Shimizu 890ddd
#include "./tga/tiio_tga.h"
Toshihiro Shimizu 890ddd
#include "./png/tiio_png.h"
Rozhuk Ivan ac51ab
/* Can't build this on FreeBSD: libtiff requires internal API access.
Rozhuk Ivan ac51ab
 * Probably some one get luck to fix this. */
Rozhuk Ivan ac51ab
#ifndef FREEBSD
Toshihiro Shimizu 890ddd
#include "./tif/tiio_tif.h"
Toshihiro Shimizu 890ddd
#include "./tzp/tiio_tzp.h"
Toshihiro Shimizu 890ddd
#include "./tzp/tiio_plt.h"
Rozhuk Ivan ac51ab
#endif
Toshihiro Shimizu 890ddd
#include "./psd/tiio_psd.h"
Toshihiro Shimizu 890ddd
#include "./avi/tiio_avi.h"
Toshihiro Shimizu 890ddd
#include "./pli/tiio_pli.h"
Toshihiro Shimizu 890ddd
#include "./tzl/tiio_tzl.h"
Toshihiro Shimizu 890ddd
#include "./svg/tiio_svg.h"
turtletooth 04d8fd
#include "./ffmpeg/tiio_gif.h"
turtletooth 04d8fd
#include "./ffmpeg/tiio_webm.h"
turtletooth 04d8fd
#include "./ffmpeg/tiio_mp4.h"
justburner 64e039
#include "./ffmpeg/tiio_apng.h"
justburner 64e039
#include "./ffmpeg/tiio_ff_mov.h"
Toshihiro Shimizu 890ddd
#include "./mesh/tiio_mesh.h"
Jeremy Bullock 764038
#include "./sprite/tiio_sprite.h"
shun-iwasawa 7bad49
#include "./exr/tiio_exr.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// static TPluginInfo info("imageIOPlugin");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TLIBMAIN
Shinya Kitaoka 120a6e
void initImageIo(bool lightVersion) {
Shinya Kitaoka 120a6e
  if (!lightVersion) {
Shinya Kitaoka 120a6e
    TLevelWriter::define("pli", TLevelWriterPli::create, false);
Shinya Kitaoka 120a6e
    TLevelReader::define("pli", TLevelReaderPli::create);
Shinya Kitaoka 120a6e
    TFileType::declare("pli", TFileType::VECTOR_LEVEL);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TLevelReader::define("svg", 0, TLevelReaderSvg::create);
Shinya Kitaoka 120a6e
    TFileType::declare("svg", TFileType::VECTOR_LEVEL);
Shinya Kitaoka 120a6e
    TLevelWriter::define("svg", TLevelWriterSvg::create, false);
Shinya Kitaoka 120a6e
    Tiio::defineWriterProperties("svg", new Tiio::SvgWriterProperties());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TLevelWriter::define("tzl", TLevelWriterTzl::create, false);
Shinya Kitaoka 120a6e
    TLevelReader::define("tzl", TLevelReaderTzl::create);
Shinya Kitaoka 120a6e
    TFileType::declare("tzl", TFileType::RASTER_LEVEL);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TLevelWriter::define("tlv", TLevelWriterTzl::create, false);
Shinya Kitaoka 120a6e
    TLevelReader::define("tlv", TLevelReaderTzl::create);
Shinya Kitaoka 120a6e
    TFileType::declare("tlv", TFileType::CMAPPED_LEVEL);
Shinya Kitaoka 120a6e
Rozhuk Ivan ac51ab
/* Can't build this on FreeBSD: libtiff requires internal API access.
Rozhuk Ivan ac51ab
 * Probably some one get luck to fix this. */
Rozhuk Ivan ac51ab
#ifndef FREEBSD
Shinya Kitaoka 120a6e
    Tiio::defineReaderMaker("tzp", Tiio::makeTzpReader);
Shinya Kitaoka 120a6e
    Tiio::defineWriterMaker("tzp", Tiio::makeTzpWriter, false);
Shinya Kitaoka 120a6e
    TFileType::declare("tzp", TFileType::CMAPPED_IMAGE);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    Tiio::defineReaderMaker("tzu", Tiio::makeTzpReader);
Shinya Kitaoka 120a6e
    Tiio::defineWriterMaker("tzu", Tiio::makeTzpWriter, false);
Shinya Kitaoka 120a6e
    TFileType::declare("tzu", TFileType::CMAPPED_IMAGE);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    Tiio::defineReaderMaker("tzi", Tiio::makeTziReader);
Shinya Kitaoka 120a6e
    TFileType::declare("tzi", TFileType::RASTER_IMAGE);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    Tiio::defineReaderMaker("plt", Tiio::makePltReader);
Shinya Kitaoka 120a6e
    Tiio::defineWriterMaker("plt", Tiio::makePltWriter, false);
Shinya Kitaoka 120a6e
    TFileType::declare("plt", TFileType::RASTER_IMAGE);
Rozhuk Ivan ac51ab
#endif
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    Tiio::defineReaderMaker("nol", Tiio::makePngReader);
Shinya Kitaoka 120a6e
    Tiio::defineWriterMaker("nol", Tiio::makePngWriter, true);
Shinya Kitaoka 120a6e
    TFileType::declare("nol", TFileType::RASTER_IMAGE);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TLevelWriter::define("psd", TLevelWriterPsd::create, false);
Shinya Kitaoka 120a6e
    TLevelReader::define("psd", TLevelReaderPsd::create);
Shinya Kitaoka 120a6e
    TFileType::declare("psd", TFileType::RASTER_LEVEL);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TLevelWriter::define("mesh", TLevelWriterMesh::create, false);
Shinya Kitaoka 120a6e
    TLevelReader::define("mesh", TLevelReaderMesh::create);
Shinya Kitaoka 120a6e
    TFileType::declare("mesh", TFileType::MESH_IMAGE);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  }  // !lightversion
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TFileType::declare("tpl", TFileType::PALETTE_LEVEL);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Tiio::defineReaderMaker("png", Tiio::makePngReader);
Shinya Kitaoka 120a6e
  Tiio::defineWriterMaker("png", Tiio::makePngWriter, true);
Shinya Kitaoka 120a6e
  TFileType::declare("png", TFileType::RASTER_IMAGE);
Shinya Kitaoka 120a6e
  Tiio::defineWriterProperties("png", new Tiio::PngWriterProperties());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Tiio::defineReaderMaker("tga", Tiio::makeTgaReader);
Shinya Kitaoka 120a6e
  Tiio::defineWriterMaker("tga", Tiio::makeTgaWriter, true);
Shinya Kitaoka 120a6e
  TFileType::declare("tga", TFileType::RASTER_IMAGE);
Shinya Kitaoka 120a6e
  Tiio::defineWriterProperties("tga", new Tiio::TgaWriterProperties());
Shinya Kitaoka 120a6e
Rozhuk Ivan ac51ab
/* Can't build this on FreeBSD: libtiff requires internal API access.
Rozhuk Ivan ac51ab
 * Probably some one get luck to fix this. */
Rozhuk Ivan ac51ab
#ifndef FREEBSD
Shinya Kitaoka 120a6e
  Tiio::defineReaderMaker("tif", Tiio::makeTifReader);
Shinya Kitaoka 120a6e
  Tiio::defineWriterMaker("tif", Tiio::makeTifWriter, true);
Shinya Kitaoka 120a6e
  TFileType::declare("tif", TFileType::RASTER_IMAGE);
Shinya Kitaoka 120a6e
  Tiio::defineWriterProperties("tif", new Tiio::TifWriterProperties());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Tiio::defineReaderMaker("tiff", Tiio::makeTifReader);
Shinya Kitaoka 120a6e
  Tiio::defineWriterMaker("tiff", Tiio::makeTifWriter, true);
Shinya Kitaoka 120a6e
  TFileType::declare("tiff", TFileType::RASTER_IMAGE);
Shinya Kitaoka 120a6e
  Tiio::defineWriterProperties("tiff", new Tiio::TifWriterProperties());
Rozhuk Ivan ac51ab
#endif
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Tiio::defineReaderMaker("sgi", Tiio::makeSgiReader);
Shinya Kitaoka 120a6e
  Tiio::defineWriterMaker("sgi", Tiio::makeSgiWriter, true);
Shinya Kitaoka 120a6e
  TFileType::declare("sgi", TFileType::RASTER_IMAGE);
Shinya Kitaoka 120a6e
  Tiio::defineWriterProperties("sgi", new Tiio::SgiWriterProperties());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Tiio::defineReaderMaker("rgb", Tiio::makeSgiReader);
Shinya Kitaoka 120a6e
  Tiio::defineWriterMaker("rgb", Tiio::makeSgiWriter, true);
Shinya Kitaoka 120a6e
  TFileType::declare("rgb", TFileType::RASTER_IMAGE);
Shinya Kitaoka 120a6e
  Tiio::defineWriterProperties("rgb", new Tiio::SgiWriterProperties());
Shinya Kitaoka 120a6e
Jeremy Bullock 764038
  TLevelWriter::define("spritesheet", TLevelWriterSprite::create, true);
Jeremy Bullock 764038
  TFileType::declare("spritesheet", TFileType::RASTER_LEVEL);
Jeremy Bullock 764038
  Tiio::defineWriterProperties("spritesheet",
Jeremy Bullock 764038
                               new Tiio::SpriteWriterProperties());
Jeremy Bullock 764038
shun-iwasawa 7bad49
  Tiio::defineReaderMaker("exr", Tiio::makeExrReader);
shun-iwasawa 7bad49
  Tiio::defineWriterMaker("exr", Tiio::makeExrWriter, true);
shun-iwasawa 7bad49
  TFileType::declare("exr", TFileType::RASTER_IMAGE);
shun-iwasawa 7bad49
  Tiio::defineWriterProperties("exr", new Tiio::ExrWriterProperties());
shun-iwasawa 7bad49
shun-iwasawa 27b0cf
// ffmpeg
db7f14
#if !defined(_WIN32) || defined(x64) || (defined(_WIN32) && defined(__GNUC__))
justburner 64e039
  if (ThirdParty::checkFFmpeg()) {
shun-iwasawa 27b0cf
    if (Ffmpeg::checkFormat("webm")) {
shun-iwasawa 27b0cf
      TLevelWriter::define("webm", TLevelWriterWebm::create, true);
justburner 64e039
      TLevelReader::define("webm", TLevelReaderWebm::create);
shun-iwasawa 27b0cf
      TFileType::declare("webm", TFileType::RASTER_LEVEL);
shun-iwasawa 27b0cf
      Tiio::defineWriterProperties("webm", new Tiio::WebmWriterProperties());
shun-iwasawa 27b0cf
    }
shun-iwasawa 27b0cf
    if (Ffmpeg::checkFormat("gif")) {
shun-iwasawa 27b0cf
      TLevelWriter::define("gif", TLevelWriterGif::create, true);
justburner 64e039
      TLevelReader::define("gif", TLevelReaderGif::create);
shun-iwasawa 27b0cf
      TFileType::declare("gif", TFileType::RASTER_LEVEL);
shun-iwasawa 27b0cf
      Tiio::defineWriterProperties("gif", new Tiio::GifWriterProperties());
shun-iwasawa 27b0cf
    }
shun-iwasawa 27b0cf
    if (Ffmpeg::checkFormat("mp4")) {
shun-iwasawa 27b0cf
      TLevelWriter::define("mp4", TLevelWriterMp4::create, true);
justburner 64e039
      TLevelReader::define("mp4", TLevelReaderMp4::create);
shun-iwasawa 27b0cf
      TFileType::declare("mp4", TFileType::RASTER_LEVEL);
shun-iwasawa 27b0cf
      Tiio::defineWriterProperties("mp4", new Tiio::Mp4WriterProperties());
shun-iwasawa 27b0cf
    }
justburner 64e039
    if (Ffmpeg::checkFormat("apng")) {
justburner 64e039
      TLevelWriter::define("apng", TLevelWriterAPng::create, true);
justburner 64e039
      TLevelReader::define("apng", TLevelReaderAPng::create);
justburner 64e039
      TFileType::declare("apng", TFileType::RASTER_LEVEL);
justburner 64e039
      Tiio::defineWriterProperties("apng", new Tiio::APngWriterProperties());
justburner 64e039
    }
justburner 64e039
    if (!IsQuickTimeInstalled()) {
justburner 64e039
      if (Ffmpeg::checkFormat("mov")) {
justburner 64e039
        TLevelWriter::define("mov", TLevelWriterFFMov::create, true);
justburner 64e039
        TLevelReader::define("mov", TLevelReaderFFMov::create);
justburner 64e039
        TFileType::declare("mov", TFileType::RASTER_LEVEL);
justburner 64e039
        Tiio::defineWriterProperties("mov", new Tiio::FFMovWriterProperties());
justburner 64e039
      }
justburner 64e039
      if (Ffmpeg::checkFormat("3gp")) {
justburner 64e039
        TLevelReader::define("3gp", TLevelReaderFFmpeg::create);
justburner 64e039
        TFileType::declare("3gp", TFileType::RASTER_LEVEL);
justburner 64e039
      }
justburner 64e039
    }
justburner 64e039
    TLevelReader::define("webp", TLevelReaderFFmpeg::create);
justburner 64e039
    TFileType::declare("webp", TFileType::RASTER_LEVEL);
justburner 64e039
    TLevelReader::define("ffvideo", TLevelReaderFFmpeg::create);
justburner 64e039
    TFileType::declare("ffvideo", TFileType::RASTER_LEVEL);
turtletooth 04d8fd
  }
turtletooth 04d8fd
#endif
turtletooth 04d8fd
  // end ffmpeg
turtletooth 04d8fd
Shinya Kitaoka 120a6e
  if (!lightVersion) {
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    TLevelWriter::define("avi", TLevelWriterAvi::create, true);
Shinya Kitaoka 120a6e
    TLevelReader::define("avi", TLevelReaderAvi::create);
Shinya Kitaoka 120a6e
    TFileType::declare("avi", TFileType::RASTER_LEVEL);
Shinya Kitaoka 120a6e
    Tiio::defineWriterProperties("avi", new Tiio::AviWriterProperties());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // _WIN32
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    if (IsQuickTimeInstalled()) {
justburner f0c501
      Tiio::useQuicktime(true);
justburner f0c501
Shinya Kitaoka 120a6e
      TLevelWriter::define("mov", TLevelWriterMov::create, true);
Shinya Kitaoka 120a6e
      TLevelReader::define("mov", TLevelReaderMov::create);
Shinya Kitaoka 120a6e
      TFileType::declare("mov", TFileType::RASTER_LEVEL);
Shinya Kitaoka 120a6e
      Tiio::defineWriterProperties("mov", new Tiio::MovWriterProperties());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
      TLevelWriter::define("3gp", TLevelWriter3gp::create, true);
Shinya Kitaoka 120a6e
      TLevelReader::define("3gp", TLevelReader3gp::create);
Shinya Kitaoka 120a6e
      TFileType::declare("3gp", TFileType::RASTER_LEVEL);
Shinya Kitaoka 120a6e
      Tiio::defineWriterProperties("3gp", new Tiio::MovWriterProperties());
Shinya Kitaoka 120a6e
    }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    /*
Shinya Kitaoka 9f5a1b
#if (defined(_WIN32) && !defined(x64))
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TLevelWriter::define("pct", TLevelWriterPicPct::create, true);
Shinya Kitaoka 120a6e
TLevelReader::define("pct", TLevelReaderPicPct::create);
Shinya Kitaoka 120a6e
TFileType::declare("pct", TFileType::RASTER_LEVEL);
Shinya Kitaoka 120a6e
Tiio::defineWriterProperties("pct", new Tiio::PctWriterProperties());
Shinya Kitaoka 120a6e
TLevelWriter::define("pic", TLevelWriterPicPct::create, true);
Shinya Kitaoka 120a6e
TLevelReader::define("pic", TLevelReaderPicPct::create);
Shinya Kitaoka 120a6e
TFileType::declare("pic", TFileType::RASTER_LEVEL);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TLevelWriter::define("pict", TLevelWriterPicPct::create, true);
Shinya Kitaoka 120a6e
TLevelReader::define("pict", TLevelReaderPicPct::create);
Shinya Kitaoka 120a6e
TFileType::declare("pict", TFileType::RASTER_LEVEL);
Shinya Kitaoka 120a6e
Tiio::defineWriterProperties("pict", new Tiio::PctWriterProperties());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#endif    // _WIN32 && 32-bit
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}