|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef T_RASTER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define T_RASTER_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgeometry.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelgr.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsmartpointer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tbigmemorymanager.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TRASTER_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 |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TRasterType {
|
|
Shinya Kitaoka |
120a6e |
int m_id;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
enum Type {
|
|
Shinya Kitaoka |
120a6e |
None,
|
|
Shinya Kitaoka |
120a6e |
BW,
|
|
Shinya Kitaoka |
120a6e |
WB,
|
|
Shinya Kitaoka |
120a6e |
RGBM32,
|
|
Shinya Kitaoka |
120a6e |
RGBM64,
|
|
Shinya Kitaoka |
120a6e |
CM8,
|
|
Shinya Kitaoka |
120a6e |
GR8,
|
|
Shinya Kitaoka |
120a6e |
CM16,
|
|
Shinya Kitaoka |
120a6e |
GR16,
|
|
Shinya Kitaoka |
120a6e |
RGB555,
|
|
Shinya Kitaoka |
120a6e |
RGB565,
|
|
Shinya Kitaoka |
120a6e |
CM24,
|
|
Shinya Kitaoka |
120a6e |
(MSB)
|
|
Shinya Kitaoka |
120a6e |
CM16S12,
|
|
Shinya Kitaoka |
120a6e |
CM16S8
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TRasterType(int id) : m_id(id){};
|
|
Shinya Kitaoka |
120a6e |
int getId() const { return m_id; };
|
|
Shinya Kitaoka |
120a6e |
bool operator==(TRasterType a) { return m_id == a.m_id; };
|
|
Shinya Kitaoka |
120a6e |
bool operator!=(TRasterType a) { return m_id != a.m_id; };
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Toshihiro Shimizu |
890ddd |
class TRasterPT;
|
|
Toshihiro Shimizu |
890ddd |
class TRaster;
|
|
Toshihiro Shimizu |
890ddd |
typedef TSmartPointerT<traster> TRasterP;</traster>
|
|
Toshihiro Shimizu |
890ddd |
|
|
|
2fc36c |
|
|
|
2fc36c |
|
|
|
2fc36c |
|
|
|
2fc36c |
|
|
|
2fc36c |
|
|
|
2fc36c |
|
|
|
2fc36c |
#ifdef _WIN32
|
|
|
2fc36c |
template class DVAPI TSmartPointerT<traster>;</traster>
|
|
|
2fc36c |
#endif
|
|
|
2fc36c |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!This class stores bitmap images. */
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TRaster : public TSmartObject {
|
|
Shinya Kitaoka |
120a6e |
DECLARE_CLASS_CODE
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
int m_pixelSize;
|
|
Shinya Kitaoka |
120a6e |
int m_lx, m_ly;
|
|
Shinya Kitaoka |
120a6e |
int m_wrap;
|
|
Shinya Kitaoka |
120a6e |
int m_lockCount;
|
|
Shinya Kitaoka |
120a6e |
TRaster *m_parent;
|
|
Shinya Kitaoka |
120a6e |
UCHAR *m_buffer;
|
|
Shinya Kitaoka |
120a6e |
bool m_bufferOwner;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// e' comunque impossibile fare new TRaster perche' e' una classe astratta
|
|
Shinya Kitaoka |
120a6e |
// (clone, extract)
|
|
shun-iwasawa |
481b59 |
bool m_isLinear;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRaster(int lx, int ly, int pixelSize);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRaster(int lx, int ly, int pixelSize, int wrap, UCHAR *buffer,
|
|
Shinya Kitaoka |
120a6e |
TRaster *parent, bool bufferOwner = false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
static TAtomicVar m_totalMemory;
|
|
Shinya Kitaoka |
120a6e |
TThread::Mutex m_mutex;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRaster(const TRaster &);
|
|
Shinya Kitaoka |
120a6e |
TRaster &operator=(const TRaster &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Shinya Kitaoka |
120a6e |
bool m_cashed;
|
|
Shinya Kitaoka |
120a6e |
static unsigned long getTotalMemoryInKB();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual ~TRaster();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// TRasterType getType() const {return m_type;};
|
|
Shinya Kitaoka |
120a6e |
int getLx() const { return m_lx; };
|
|
Shinya Kitaoka |
120a6e |
int getLy() const { return m_ly; };
|
|
Shinya Kitaoka |
120a6e |
TDimension getSize() const { return TDimension(m_lx, m_ly); };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int getWrap() const { return m_wrap; };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD getCenterD() const { return TPointD(0.5 * m_lx, 0.5 * m_ly); };
|
|
Shinya Kitaoka |
120a6e |
TPoint getCenter() const { return TPoint(m_lx / 2, m_ly / 2); };
|
|
Shinya Kitaoka |
120a6e |
TRect getBounds() const { return TRect(0, 0, m_lx - 1, m_ly - 1); };
|
|
Shinya Kitaoka |
120a6e |
int getPixelSize() const { return m_pixelSize; };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int getRowSize() const { return m_pixelSize * m_lx; };
|
|
Shinya Kitaoka |
120a6e |
// in bytes
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// to lock/unlock them o use them.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void lock() {
|
|
Shinya Kitaoka |
120a6e |
if (!TBigMemoryManager::instance()->isActive()) return;
|
|
Shinya Kitaoka |
120a6e |
TThread::MutexLocker sl(&m_mutex);
|
|
Shinya Kitaoka |
120a6e |
if (m_parent)
|
|
Shinya Kitaoka |
120a6e |
m_parent->lock();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
++m_lockCount;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void unlock() {
|
|
Shinya Kitaoka |
120a6e |
if (!TBigMemoryManager::instance()->isActive()) return;
|
|
Shinya Kitaoka |
120a6e |
TThread::MutexLocker sl(&m_mutex);
|
|
Shinya Kitaoka |
120a6e |
if (m_parent)
|
|
Shinya Kitaoka |
120a6e |
m_parent->unlock();
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
assert(m_lockCount > 0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void beginRemapping();
|
|
Shinya Kitaoka |
120a6e |
void endRemapping();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const UCHAR *getRawData() const { return m_buffer; };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
UCHAR *getRawData() { return m_buffer; };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const UCHAR *getRawData(int x, int y) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= x && x < m_lx && 0 <= y && y < m_ly);
|
|
Shinya Kitaoka |
120a6e |
return m_buffer + (y * m_wrap + x) * m_pixelSize;
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
UCHAR *getRawData(int x, int y) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= x && x < m_lx && 0 <= y && y < m_ly);
|
|
Shinya Kitaoka |
120a6e |
return m_buffer + (y * m_wrap + x) * m_pixelSize;
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
bool isEmpty() const { return getSize() == TDimension(); };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRasterP getParent() { return m_parent; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
481b59 |
bool isLinear() const { return m_isLinear; }
|
|
shun-iwasawa |
481b59 |
void setLinear(const bool linear) {
|
|
shun-iwasawa |
481b59 |
if (m_isLinear == linear) return;
|
|
shun-iwasawa |
481b59 |
m_isLinear = linear;
|
|
shun-iwasawa |
481b59 |
if (m_parent) m_parent->setLinear(linear);
|
|
shun-iwasawa |
481b59 |
}
|
|
shun-iwasawa |
481b59 |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
481b59 |
virtual TRasterP clone() const = 0;
|
|
shun-iwasawa |
481b59 |
virtual TRasterP extract(TRect &rect) = 0;
|
|
shun-iwasawa |
481b59 |
virtual TRasterP create() const = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual TRasterP create(int lx, int ly) const = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// definita in termini di extract(rect); non lo posso fare subito perche'
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline virtual TRasterP extract(int x0, int y0, int x1, int y1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// In caso di dimensione diversa l'area copiata e' l'intersezione dei due
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
481b59 |
*/
|
|
Shinya Kitaoka |
120a6e |
void copy(const TRasterP &src, const TPoint &offset = TPoint());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void xMirror();
|
|
Shinya Kitaoka |
120a6e |
void yMirror();
|
|
Shinya Kitaoka |
120a6e |
void rotate180();
|
|
Shinya Kitaoka |
120a6e |
void rotate90();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void clear();
|
|
Shinya Kitaoka |
120a6e |
void clearOutside(const TRect &rect);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
friend class TBigMemoryManager;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
void fillRawData(const UCHAR *pixel);
|
|
Shinya Kitaoka |
120a6e |
void fillRawDataOutside(const TRect &rect, const UCHAR *pixel);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
void remap(UCHAR *newLocation);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline void detach(TRasterP &r) {
|
|
Shinya Kitaoka |
120a6e |
if (!r || r->getRefCount() == 1) return;
|
|
Shinya Kitaoka |
120a6e |
TRasterP tmp(r->clone());
|
|
Shinya Kitaoka |
120a6e |
r = tmp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Toshihiro Shimizu |
890ddd |
class TRasterT;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TRasterPT<pixel>:</pixel>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Smart Pointer to TRasterT<pixel></pixel>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// class TRasterPT<t></t>
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
d1f6c4 |
class TRasterPT final : public TSmartPointerT<trastert<t>> {</trastert<t>
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef T Pixel;
|
|
Shinya Kitaoka |
120a6e |
typedef TRasterT<t> Raster;</t>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRasterPT(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRasterPT(int lx, int ly) { create(lx, ly); };
|
|
Shinya Kitaoka |
120a6e |
TRasterPT(const TDimension &d) { create(d.lx, d.ly); };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TRasterPT(const TRasterP &src);
|
|
Shinya Kitaoka |
120a6e |
inline TRasterPT(int lx, int ly, int wrap, T *buffer,
|
|
Shinya Kitaoka |
120a6e |
bool bufferOwner = false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
~TRasterPT(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void create(int lx, int ly);
|
|
Shinya Kitaoka |
120a6e |
void create(const TDimension &d) { create(d.lx, d.ly); };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline void detach();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
operator TRasterP() const;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TRasterT<pixel></pixel>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
class TRasterT : public TRaster {
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRasterT(int lx, int ly) : TRaster(lx, ly, sizeof(T)) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRasterT(int lx, int ly, int wrap, T *buffer, TRasterT<t> *parent,</t>
|
|
Shinya Kitaoka |
120a6e |
bool bufferOwner = false)
|
|
Shinya Kitaoka |
120a6e |
: TRaster(lx, ly, sizeof(T), wrap, reinterpret_cast<uchar *="">(buffer),</uchar>
|
|
Shinya Kitaoka |
120a6e |
parent, bufferOwner) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef T Pixel;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~TRasterT(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const T *pixels(int y = 0) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= y && y < getLy());
|
|
Shinya Kitaoka |
120a6e |
return reinterpret_cast<t *="">(m_buffer) + getWrap() * y;</t>
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
T *pixels(int y = 0) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= y && y < getLy());
|
|
Shinya Kitaoka |
120a6e |
return reinterpret_cast<t *="">(m_buffer) + getWrap() * y;</t>
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
TRasterP clone() const override {
|
|
Shinya Kitaoka |
120a6e |
TRasterP dst = TRasterPT<t>(m_lx, m_ly);</t>
|
|
Shinya Kitaoka |
120a6e |
TRasterP src(const_cast<traster *="">((const TRaster *)this));</traster>
|
|
Shinya Kitaoka |
120a6e |
dst->copy(src);
|
|
Shinya Kitaoka |
120a6e |
return dst;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
TRasterP create() const override { return TRasterPT<t>(m_lx, m_ly); }</t>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
38fd86 |
TRasterP create(int lx, int ly) const override {
|
|
Shinya Kitaoka |
38fd86 |
return TRasterPT<t>(lx, ly);</t>
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
TRasterP extract(int x0, int y0, int x1, int y1) override {
|
|
Shinya Kitaoka |
120a6e |
TRect rect(x0, y0, x1, y1);
|
|
Shinya Kitaoka |
120a6e |
return extract(rect);
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
TRasterP extract(TRect &rect) override {
|
|
Shinya Kitaoka |
120a6e |
if (isEmpty() || getBounds().overlaps(rect) == false) return TRasterP();
|
|
Shinya Kitaoka |
120a6e |
rect = getBounds() * rect;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
481b59 |
// return TRasterP(new TRasterT<t>(rect.getLx(), rect.getLy(), m_wrap,</t>
|
|
shun-iwasawa |
481b59 |
|
|
Shinya Kitaoka |
120a6e |
return TRasterP(new TRasterT<t>(rect.getLx(), rect.getLy(), m_wrap,</t>
|
|
Shinya Kitaoka |
120a6e |
pixels(rect.y0) + rect.x0, this));
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRasterPT<t> extractT(TRect &rect);</t>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TRasterPT<t> extractT(int x0, int y0, int x1, int y1) {</t>
|
|
Shinya Kitaoka |
120a6e |
TRect rect(x0, y0, x1, y1);
|
|
Shinya Kitaoka |
120a6e |
return extractT(rect);
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
friend class TRasterPT<t>;</t>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void fill(const T &a) { fillRawData(reinterpret_cast<const *="" uchar="">(&a)); }</const>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void fillOutside(const TRect &rect, const T &a) {
|
|
Shinya Kitaoka |
120a6e |
fillRawDataOutside(rect, reinterpret_cast<const *="" uchar="">(&a));</const>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline TRasterP TRaster::extract(int x0, int y0, int x1, int y1) {
|
|
Shinya Kitaoka |
120a6e |
TRect rect(x0, y0, x1, y1);
|
|
Shinya Kitaoka |
120a6e |
return extract(rect);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
TRasterPT<t> TRasterT<t>::extractT(TRect &rect) {</t></t>
|
|
Shinya Kitaoka |
120a6e |
if (isEmpty() || getBounds().overlaps(rect) == false) {
|
|
Shinya Kitaoka |
120a6e |
return TRasterPT<t>();</t>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
rect = getBounds() * rect;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return TRasterPT<t>(new TRasterT<t>(rect.getLx(), rect.getLy(), m_wrap,</t></t>
|
|
Shinya Kitaoka |
120a6e |
pixels(rect.y0) + rect.x0, this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// (n.b. se non si fanno esplicitament "inline" NT si confonde con dll
|
|
luz paz |
6454c4 |
// export/import)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
inline TRasterPT<t>::TRasterPT(const TRasterP &src) {</t>
|
|
Shinya Kitaoka |
120a6e |
TSmartPointerT<trastert<t>>::m_pointer =</trastert<t>
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<trastert<t> *>(src.getPointer());</trastert<t>
|
|
Shinya Kitaoka |
120a6e |
if (TSmartPointerT<trastert<t>>::m_pointer)</trastert<t>
|
|
Shinya Kitaoka |
120a6e |
TSmartPointerT<trastert<t>>::m_pointer->addRef();</trastert<t>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
inline void TRasterPT<t>::create(int lx, int ly) {</t>
|
|
Shinya Kitaoka |
120a6e |
TRasterT<t> *raster = new TRasterT<t>(lx, ly);</t></t>
|
|
Shinya Kitaoka |
120a6e |
*this = TRasterPT<t>(raster);</t>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
inline void TRasterPT<t>::detach() {</t>
|
|
Shinya Kitaoka |
120a6e |
if (!TSmartPointerT<trastert<t>>::m_pointer ||</trastert<t>
|
|
Shinya Kitaoka |
120a6e |
TSmartPointerT<trastert<t>>::m_pointer->getRefCount() == 1)</trastert<t>
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
*this = TRasterPT(TSmartPointerT<trastert<t>>::m_pointer->clone());</trastert<t>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// i reference counts del vecchio e del nuovo raster
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
inline TRasterPT<t>::operator TRasterP() const {</t>
|
|
Shinya Kitaoka |
120a6e |
return TRasterP(TSmartPointerT<trastert<t>>::m_pointer);</trastert<t>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Shinya Kitaoka |
120a6e |
inline TRasterPT<t>::TRasterPT(int lx, int ly, int wrap, T *buffer,</t>
|
|
Shinya Kitaoka |
120a6e |
bool bufferOwner) {
|
|
Shinya Kitaoka |
120a6e |
TSmartPointerT<trastert<t>>::m_pointer =</trastert<t>
|
|
Shinya Kitaoka |
120a6e |
new TRasterT<t>(lx, ly, wrap, buffer, 0, bufferOwner);</t>
|
|
Shinya Kitaoka |
120a6e |
TSmartPointerT<trastert<t>>::m_pointer->addRef();</trastert<t>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<trastert<tpixel32>>;</trastert<tpixel32>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TRasterPT<tpixel32>;</tpixel32>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<trastert<tpixel64>>;</trastert<tpixel64>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TRasterPT<tpixel64>;</tpixel64>
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
481b59 |
template class DVAPI TSmartPointerT<trastert<tpixelf>>;</trastert<tpixelf>
|
|
shun-iwasawa |
481b59 |
template class DVAPI TRasterPT<tpixelf>;</tpixelf>
|
|
shun-iwasawa |
481b59 |
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<trastert<tpixelgr8>>;</trastert<tpixelgr8>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TRasterPT<tpixelgr8>;</tpixelgr8>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<trastert<tpixelgr16>>;</trastert<tpixelgr16>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TRasterPT<tpixelgr16>;</tpixelgr16>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<trastert<tpixelgrd>>;</trastert<tpixelgrd>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TRasterPT<tpixelgrd>;</tpixelgrd>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<trastert<tpixelcy>>;</trastert<tpixelcy>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TRasterPT<tpixelcy>;</tpixelcy>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef TRasterPT<tpixel32> TRaster32P;</tpixel32>
|
|
Toshihiro Shimizu |
890ddd |
typedef TRasterPT<tpixel64> TRaster64P;</tpixel64>
|
|
shun-iwasawa |
481b59 |
typedef TRasterPT<tpixelf> TRasterFP;</tpixelf>
|
|
Toshihiro Shimizu |
890ddd |
typedef TRasterPT<tpixelgr8> TRasterGR8P;</tpixelgr8>
|
|
Toshihiro Shimizu |
890ddd |
typedef TRasterPT<tpixelgr16> TRasterGR16P;</tpixelgr16>
|
|
Toshihiro Shimizu |
890ddd |
typedef TRasterPT<tpixelgrd> TRasterGRDP;</tpixelgrd>
|
|
Toshihiro Shimizu |
890ddd |
typedef TRasterPT<tpixelcy> TRasterYUV422P;</tpixelcy>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
b3bd84 |
// functions
|
|
Campbell Barton |
b3bd84 |
|
|
Campbell Barton |
b3bd84 |
|
|
Campbell Barton |
b3bd84 |
TPoint computeCentroid(const TRaster32P &r);
|
|
Campbell Barton |
b3bd84 |
|
|
Campbell Barton |
b3bd84 |
|
|
Campbell Barton |
b3bd84 |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|