1 #pragma once 2 3 #ifndef TRASTERIMAGE_INCLUDED 4 #define TRASTERIMAGE_INCLUDED 5 6 #include "timage.h" 7 #include "traster.h" 8 9 #undef DVAPI 10 #undef DVVAR 11 #ifdef TRASTERIMAGE_EXPORTS 12 #define DVAPI DV_EXPORT_API 13 #define DVVAR DV_EXPORT_VAR 14 #else 15 #define DVAPI DV_IMPORT_API 16 #define DVVAR DV_IMPORT_VAR 17 #endif 18 19 //------------------------------------------------------------------- 20 21 //! An image containing a raster. 22 23 /*! 24 Some examples: 25 \include rasterImage_ex.cpp 26 */ 27 28 class DVAPI TRasterImage final : public TImage { 29 TRasterP m_mainRaster, m_patchRaster, m_iconRaster; 30 31 //! dpi value for x axis 32 double m_dpix, 33 //! dpi value for y axis 34 m_dpiy; 35 //! The name of the image 36 std::string m_name; 37 //! The savebox of the image 38 TRect m_savebox; 39 // double m_hPos; 40 //! Specify if the image is an opaque image. 41 bool m_isOpaque; 42 //! Specify if the image is a BW Scan image. 43 bool m_isScanBW; 44 45 //! The offset of the image 46 TPoint m_offset; 47 48 int m_subsampling; 49 50 public: 51 TRasterImage(); 52 TRasterImage(const TRasterP &raster); 53 ~TRasterImage(); 54 55 private: 56 //! Is used to clone an existing ToonzImage. 57 TRasterImage(const TRasterImage &); 58 59 //! not implemented 60 TRasterImage &operator=(const TRasterImage &); 61 62 public: 63 //! Return the image type getType()64 TImage::Type getType() const override { return TImage::RASTER; } 65 66 // image info 67 //! Return the name of the image getName()68 std::string getName() const { return m_name; } 69 //! Set the name of the image setName(std::string name)70 void setName(std::string name) { m_name = name; } 71 72 //! Get the \b dpi image getDpi(double & dpix,double & dpiy)73 void getDpi(double &dpix, double &dpiy) const { 74 dpix = m_dpix; 75 dpiy = m_dpiy; 76 } 77 //! Set the \b dpi image setDpi(double dpix,double dpiy)78 void setDpi(double dpix, double dpiy) { 79 m_dpix = dpix; 80 m_dpiy = dpiy; 81 } 82 getSubsampling()83 int getSubsampling() const { return m_subsampling; } 84 void setSubsampling(int s); 85 86 //! Return the save box of the image getSavebox()87 TRect getSavebox() const { return m_savebox; } 88 //! Set the save box of the image setSavebox(const TRect & rect)89 void setSavebox(const TRect &rect) { m_savebox = rect; } 90 91 //! Return the bbox of the image getBBox()92 TRectD getBBox() const override { return convert(m_savebox); } 93 94 //! Return raster image offset \b m_offset getOffset()95 TPoint getOffset() const { return m_offset; } 96 //! Set raster image offset \b m_offset setOffset(const TPoint & offset)97 void setOffset(const TPoint &offset) { m_offset = offset; } 98 99 //! Return raster hPos \b m_hPos 100 // double gethPos() const {return m_hPos;} 101 //! Set raster hPos \b m_hPos 102 // void sethPos(double hPos) {m_hPos= hPos;} 103 104 //! Return a clone of image 105 TImage *cloneImage() const override; 106 107 //! Return \b TRasterP getRaster()108 const TRasterP &getRaster() const { return m_mainRaster; } 109 //! Return \b TRasterP getRaster()110 TRasterP &getRaster() { return m_mainRaster; } 111 raster()112 TRasterP raster() const override { return m_mainRaster; } 113 114 //! Set the \b TRasterP \b raster 115 void setRaster(const TRasterP &raster); 116 117 //! Return a \b TRasterP contained the icon of the image \b m_iconRaster getIconRaster()118 const TRasterP &getIconRaster() const { return m_iconRaster; } 119 //! Return a \b TRasterP contained the icon of the image \b m_iconRaster getIconRaster()120 TRasterP &getIconRaster() { return m_iconRaster; } 121 //! Set a \b TRasterP contained the icon of the image \b m_iconRaster setIconRaster(const TRasterP & raster)122 void setIconRaster(const TRasterP &raster) { m_iconRaster = raster; } 123 124 //! Return true if the raster is empty isEmpty()125 bool isEmpty() const { return !m_mainRaster; } 126 127 //! Return true if the raster comes from BW Scan isScanBW()128 bool isScanBW() const { return m_isScanBW; } setScanBWFlag(bool isScanBW)129 void setScanBWFlag(bool isScanBW) { m_isScanBW = isScanBW; } 130 131 //! Return true if the raster is opaque 132 isOpaque()133 bool isOpaque() const { return m_isOpaque; } setOpaqueFlag(bool isOpaque)134 void setOpaqueFlag(bool isOpaque) { m_isOpaque = isOpaque; } 135 136 //! Make the icon of the raster. 137 void makeIcon(const TRaster32P &raster); 138 }; 139 140 //------------------------------------------------------------------- 141 142 #ifdef _WIN32 143 template class DVAPI TSmartPointerT<TRasterImage>; 144 template class DVAPI TDerivedSmartPointerT<TRasterImage, TImage>; 145 #endif 146 147 class DVAPI TRasterImageP final 148 : public TDerivedSmartPointerT<TRasterImage, TImage> { 149 public: TRasterImageP()150 TRasterImageP() {} TRasterImageP(TRasterImage * image)151 TRasterImageP(TRasterImage *image) : DerivedSmartPointer(image) {} TRasterImageP(TImageP image)152 TRasterImageP(TImageP image) : DerivedSmartPointer(image) {} TRasterImageP(const TRasterP & ras)153 TRasterImageP(const TRasterP &ras) 154 : DerivedSmartPointer(new TRasterImage(ras)) {} TImageP()155 operator TImageP() { return TImageP(m_pointer); } 156 }; 157 158 #endif 159