|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/rasterimagedata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/strokesdata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpaletteutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcenterlinevectorizer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/ttileset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzimageutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzscene.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/sceneproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/fullcolorpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
40cabe |
#include <memory></memory>
|
|
Campbell Barton |
40cabe |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP vectorize(const TImageP &source, const TRectD &rect, const VectorizerConfiguration &config, TAffine transform)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
VectorizerCore vc;
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP vi = vc.vectorize(source.getPointer(), config, source->getPalette());
|
|
Toshihiro Shimizu |
890ddd |
assert(vi);
|
|
Toshihiro Shimizu |
890ddd |
vi->setPalette(source->getPalette());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double dpiX, dpiY;
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti(source);
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP ri(source);
|
|
Toshihiro Shimizu |
890ddd |
if (ti)
|
|
Toshihiro Shimizu |
890ddd |
ti->getDpi(dpiX, dpiY);
|
|
Toshihiro Shimizu |
890ddd |
else if (ri)
|
|
Toshihiro Shimizu |
890ddd |
ri->getDpi(dpiX, dpiY);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return vi;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TScale sc(dpiX / Stage::inch, dpiY / Stage::inch);
|
|
Toshihiro Shimizu |
890ddd |
TTranslation tr(rect.getP00());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)vi->getStrokeCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TStroke *stroke = vi->getStroke(i);
|
|
Toshihiro Shimizu |
890ddd |
stroke->transform((sc.inv() * tr) * transform, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return vi;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} //namspace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
// RasterImageData
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RasterImageData::RasterImageData()
|
|
Toshihiro Shimizu |
890ddd |
: m_dpiX(0), m_dpiY(0), m_transformation(), m_dim()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RasterImageData::~RasterImageData()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
// ToonzImageData
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageData::ToonzImageData()
|
|
Toshihiro Shimizu |
890ddd |
: RasterImageData(), m_copiedRaster(0), m_palette(new TPalette())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageData::ToonzImageData(const ToonzImageData &src)
|
|
Toshihiro Shimizu |
890ddd |
: m_copiedRaster(src.m_copiedRaster), m_palette(src.m_palette), m_usedStyles(src.m_usedStyles)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_dpiX = src.m_dpiX;
|
|
Toshihiro Shimizu |
890ddd |
m_dpiY = src.m_dpiY;
|
|
Toshihiro Shimizu |
890ddd |
m_rects = src.m_rects;
|
|
Toshihiro Shimizu |
890ddd |
m_strokes = src.m_strokes;
|
|
Toshihiro Shimizu |
890ddd |
m_transformation = src.m_transformation;
|
|
Toshihiro Shimizu |
890ddd |
m_originalStrokes = src.m_originalStrokes;
|
|
Toshihiro Shimizu |
890ddd |
m_dim = src.m_dim;
|
|
Toshihiro Shimizu |
890ddd |
assert(m_palette);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageData::~ToonzImageData()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzImageData::setData(const TRasterP &copiedRaster, const TPaletteP &palette, double dpiX, double dpiY, const TDimension &dim,
|
|
Toshihiro Shimizu |
890ddd |
const vector<trectd> &rects, const vector<tstroke> &strokes,</tstroke></trectd>
|
|
Toshihiro Shimizu |
890ddd |
const vector<tstroke> &originalStrokes,</tstroke>
|
|
Toshihiro Shimizu |
890ddd |
const TAffine &transformation)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_copiedRaster = copiedRaster;
|
|
Toshihiro Shimizu |
890ddd |
m_palette = palette;
|
|
Toshihiro Shimizu |
890ddd |
m_dpiX = dpiX;
|
|
Toshihiro Shimizu |
890ddd |
m_dpiY = dpiY;
|
|
Toshihiro Shimizu |
890ddd |
m_rects = rects;
|
|
Toshihiro Shimizu |
890ddd |
m_strokes = strokes;
|
|
Toshihiro Shimizu |
890ddd |
m_transformation = transformation;
|
|
Toshihiro Shimizu |
890ddd |
m_originalStrokes = originalStrokes;
|
|
Toshihiro Shimizu |
890ddd |
m_dim = dim;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- 使用されているStyleの一覧を作る --*/
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti(m_copiedRaster, m_copiedRaster->getBounds());
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageUtils::getUsedStyles(m_usedStyles, ti);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ToonzImageData::getData(TRasterP &copiedRaster, double &dpiX, double &dpiY,
|
|
Toshihiro Shimizu |
890ddd |
vector<trectd> &rects, vector<tstroke> &strokes, vector<tstroke> &originalStrokes,</tstroke></tstroke></trectd>
|
|
Toshihiro Shimizu |
890ddd |
TAffine &transformation, TPalette *targetPalette) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_copiedRaster || (m_rects.empty() && m_strokes.empty()))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
copiedRaster = m_copiedRaster->clone();
|
|
Toshihiro Shimizu |
890ddd |
dpiX = m_dpiX;
|
|
Toshihiro Shimizu |
890ddd |
dpiY = m_dpiY;
|
|
Toshihiro Shimizu |
890ddd |
assert(m_palette);
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_rects.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
rects.push_back(m_rects[i]);
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_strokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
strokes.push_back(m_strokes[i]);
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_originalStrokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
originalStrokes.push_back(m_originalStrokes[i]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
transformation = m_transformation;
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P cmRas = copiedRaster;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!targetPalette)
|
|
Toshihiro Shimizu |
890ddd |
targetPalette = new TPalette();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!cmRas)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
std::set<int> usedStyles(m_usedStyles);</int>
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP ti(cmRas, cmRas->getBounds());
|
|
Toshihiro Shimizu |
890ddd |
if (usedStyles.size() == 0)
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageUtils::getUsedStyles(usedStyles, ti);
|
|
Toshihiro Shimizu |
890ddd |
std::map<int, int=""> indexTable;</int,>
|
|
Toshihiro Shimizu |
890ddd |
mergePalette(targetPalette, indexTable, m_palette, usedStyles);
|
|
Toshihiro Shimizu |
890ddd |
ToonzImageUtils::scrambleStyles(ti, indexTable);
|
|
Toshihiro Shimizu |
890ddd |
ti->setPalette(m_palette.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StrokesData *ToonzImageData::toStrokesData(ToonzScene *scene) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(scene);
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect;
|
|
Toshihiro Shimizu |
890ddd |
if (!m_rects.empty())
|
|
Toshihiro Shimizu |
890ddd |
rect = m_rects[0];
|
|
Toshihiro Shimizu |
890ddd |
else if (!m_strokes.empty())
|
|
Toshihiro Shimizu |
890ddd |
rect = m_strokes[0].getBBox();
|
|
Toshihiro Shimizu |
890ddd |
unsigned int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_rects.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
rect += m_rects[i];
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_strokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
rect += m_strokes[i].getBBox();
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP image(m_copiedRaster, m_copiedRaster->getBounds());
|
|
Toshihiro Shimizu |
890ddd |
image->setPalette(m_palette.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
image->setDpi(m_dpiX, m_dpiY);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const VectorizerParameters &vParams = *scene->getProperties()->getVectorizerParameters();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
CenterlineConfiguration cConf = vParams.getCenterlineConfiguration(0.0);
|
|
Toshihiro Shimizu |
890ddd |
NewOutlineConfiguration oConf = vParams.getOutlineConfiguration(0.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const VectorizerConfiguration &config = vParams.m_isOutline ? static_cast<const &="" vectorizerconfiguration="">(oConf) : static_cast<const &="" vectorizerconfiguration="">(cConf);</const></const>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP vi = vectorize(image, rect, config, m_transformation);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StrokesData *sd = new StrokesData();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::set<int> indexes;</int>
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < vi->getStrokeCount(); i++)
|
|
Toshihiro Shimizu |
890ddd |
indexes.insert(i);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
sd->setImage(vi, indexes);
|
|
Toshihiro Shimizu |
890ddd |
return sd;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int ToonzImageData::getMemorySize() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i, size = 0;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_strokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
size += m_strokes[i].getControlPointCount() * sizeof(TThickPoint) + 100;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_originalStrokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
size += m_originalStrokes[i].getControlPointCount() * sizeof(TThickPoint) + 100;
|
|
Toshihiro Shimizu |
890ddd |
return size + sizeof(*(m_copiedRaster.getPointer())) +
|
|
Toshihiro Shimizu |
890ddd |
sizeof(*(m_palette.getPointer())) +
|
|
Toshihiro Shimizu |
890ddd |
sizeof(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
// FullColorImageData
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FullColorImageData::FullColorImageData()
|
|
Toshihiro Shimizu |
890ddd |
: RasterImageData(), m_copiedRaster(0), m_palette(new TPalette())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FullColorImageData::FullColorImageData(const FullColorImageData &src)
|
|
Toshihiro Shimizu |
890ddd |
: m_copiedRaster(src.m_copiedRaster), m_palette(src.m_palette)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_dpiX = src.m_dpiX;
|
|
Toshihiro Shimizu |
890ddd |
m_dpiY = src.m_dpiY;
|
|
Toshihiro Shimizu |
890ddd |
m_rects = src.m_rects;
|
|
Toshihiro Shimizu |
890ddd |
m_strokes = src.m_strokes;
|
|
Toshihiro Shimizu |
890ddd |
m_transformation = src.m_transformation;
|
|
Toshihiro Shimizu |
890ddd |
m_originalStrokes = src.m_originalStrokes;
|
|
Toshihiro Shimizu |
890ddd |
m_dim = src.m_dim;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FullColorImageData::~FullColorImageData()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FullColorImageData::setData(const TRasterP &copiedRaster, const TPaletteP &palette, double dpiX, double dpiY, const TDimension &dim,
|
|
Toshihiro Shimizu |
890ddd |
const vector<trectd> &rects, const vector<tstroke> &strokes,</tstroke></trectd>
|
|
Toshihiro Shimizu |
890ddd |
const vector<tstroke> &originalStrokes,</tstroke>
|
|
Toshihiro Shimizu |
890ddd |
const TAffine &transformation)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_copiedRaster = copiedRaster;
|
|
Toshihiro Shimizu |
890ddd |
m_palette = palette;
|
|
Toshihiro Shimizu |
890ddd |
m_dpiX = dpiX;
|
|
Toshihiro Shimizu |
890ddd |
m_dpiY = dpiY;
|
|
Toshihiro Shimizu |
890ddd |
m_rects = rects;
|
|
Toshihiro Shimizu |
890ddd |
m_strokes = strokes;
|
|
Toshihiro Shimizu |
890ddd |
m_originalStrokes = originalStrokes;
|
|
Toshihiro Shimizu |
890ddd |
m_transformation = transformation;
|
|
Toshihiro Shimizu |
890ddd |
m_dim = dim;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void FullColorImageData::getData(TRasterP &copiedRaster, double &dpiX, double &dpiY,
|
|
Toshihiro Shimizu |
890ddd |
vector<trectd> &rects, vector<tstroke> &strokes, vector<tstroke> &originalStrokes,</tstroke></tstroke></trectd>
|
|
Toshihiro Shimizu |
890ddd |
TAffine &transformation, TPalette *targetPalette) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_copiedRaster || (m_rects.empty() && m_strokes.empty()))
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
copiedRaster = m_copiedRaster->clone();
|
|
Toshihiro Shimizu |
890ddd |
dpiX = m_dpiX;
|
|
Toshihiro Shimizu |
890ddd |
dpiY = m_dpiY;
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_rects.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
rects.push_back(m_rects[i]);
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_strokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
strokes.push_back(m_strokes[i]);
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_originalStrokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
originalStrokes.push_back(m_originalStrokes[i]);
|
|
Toshihiro Shimizu |
890ddd |
transformation = m_transformation;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterP ras = copiedRaster;
|
|
Toshihiro Shimizu |
890ddd |
if (!ras)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (!m_palette)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
if (!targetPalette)
|
|
Toshihiro Shimizu |
890ddd |
targetPalette = new TPalette();
|
|
Toshihiro Shimizu |
890ddd |
std::set<int> usedStyles;</int>
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP ri(ras);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_palette->getPageCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
TPalette::Page *page = m_palette->getPage(i);
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < page->getStyleCount(); j++)
|
|
Toshihiro Shimizu |
890ddd |
usedStyles.insert(page->getStyleId(j));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
std::map<int, int=""> indexTable;</int,>
|
|
Toshihiro Shimizu |
890ddd |
mergePalette(targetPalette, indexTable, m_palette, usedStyles);
|
|
Toshihiro Shimizu |
890ddd |
ri->setPalette(m_palette.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StrokesData *FullColorImageData::toStrokesData(ToonzScene *scene) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(scene);
|
|
Toshihiro Shimizu |
890ddd |
TRectD rect;
|
|
Toshihiro Shimizu |
890ddd |
if (!m_rects.empty())
|
|
Toshihiro Shimizu |
890ddd |
rect = m_rects[0];
|
|
Toshihiro Shimizu |
890ddd |
else if (!m_strokes.empty())
|
|
Toshihiro Shimizu |
890ddd |
rect = m_strokes[0].getBBox();
|
|
Toshihiro Shimizu |
890ddd |
unsigned int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_rects.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
rect += m_rects[i];
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < m_strokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
rect += m_strokes[i].getBBox();
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP image(m_copiedRaster);
|
|
Toshihiro Shimizu |
890ddd |
image->setPalette(FullColorPalette::instance()->getPalette(scene));
|
|
Toshihiro Shimizu |
890ddd |
image->setDpi(m_dpiX, m_dpiY);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const VectorizerParameters *vParams = scene->getProperties()->getVectorizerParameters();
|
|
Toshihiro Shimizu |
890ddd |
assert(vParams);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::auto_ptr<vectorizerconfiguration> config(vParams->getCurrentConfiguration(0.0));</vectorizerconfiguration>
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP vi = vectorize(image, rect, *config, m_transformation);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StrokesData *sd = new StrokesData();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::set<int> indexes;</int>
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < vi->getStrokeCount(); i++)
|
|
Toshihiro Shimizu |
890ddd |
indexes.insert(i);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
sd->setImage(vi, indexes);
|
|
Toshihiro Shimizu |
890ddd |
return sd;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int FullColorImageData::getMemorySize() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int i, size = 0;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_strokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
size += m_strokes[i].getControlPointCount() * sizeof(TThickPoint) + 100;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < (int)m_originalStrokes.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
size += m_originalStrokes[i].getControlPointCount() * sizeof(TThickPoint) + 100;
|
|
Toshihiro Shimizu |
890ddd |
return size + sizeof(*(m_copiedRaster.getPointer())) +
|
|
Toshihiro Shimizu |
890ddd |
sizeof(*(m_palette.getPointer())) +
|
|
Toshihiro Shimizu |
890ddd |
sizeof(*this);
|
|
Toshihiro Shimizu |
890ddd |
}
|