Toshihiro Shimizu 890ddd
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
Toshihiro Shimizu 890ddd
class DVAPI TRasterImage : public TImage
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterP m_mainRaster, m_patchRaster, m_iconRaster;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! dpi value for x axis
Toshihiro Shimizu 890ddd
	double m_dpix,
Toshihiro Shimizu 890ddd
		//! dpi value for y axis
Toshihiro Shimizu 890ddd
		m_dpiy;
Toshihiro Shimizu 890ddd
	//! The name of the image
Toshihiro Shimizu 890ddd
	string m_name;
Toshihiro Shimizu 890ddd
	//! The savebox of the image
Toshihiro Shimizu 890ddd
	TRect m_savebox;
Toshihiro Shimizu 890ddd
	//double m_hPos;
Toshihiro Shimizu 890ddd
	//! Specify if the image is an opaque image.
Toshihiro Shimizu 890ddd
	bool m_isOpaque;
Toshihiro Shimizu 890ddd
	//! Specify if the image is a BW Scan image.
Toshihiro Shimizu 890ddd
	bool m_isScanBW;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! The offset of the image
Toshihiro Shimizu 890ddd
	TPoint m_offset;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int m_subsampling;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TRasterImage();
Toshihiro Shimizu 890ddd
	TRasterImage(const TRasterP &raster);
Toshihiro Shimizu 890ddd
	~TRasterImage();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	//! Is used to clone an existing ToonzImage.
Toshihiro Shimizu 890ddd
	TRasterImage(const TRasterImage &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! not implemented
Toshihiro Shimizu 890ddd
	TRasterImage &operator=(const TRasterImage &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	//! Return the image type
Toshihiro Shimizu 890ddd
	TImage::Type getType() const { return TImage::RASTER; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// image info
Toshihiro Shimizu 890ddd
	//! Return the name of the image
Toshihiro Shimizu 890ddd
	string getName() const { return m_name; }
Toshihiro Shimizu 890ddd
	//! Set the name of the image
Toshihiro Shimizu 890ddd
	void setName(string name) { m_name = name; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Get the \b dpi image
Toshihiro Shimizu 890ddd
	void getDpi(double &dpix, double &dpiy) const
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		dpix = m_dpix;
Toshihiro Shimizu 890ddd
		dpiy = m_dpiy;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	//! Set the \b dpi image
Toshihiro Shimizu 890ddd
	void setDpi(double dpix, double dpiy)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_dpix = dpix;
Toshihiro Shimizu 890ddd
		m_dpiy = dpiy;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getSubsampling() const { return m_subsampling; }
Toshihiro Shimizu 890ddd
	void setSubsampling(int s);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return the save box of the image
Toshihiro Shimizu 890ddd
	TRect getSavebox() const { return m_savebox; }
Toshihiro Shimizu 890ddd
	//! Set the save box of the image
Toshihiro Shimizu 890ddd
	void setSavebox(const TRect &rect) { m_savebox = rect; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return the bbox of the image
Toshihiro Shimizu 890ddd
	TRectD getBBox() const { return convert(m_savebox); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return raster image offset \b m_offset
Toshihiro Shimizu 890ddd
	TPoint getOffset() const { return m_offset; }
Toshihiro Shimizu 890ddd
	//! Set raster image offset \b m_offset
Toshihiro Shimizu 890ddd
	void setOffset(const TPoint &offset) { m_offset = offset; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return raster hPos \b m_hPos
Toshihiro Shimizu 890ddd
	//double gethPos() const {return m_hPos;}
Toshihiro Shimizu 890ddd
	//! Set raster hPos \b m_hPos
Toshihiro Shimizu 890ddd
	//void sethPos(double hPos) {m_hPos= hPos;}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return a clone of image
Toshihiro Shimizu 890ddd
	TImage *cloneImage() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return \b TRasterP
Toshihiro Shimizu 890ddd
	const TRasterP &getRaster() const { return m_mainRaster; }
Toshihiro Shimizu 890ddd
	//! Return \b TRasterP
Toshihiro Shimizu 890ddd
	TRasterP &getRaster() { return m_mainRaster; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TRasterP raster() const { return m_mainRaster; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Set the \b TRasterP \b raster
Toshihiro Shimizu 890ddd
	void setRaster(const TRasterP &raster);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return a \b TRasterP contained the icon of the image \b m_iconRaster
Toshihiro Shimizu 890ddd
	const TRasterP &getIconRaster() const { return m_iconRaster; }
Toshihiro Shimizu 890ddd
	//! Return a \b TRasterP contained the icon of the image \b m_iconRaster
Toshihiro Shimizu 890ddd
	TRasterP &getIconRaster() { return m_iconRaster; }
Toshihiro Shimizu 890ddd
	//! Set a \b TRasterP contained the icon of the image \b m_iconRaster
Toshihiro Shimizu 890ddd
	void setIconRaster(const TRasterP &raster) { m_iconRaster = raster; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return true if the raster is empty
Toshihiro Shimizu 890ddd
	bool isEmpty() const { return !m_mainRaster; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return true if the raster comes from BW Scan
Toshihiro Shimizu 890ddd
	bool isScanBW() const
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		return m_isScanBW;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	void setScanBWFlag(bool isScanBW) { m_isScanBW = isScanBW; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Return true if the raster is opaque
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool isOpaque() const { return m_isOpaque; }
Toshihiro Shimizu 890ddd
	void setOpaqueFlag(bool isOpaque) { m_isOpaque = isOpaque; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! Make the icon of the raster.
Toshihiro Shimizu 890ddd
	void makeIcon(const TRaster32P &raster);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#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
Toshihiro Shimizu 890ddd
class DVAPI TRasterImageP : public TDerivedSmartPointerT<trasterimage, timage=""></trasterimage,>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TRasterImageP() {}
Toshihiro Shimizu 890ddd
	TRasterImageP(TRasterImage *image) : DerivedSmartPointer(image) {}
Toshihiro Shimizu 890ddd
	TRasterImageP(TImageP image) : DerivedSmartPointer(image) {}
Toshihiro Shimizu 890ddd
	TRasterImageP(const TRasterP &ras) : DerivedSmartPointer(new TRasterImage(ras)) {}
Toshihiro Shimizu 890ddd
	operator TImageP() { return TImageP(m_pointer); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif