Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TRASTERIMAGE_INCLUDED
Toshihiro Shimizu 890ddd
#define TRASTERIMAGE_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "timage.h"
Toshihiro Shimizu 890ddd
#include "traster.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TRASTERIMAGE_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! An image containing a raster.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Some examples:
Toshihiro Shimizu 890ddd
 \include rasterImage_ex.cpp
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TRasterImage : public TImage {
Shinya Kitaoka 120a6e
  TRasterP m_mainRaster, m_patchRaster, m_iconRaster;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! dpi value for x axis
Shinya Kitaoka 120a6e
  double m_dpix,
Shinya Kitaoka 120a6e
      //! dpi value for y axis
Shinya Kitaoka 120a6e
      m_dpiy;
Shinya Kitaoka 120a6e
  //! The name of the image
Shinya Kitaoka 120a6e
  std::string m_name;
Shinya Kitaoka 120a6e
  //! The savebox of the image
Shinya Kitaoka 120a6e
  TRect m_savebox;
Shinya Kitaoka 120a6e
  // double m_hPos;
Shinya Kitaoka 120a6e
  //! Specify if the image is an opaque image.
Shinya Kitaoka 120a6e
  bool m_isOpaque;
Shinya Kitaoka 120a6e
  //! Specify if the image is a BW Scan image.
Shinya Kitaoka 120a6e
  bool m_isScanBW;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! The offset of the image
Shinya Kitaoka 120a6e
  TPoint m_offset;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int m_subsampling;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TRasterImage();
Shinya Kitaoka 120a6e
  TRasterImage(const TRasterP &raster);
Shinya Kitaoka 120a6e
  ~TRasterImage();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  //! Is used to clone an existing ToonzImage.
Shinya Kitaoka 120a6e
  TRasterImage(const TRasterImage &);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! not implemented
Shinya Kitaoka 120a6e
  TRasterImage &operator=(const TRasterImage &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  //! Return the image type
Shinya Kitaoka 473e70
  TImage::Type getType() const override { return TImage::RASTER; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // image info
Shinya Kitaoka 120a6e
  //! Return the name of the image
Shinya Kitaoka 120a6e
  std::string getName() const { return m_name; }
Shinya Kitaoka 120a6e
  //! Set the name of the image
Shinya Kitaoka 120a6e
  void setName(std::string name) { m_name = name; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Get the \b dpi image
Shinya Kitaoka 120a6e
  void getDpi(double &dpix, double &dpiy) const {
Shinya Kitaoka 120a6e
    dpix = m_dpix;
Shinya Kitaoka 120a6e
    dpiy = m_dpiy;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  //! Set the \b dpi image
Shinya Kitaoka 120a6e
  void setDpi(double dpix, double dpiy) {
Shinya Kitaoka 120a6e
    m_dpix = dpix;
Shinya Kitaoka 120a6e
    m_dpiy = dpiy;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getSubsampling() const { return m_subsampling; }
Shinya Kitaoka 120a6e
  void setSubsampling(int s);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return the save box of the image
Shinya Kitaoka 120a6e
  TRect getSavebox() const { return m_savebox; }
Shinya Kitaoka 120a6e
  //! Set the save box of the image
Shinya Kitaoka 120a6e
  void setSavebox(const TRect &rect) { m_savebox = rect; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return the bbox of the image
Shinya Kitaoka 473e70
  TRectD getBBox() const override { return convert(m_savebox); }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return raster image offset \b m_offset
Shinya Kitaoka 120a6e
  TPoint getOffset() const { return m_offset; }
Shinya Kitaoka 120a6e
  //! Set raster image offset \b m_offset
Shinya Kitaoka 120a6e
  void setOffset(const TPoint &offset) { m_offset = offset; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return raster hPos \b m_hPos
Shinya Kitaoka 120a6e
  // double gethPos() const {return m_hPos;}
Shinya Kitaoka 120a6e
  //! Set raster hPos \b m_hPos
Shinya Kitaoka 120a6e
  // void sethPos(double hPos) {m_hPos= hPos;}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return a clone of image
Shinya Kitaoka 473e70
  TImage *cloneImage() const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return \b TRasterP
Shinya Kitaoka 120a6e
  const TRasterP &getRaster() const { return m_mainRaster; }
Shinya Kitaoka 120a6e
  //! Return \b TRasterP
Shinya Kitaoka 120a6e
  TRasterP &getRaster() { return m_mainRaster; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  TRasterP raster() const override { return m_mainRaster; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Set the \b TRasterP \b raster
Shinya Kitaoka 120a6e
  void setRaster(const TRasterP &raster);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return a \b TRasterP contained the icon of the image \b m_iconRaster
Shinya Kitaoka 120a6e
  const TRasterP &getIconRaster() const { return m_iconRaster; }
Shinya Kitaoka 120a6e
  //! Return a \b TRasterP contained the icon of the image \b m_iconRaster
Shinya Kitaoka 120a6e
  TRasterP &getIconRaster() { return m_iconRaster; }
Shinya Kitaoka 120a6e
  //! Set a \b TRasterP contained the icon of the image \b m_iconRaster
Shinya Kitaoka 120a6e
  void setIconRaster(const TRasterP &raster) { m_iconRaster = raster; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return true if the raster is empty
Shinya Kitaoka 120a6e
  bool isEmpty() const { return !m_mainRaster; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return true if the raster comes from BW Scan
Shinya Kitaoka 120a6e
  bool isScanBW() const { return m_isScanBW; }
Shinya Kitaoka 120a6e
  void setScanBWFlag(bool isScanBW) { m_isScanBW = isScanBW; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Return true if the raster is opaque
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isOpaque() const { return m_isOpaque; }
Shinya Kitaoka 120a6e
  void setOpaqueFlag(bool isOpaque) { m_isOpaque = isOpaque; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Make the icon of the raster.
Shinya Kitaoka 120a6e
  void makeIcon(const TRaster32P &raster);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
template class DVAPI TSmartPointerT<trasterimage>;</trasterimage>
Toshihiro Shimizu 890ddd
template class DVAPI TDerivedSmartPointerT<trasterimage, timage="">;</trasterimage,>
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TRasterImageP : public TDerivedSmartPointerT<trasterimage, timage=""> {</trasterimage,>
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TRasterImageP() {}
Shinya Kitaoka 120a6e
  TRasterImageP(TRasterImage *image) : DerivedSmartPointer(image) {}
Shinya Kitaoka 120a6e
  TRasterImageP(TImageP image) : DerivedSmartPointer(image) {}
Shinya Kitaoka 120a6e
  TRasterImageP(const TRasterP &ras)
Shinya Kitaoka 120a6e
      : DerivedSmartPointer(new TRasterImage(ras)) {}
Shinya Kitaoka 120a6e
  operator TImageP() { return TImageP(m_pointer); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif