justburner 64e039
#pragma once
justburner 64e039
justburner 64e039
#ifndef TTIO_APNG_INCLUDED
justburner 64e039
#define TTIO_APNG_INCLUDED
justburner 64e039
justburner 64e039
#include "tproperty.h"
justburner 64e039
#include "tlevel_io.h"
justburner 64e039
#include "tiio_ffmpeg.h"
justburner 64e039
#include <qcoreapplication></qcoreapplication>
justburner 64e039
justburner 64e039
//===========================================================
justburner 64e039
//
justburner 64e039
//  TLevelWriterAPng
justburner 64e039
//
justburner 64e039
//===========================================================
justburner 64e039
justburner 64e039
class TLevelWriterAPng : public TLevelWriter {
justburner 64e039
public:
justburner 64e039
  TLevelWriterAPng(const TFilePath &path, TPropertyGroup *winfo);
justburner 64e039
  ~TLevelWriterAPng();
justburner 64e039
  void setFrameRate(double fps) override;
justburner 64e039
justburner 64e039
  TImageWriterP getFrameWriter(TFrameId fid) override;
justburner 64e039
  void save(const TImageP &image, int frameIndex);
justburner 64e039
justburner 64e039
  void saveSoundTrack(TSoundTrack *st) override;
justburner 64e039
justburner 64e039
  static TLevelWriter *create(const TFilePath &path, TPropertyGroup *winfo) {
justburner 64e039
    return new TLevelWriterAPng(path, winfo);
justburner 64e039
  }
justburner 64e039
justburner 64e039
private:
justburner 64e039
  Ffmpeg *ffmpegWriter;
justburner 64e039
  int m_lx, m_ly;
justburner 64e039
  int m_scale;
justburner 64e039
  bool m_looping;
justburner 64e039
  bool m_extPng;
justburner 64e039
};
justburner 64e039
justburner 64e039
//===========================================================
justburner 64e039
//
justburner 64e039
//  TLevelReaderAPng
justburner 64e039
//
justburner 64e039
//===========================================================
justburner 64e039
justburner 64e039
class TLevelReaderAPng final : public TLevelReader {
justburner 64e039
public:
justburner 64e039
  TLevelReaderAPng(const TFilePath &path);
justburner 64e039
  ~TLevelReaderAPng();
justburner 64e039
  TImageReaderP getFrameReader(TFrameId fid) override;
justburner 64e039
justburner 64e039
  static TLevelReader *create(const TFilePath &f) {
justburner 64e039
    return new TLevelReaderAPng(f);
justburner 64e039
  }
justburner 64e039
justburner 64e039
  TLevelP loadInfo() override;
justburner 64e039
  TImageP load(int frameIndex);
justburner 64e039
  TDimension getSize();
justburner 64e039
private:
justburner 64e039
  Ffmpeg *ffmpegReader;
justburner 64e039
  bool ffmpegFramesCreated = false;
justburner 64e039
  TDimension m_size;
justburner 64e039
  int m_frameCount, m_lx, m_ly;
justburner 64e039
};
justburner 64e039
justburner 64e039
//===========================================================================
justburner 64e039
justburner 64e039
namespace Tiio {
justburner 64e039
justburner 64e039
//===========================================================================
justburner 64e039
justburner 64e039
class APngWriterProperties : public TPropertyGroup {
justburner 64e039
  Q_DECLARE_TR_FUNCTIONS(APngWriterProperties)
justburner 64e039
public:
justburner 64e039
  TIntProperty m_scale;
justburner 64e039
  TBoolProperty m_looping;
justburner 64e039
  TBoolProperty m_extPng;
justburner 64e039
  APngWriterProperties();
justburner 64e039
  void updateTranslation() override;
justburner 64e039
};
justburner 64e039
justburner 64e039
//===========================================================================
justburner 64e039
justburner 64e039
}  // namespace Tiio
justburner 64e039
justburner 64e039
#endif