tahoma2d/toonz/sources/include/ttoonzimage.h

137 lines
3.6 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TTOONZIMAGE_INCLUDED
#define TTOONZIMAGE_INCLUDED
#include "trastercm.h"
#include "tthreadmessage.h"
#include "timage.h"
#undef DVAPI
#undef DVVAR
#ifdef TNZCORE_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
class TToonzImageP;
//! An image containing a Toonz raster.
class DVAPI TToonzImage final : public TImage {
2016-06-15 18:43:10 +12:00
//! dpi value for x axis
double m_dpix,
//! dpi value for y axis
m_dpiy;
int m_subsampling;
//! The name of the image
std::string m_name;
//! The savebox of the image
TRect m_savebox;
// double m_hPos;
//! The offset of the image
TPoint m_offset;
//! ColorMapped raster of the image.
TRasterCM32P m_ras;
TThread::Mutex m_mutex;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TToonzImage();
TToonzImage(const TRasterCM32P &raster, const TRect &saveBox);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
~TToonzImage();
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
//! Is used to clone an existing ToonzImage.
TToonzImage(const TToonzImage &);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Not implemented
TToonzImage &operator=(const TToonzImage &);
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
//! Return the type of the image.
2016-06-19 20:06:29 +12:00
TImage::Type getType() const override { return TImage::TOONZ_RASTER; }
2016-06-15 18:43:10 +12:00
//! Return the size of the Image.
TDimension getSize() const { return m_size; }
//! Get the dpi values of the image for x and y axes.
void getDpi(double &dpix, double &dpiy) const {
dpix = m_dpix;
dpiy = m_dpiy;
}
//! Set the dpi values of the image for x and y axes.
void setDpi(double dpix, double dpiy) {
m_dpix = dpix;
m_dpiy = dpiy;
}
int getSubsampling() const { return m_subsampling; }
void setSubsampling(int s);
//! Return the savebox of the image
TRect getSavebox() const { return m_savebox; }
//! Set the savebox of the image.
/*! The savebox setted is the intersection between \b rect and the image
* box.*/
void setSavebox(const TRect &rect);
//! Return the boundin box of the image.
2016-06-19 20:06:29 +12:00
TRectD getBBox() const override { return convert(m_savebox); }
2016-06-15 18:43:10 +12:00
//! Return the offset point of the image.
TPoint getOffset() const { return m_offset; }
//! Set the offset point of the image.
void setOffset(const TPoint &offset) { m_offset = offset; }
//! Return raster hPos \b m_hPos
// double gethPos() const {return m_hPos;}
//! Return a clone of image
// void sethPos(double hPos) {m_hPos= hPos;}
//! Return a clone of the current image
2016-06-19 20:06:29 +12:00
TImage *cloneImage() const override;
2016-06-15 18:43:10 +12:00
//! Return the image's raster
TRasterCM32P getCMapped() const;
//! Return a copy of the image's raster.
void getCMapped(const TRasterCM32P &ras);
//! Set the image's raster
void setCMapped(const TRasterCM32P &ras);
//! Return the image's raster.
/*! Call the getCMapped() method.*/
TRasterCM32P getRaster() const { return getCMapped(); }
2016-06-19 20:06:29 +12:00
TRasterP raster() const override { return (TRasterP)getCMapped(); }
2016-06-15 18:43:10 +12:00
//! Return a clone of the current image.
TToonzImageP clone() const;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
//! Image dimension
TDimension m_size;
2016-03-19 06:57:51 +13:00
};
//-------------------------------------------------------------------
2016-04-15 17:11:23 +12:00
#ifdef _WIN32
2016-03-19 06:57:51 +13:00
template class DVAPI TSmartPointerT<TToonzImage>;
template class DVAPI TDerivedSmartPointerT<TToonzImage, TImage>;
#endif
class DVAPI TToonzImageP final
: public TDerivedSmartPointerT<TToonzImage, TImage> {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TToonzImageP() {}
TToonzImageP(TToonzImage *image) : DerivedSmartPointer(image) {}
TToonzImageP(TImageP image) : DerivedSmartPointer(image) {}
TToonzImageP(const TRasterCM32P &ras, const TRect &saveBox)
: DerivedSmartPointer(new TToonzImage(ras, saveBox)) {}
operator TImageP() { return TImageP(m_pointer); }
2016-03-19 06:57:51 +13:00
};
#endif