turtletooth 04d8fd
#pragma once
turtletooth 04d8fd
turtletooth 04d8fd
#ifndef TTIO_GIF_INCLUDED
turtletooth 04d8fd
#define TTIO_GIF_INCLUDED
turtletooth 04d8fd
turtletooth 04d8fd
#include "tproperty.h"
turtletooth 04d8fd
#include "tlevel_io.h"
turtletooth 04d8fd
#include "tiio_ffmpeg.h"
turtletooth 04d8fd
//#include "tthreadmessage.h"
turtletooth 04d8fd
shun-iwasawa e87e08
#include <qcoreapplication></qcoreapplication>
shun-iwasawa e87e08
turtletooth 04d8fd
//===========================================================
turtletooth 04d8fd
//
turtletooth 04d8fd
//  TLevelWriterGif
turtletooth 04d8fd
//
turtletooth 04d8fd
//===========================================================
turtletooth 04d8fd
turtletooth 04d8fd
class TLevelWriterGif : public TLevelWriter {
turtletooth 04d8fd
public:
turtletooth 04d8fd
  TLevelWriterGif(const TFilePath &path, TPropertyGroup *winfo);
turtletooth 04d8fd
  ~TLevelWriterGif();
turtletooth 04d8fd
  // FfmpegBridge* ffmpeg;
turtletooth 04d8fd
  void setFrameRate(double fps);
turtletooth 04d8fd
turtletooth 04d8fd
  TImageWriterP getFrameWriter(TFrameId fid) override;
turtletooth 04d8fd
  void save(const TImageP &image, int frameIndex);
turtletooth 04d8fd
turtletooth 04d8fd
  void saveSoundTrack(TSoundTrack *st);
turtletooth 04d8fd
turtletooth 04d8fd
  static TLevelWriter *create(const TFilePath &path, TPropertyGroup *winfo) {
turtletooth 04d8fd
    return new TLevelWriterGif(path, winfo);
turtletooth 04d8fd
  }
turtletooth 04d8fd
turtletooth 04d8fd
private:
turtletooth 04d8fd
  Ffmpeg *ffmpegWriter;
turtletooth 04d8fd
  int m_frameCount, m_lx, m_ly;
turtletooth 04d8fd
  // double m_fps;
turtletooth 04d8fd
  int m_scale;
turtletooth 04d8fd
  bool m_looping = false;
turtletooth 04d8fd
  bool m_palette = false;
turtletooth 04d8fd
};
turtletooth 04d8fd
turtletooth 04d8fd
//===========================================================
turtletooth 04d8fd
//
turtletooth 04d8fd
//  TLevelReaderGif
turtletooth 04d8fd
//
turtletooth 04d8fd
//===========================================================
turtletooth 04d8fd
turtletooth 04d8fd
class TLevelReaderGif final : public TLevelReader {
turtletooth 04d8fd
public:
turtletooth 04d8fd
  TLevelReaderGif(const TFilePath &path);
turtletooth 04d8fd
  ~TLevelReaderGif();
turtletooth 04d8fd
  TImageReaderP getFrameReader(TFrameId fid) override;
turtletooth 04d8fd
turtletooth 04d8fd
  static TLevelReader *create(const TFilePath &f) {
turtletooth 04d8fd
    return new TLevelReaderGif(f);
turtletooth 04d8fd
  }
turtletooth 04d8fd
turtletooth 04d8fd
  TLevelP loadInfo() override;
turtletooth 04d8fd
  TImageP load(int frameIndex);
turtletooth 04d8fd
  TDimension getSize();
turtletooth 04d8fd
  // TThread::Mutex m_mutex;
turtletooth 04d8fd
  // void *m_decompressedBuffer;
turtletooth 04d8fd
private:
turtletooth 04d8fd
  Ffmpeg *ffmpegReader;
manongjohn f2da01
  bool ffmpegFramesCreated = false;
turtletooth 04d8fd
  TDimension m_size;
turtletooth 04d8fd
  int m_frameCount, m_lx, m_ly;
turtletooth 04d8fd
};
turtletooth 04d8fd
turtletooth 04d8fd
//===========================================================================
turtletooth 04d8fd
turtletooth 04d8fd
namespace Tiio {
turtletooth 04d8fd
turtletooth 04d8fd
//===========================================================================
turtletooth 04d8fd
turtletooth 04d8fd
class GifWriterProperties : public TPropertyGroup {
shun-iwasawa e87e08
  Q_DECLARE_TR_FUNCTIONS(GifWriterProperties)
shun-iwasawa e87e08
turtletooth 04d8fd
public:
turtletooth 04d8fd
  TIntProperty m_scale;
turtletooth 04d8fd
  TBoolProperty m_looping;
turtletooth 04d8fd
  TBoolProperty m_palette;
turtletooth 04d8fd
  GifWriterProperties();
shun-iwasawa e87e08
shun-iwasawa e87e08
  void updateTranslation() override;
turtletooth 04d8fd
};
turtletooth 04d8fd
turtletooth 04d8fd
//===========================================================================
turtletooth 04d8fd
turtletooth 04d8fd
// Tiio::Reader *makeGifReader();
turtletooth 04d8fd
// Tiio::Writer *makeGifWriter();
turtletooth 04d8fd
turtletooth 04d8fd
}  // namespace
turtletooth 04d8fd
turtletooth 04d8fd
#endif