本文整理汇总了C++中TRasterP::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TRasterP::getSize方法的具体用法?C++ TRasterP::getSize怎么用?C++ TRasterP::getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRasterP
的用法示例。
在下文中一共展示了TRasterP::getSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processColors
//this one incorporate the preprocessColors and the finalize function; used for swatch.(tipically on very small rasters)
TRasterP TCleanupper::processColors(const TRasterP &rin)
{
if (m_parameters->m_lineProcessingMode == lpNone)
return rin;
TRasterCM32P rcm = TRasterCM32P(rin->getSize());
if (!rcm) {
assert(!"failed finalRas allocation!");
return TRasterCM32P();
}
// Copy current cleanup palette to parameters' colors
m_parameters->m_colors.update(m_parameters->m_cleanupPalette.getPointer(), m_parameters->m_noAntialias);
bool toGr8 = (m_parameters->m_lineProcessingMode == lpGrey);
if (toGr8) {
//No (color) processing. Not even thresholding. This just means that all the important
//stuff here is made in the brightness/contrast stage...
//NOTE: Most of the color processing should be DISABLED in this case!!
//finalRas->clear();
rin->lock();
rcm->lock();
if (TRasterGR8P(rin)) {
UCHAR *rowin = rin->getRawData();
TUINT32 *rowout = reinterpret_cast<TUINT32 *>(rcm->getRawData());
for (int i = 0; i < rin->getLy(); i++) {
for (int j = 0; j < rin->getLx(); j++)
*rowout++ = *rowin++; //Direct copy for now... :(
rowin += rin->getWrap() - rin->getLx();
rowout += rcm->getWrap() - rcm->getLx();
}
} else {
TPixel32 *rowin = reinterpret_cast<TPixel32 *>(rin->getRawData());
TUINT32 *rowout = reinterpret_cast<TUINT32 *>(rcm->getRawData());
for (int i = 0; i < rin->getLy(); i++) {
for (int j = 0; j < rin->getLx(); j++)
*rowout++ = TPixelGR8::from(*rowin++).value;
rowin += rin->getWrap() - rin->getLx();
rowout += rcm->getWrap() - rcm->getLx();
}
}
rin->unlock();
rcm->unlock();
} else {
assert(TRaster32P(rin));
preprocessColors(rcm, rin, m_parameters->m_colors);
}
//outImg->setDpi(outDpi.x, outDpi.y);
CleanupPreprocessedImage cpi(m_parameters, TToonzImageP(rcm, rcm->getBounds()), toGr8);
cpi.m_autocentered = true;
TRaster32P rout = TRaster32P(rin->getSize());
finalize(rout, &cpi);
return rout;
}
示例2: leftButtonDown
void FullColorBrushTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e)
{
m_brushPos = m_mousePos = pos;
Viewer *viewer = getViewer();
if (!viewer)
return;
TRasterImageP ri = (TRasterImageP)getImage(true);
if (!ri)
ri = (TRasterImageP)touchImage();
if (!ri)
return;
TRasterP ras = ri->getRaster();
TDimension dim = ras->getSize();
if (!(m_workRaster && m_backUpRas))
setWorkAndBackupImages();
m_workRaster->lock();
double maxThick = m_thickness.getValue().second;
double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThick;
double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01;
TPointD rasCenter = TPointD(dim.lx * 0.5, dim.ly * 0.5);
TThickPoint point(pos + rasCenter, thickness);
TPointD halfThick(maxThick * 0.5, maxThick * 0.5);
TRectD invalidateRect(pos - halfThick, pos + halfThick);
m_points.clear();
m_points.push_back(point);
m_tileSet = new TTileSetFullColor(ras->getSize());
m_tileSaver = new TTileSaverFullColor(ras, m_tileSet);
double hardness = m_hardness.getValue() * 0.01;
m_brush = new BluredBrush(m_workRaster, maxThick, m_brushPad, hardness == 1.0);
m_strokeRect = m_brush->getBoundFromPoints(m_points);
updateWorkAndBackupRasters(m_strokeRect);
m_tileSaver->save(m_strokeRect);
m_brush->addPoint(point, opacity);
m_brush->updateDrawing(ras, m_backUpRas, m_currentColor, m_strokeRect, m_opacity.getValue().second * 0.01);
m_oldOpacity = opacity;
m_lastRect = m_strokeRect;
invalidate(invalidateRect.enlarge(2));
}
示例3: addInCache
void TTile::addInCache(const TRasterP &raster) {
if (!raster) {
m_rasterId = "";
return;
}
TRasterP rin;
m_rasterId = TImageCache::instance()->getUniqueId();
if (raster->getParent()) {
rin = raster->getParent();
unsigned long offs =
(raster->getRawData() - raster->getParent()->getRawData()) /
raster->getPixelSize();
m_subRect =
TRect(TPoint(offs % raster->getWrap(), offs / raster->getWrap()),
raster->getSize());
} else {
m_subRect = raster->getBounds();
rin = raster;
}
if ((TRasterCM32P)rin)
TImageCache::instance()->add(m_rasterId,
TToonzImageP(rin, rin->getBounds()));
else if ((TRaster32P)rin || (TRaster64P)rin)
TImageCache::instance()->add(m_rasterId, TRasterImageP(rin));
else if ((TRasterGR8P)rin || (TRasterGR16P)rin)
TImageCache::instance()->add(m_rasterId, TRasterImageP(rin));
else
assert(false);
}
示例4: makeStereoRaster
void TRop::makeStereoRaster(const TRasterP &left, const TRasterP &right) {
assert(left->getSize() == right->getSize());
left->lock();
if ((TRaster32P)left && (TRaster32P)right)
doMakeStereoRaster<TPixel32>(left, right);
else if ((TRaster64P)left && (TRaster64P)right)
doMakeStereoRaster<TPixel64>(left, right);
else {
left->unlock();
throw TRopException("setChannel: unsupported pixel type");
}
left->unlock();
}
示例5: setChannel
void TRop::setChannel(const TRasterP &rin, TRasterP rout, UCHAR chan,
bool greytones) {
assert(rin->getSize() == rout->getSize());
rout->lock();
if ((TRaster32P)rin && (TRaster32P)rout)
doSetChannel<TPixel32>(rin, rout, chan, greytones);
else if ((TRaster64P)rin && (TRaster64P)rout)
doSetChannel<TPixel64>(rin, rout, chan, greytones);
else {
rout->unlock();
throw TRopException("setChannel: unsupported pixel type");
}
rout->unlock();
}
示例6: over
void TRop::over(const TRasterP &rout, const TRasterP &rup, const TPoint &pos)
{
TRect outRect(rout->getBounds());
TRect upRect(rup->getBounds() + pos);
TRect intersection = outRect * upRect;
if (intersection.isEmpty())
return;
TRasterP cRout = rout->extract(intersection);
TRect r = intersection - pos;
TRasterP cRup = rup->extract(r);
TRaster32P rout32 = cRout, rup32 = cRup;
TRaster64P rout64 = cRout, rup64 = cRup;
TRasterGR8P rout8 = cRout, rup8 = cRup;
TRasterCM32P routCM32 = cRout, rupCM32 = cRup;
rout->lock();
rup->lock();
// TRaster64P rout64 = rout, rin64 = rin;
if (rout32 && rup32) {
#ifdef _WIN32
if (TSystem::getCPUExtensions() & TSystem::CpuSupportsSse2)
do_over_SSE2(rout32, rup32);
else
#endif
do_overT2<TPixel32, UCHAR>(rout32, rup32);
} else if (rout64) {
if (!rup64) {
TRaster64P raux(cRup->getSize());
TRop::convert(raux, cRup);
rup64 = raux;
}
do_overT2<TPixel64, USHORT>(rout64, rup64);
} else if (rout32 && rup8)
do_over(rout32, rup8);
else if (rout8 && rup32)
do_over(rout8, rup32);
else if (rout8 && rup8)
TRop::copy(rout8, rup8);
else if (routCM32 && rupCM32)
do_over(routCM32, rupCM32);
else {
rout->unlock();
rup->unlock();
throw TRopException("unsupported pixel type");
}
rout->unlock();
rup->unlock();
}
示例7: convertForWriting
void convertForWriting(TRasterP &ras, const TRasterP &rin, int bpp)
{
switch (bpp) {
case 1:
case 8:
ras = TRasterGR8P(rin->getSize());
TRop::convert(ras, rin);
break;
case 24:
case 32:
ras = TRaster32P(rin->getSize());
TRop::convert(ras, rin);
break;
case 48:
case 64:
ras = TRaster64P(rin->getSize());
TRop::convert(ras, rin);
break;
default:
assert(false);
}
}
示例8: erodilate
void TRop::erodilate(const TRasterP &src, const TRasterP &dst,
double radius, ErodilateMaskType type)
{
assert(src->getSize() == dst->getSize());
src->lock(), dst->lock();
if ((TRaster32P)src && (TRaster32P)dst)
switch (type) {
case ED_rectangular:
::rect_erodilate<TPixel32>(src, dst, radius);
break;
case ED_circular:
::circular_erodilate<TPixel32>(src, dst, radius);
break;
default:
assert(!"Unknown mask type");
break;
}
else if ((TRaster64P)src && (TRaster64P)dst)
switch (type) {
case ED_rectangular:
::rect_erodilate<TPixel64>(src, dst, radius);
break;
case ED_circular:
::circular_erodilate<TPixel64>(src, dst, radius);
break;
default:
assert(!"Unknown mask type");
break;
}
else
assert(!"Unsupported raster type!");
src->unlock(), dst->unlock();
}
示例9: setWorkAndBackupImages
void FullColorBrushTool::setWorkAndBackupImages()
{
TRasterImageP ri = (TRasterImageP)getImage(false, 1);
if (!ri)
return;
TRasterP ras = ri->getRaster();
TDimension dim = ras->getSize();
if (!m_workRaster || m_workRaster->getLx() > dim.lx || m_workRaster->getLy() > dim.ly)
m_workRaster = TRaster32P(dim);
if (!m_backUpRas || m_backUpRas->getLx() > dim.lx || m_backUpRas->getLy() > dim.ly ||
m_backUpRas->getPixelSize() != ras->getPixelSize())
m_backUpRas = ras->create(dim.lx, dim.ly);
m_strokeRect.empty();
m_lastRect.empty();
}
示例10: do_render
//.........这里部分代码省略.........
flash->popMatrix();
} else {
TRasterP ras;
std::string alias;
TRasterImageP rimg;
if (rimg = partLevel[part->level]->frame(ndx)) {
ras = rimg->getRaster();
} else {
alias = "PART: " + (*part_ports[part->level])->getAlias(ndx, riNew);
if (rimg = TImageCache::instance()->get(alias, false)) {
ras = rimg->getRaster();
// Check that the raster resolution is sufficient for our purposes
if (ras->getLx() < partResolution.lx ||
ras->getLy() < partResolution.ly)
ras = 0;
else
partResolution = TDimensionD(ras->getLx(), ras->getLy());
}
}
// We are interested in making the relation between scale and (integer)
// resolution
// bijective - since we shall cache by using resolution as a partial
// identification parameter.
// Therefore, we find the current bbox Lx and take a unique scale out of it.
partScale = partResolution.lx / standardRefBBox.getLx();
riNew.m_affine = TScale(partScale);
bbox = riNew.m_affine * standardRefBBox;
// If no image was retrieved from the cache (or it was not scaled enough),
// calculate it
if (!ras) {
TTile auxTile;
(*part_ports[part->level])
->allocateAndCompute(auxTile, bbox.getP00(),
TDimension(partResolution.lx, partResolution.ly),
tile->getRaster(), ndx, riNew);
ras = auxTile.getRaster();
// For now, we'll just use 32 bit particles
TRaster32P rcachepart;
rcachepart = ras;
if (!rcachepart) {
rcachepart = TRaster32P(ras->getSize());
TRop::convert(rcachepart, ras);
}
ras = rcachepart;
// Finally, cache the particle
addRenderCache(alias, TRasterImageP(ras));
}
if (!ras) return; // At this point, it should never happen anyway...
// Deal with particle colors/opacity
TRaster32P rfinalpart;
double curr_opacity =
part->set_Opacity(porttiles, values, opacity_range, dist_frame);
if (curr_opacity != 1.0 || part->gencol.fadecol || part->fincol.fadecol ||
part->foutcol.fadecol) {
/*- 毎フレーム現在位置のピクセル色を参照 -*/
if (values.pick_color_for_every_frame_val && values.gencol_ctrl_val &&
(porttiles.find(values.gencol_ctrl_val) != porttiles.end()))
part->get_image_reference(porttiles[values.gencol_ctrl_val], values,
part->gencol.col);
rfinalpart = ras->clone();
part->modify_colors_and_opacity(values, curr_opacity, dist_frame,
rfinalpart);
} else
rfinalpart = ras;
// Now, let's build the particle transform before it is overed on the output
// tile
// First, complete the transform by adding the rotational and scale
// components from
// Particles parameters
M = ri.m_affine * M * TScale(1.0 / partScale);
// Then, retrieve the particle position in current reference.
TPointD pos(part->x, part->y);
pos = ri.m_affine * pos;
// Finally, add the translational component to the particle
// NOTE: p_offset is added to account for the particle relative position
// inside its level's bbox
M = TTranslation(pos - tile->m_pos) * M * TTranslation(bbox.getP00());
if (TRaster32P myras32 = tile->getRaster())
TRop::over(tileRas, rfinalpart, M);
else if (TRaster64P myras64 = tile->getRaster())
TRop::over(tileRas, rfinalpart, M);
else
throw TException("ParticlesFx: unsupported Pixel Type");
}
}
示例11: makeDataRaster
void OutlineVectorizer::makeDataRaster(const TRasterP &src)
{
m_vimage = new TVectorImage();
if (!src)
return;
m_src = src;
clearNodes();
clearJunctions();
int x, y, ii = 0;
TRaster32P srcRGBM = (TRaster32P)m_src;
TRasterCM32P srcCM = (TRasterCM32P)m_src;
TRasterGR8P srcGR = (TRasterGR8P)m_src;
// Inizializzo DataRasterP per i casi in cui si ha un TRaster32P, un TRasterGR8P o un TRasterCM32P molto grande
DataRasterP dataRaster(m_src->getSize().lx + 2, m_src->getSize().ly + 2);
if (srcRGBM || srcGR || (srcCM && srcCM->getLx() * srcCM->getLy() > 5000000)) {
int ly = dataRaster->getLy();
int lx = dataRaster->getLx();
int wrap = dataRaster->getWrap();
DataPixel *dataPix0 = dataRaster->pixels(0);
DataPixel *dataPix1 = dataRaster->pixels(0) + m_src->getLx() + 1;
for (y = 0; y < ly; y++, dataPix0 += wrap, dataPix1 += wrap) {
dataPix0->m_pos.x = 0;
dataPix1->m_pos.x = lx - 1;
dataPix0->m_pos.y = dataPix1->m_pos.y = y;
dataPix0->m_value = dataPix1->m_value = 0;
dataPix0->m_ink = dataPix1->m_ink = false;
dataPix0->m_node = dataPix1->m_node = 0;
}
dataPix0 = dataRaster->pixels(0);
dataPix1 = dataRaster->pixels(ly - 1);
for (x = 0; x < lx; x++, dataPix0++, dataPix1++) {
dataPix0->m_pos.x = dataPix1->m_pos.x = x;
dataPix0->m_pos.y = 0;
dataPix1->m_pos.y = ly - 1;
dataPix0->m_value = dataPix1->m_value = 0;
dataPix0->m_ink = dataPix1->m_ink = false;
dataPix0->m_node = dataPix1->m_node = 0;
}
}
if (srcRGBM) {
assert(m_palette);
int inkId = m_palette->getClosestStyle(m_configuration.m_inkColor);
if (!inkId || m_configuration.m_inkColor != m_palette->getStyle(inkId)->getMainColor()) {
inkId = m_palette->getStyleCount();
m_palette->getStylePage(1)->insertStyle(1, m_configuration.m_inkColor);
m_palette->setStyle(inkId, m_configuration.m_inkColor);
}
assert(inkId);
m_dataRasterArray.push_back(std::pair<int, DataRasterP>(inkId, dataRaster));
int maxDistance2 = m_configuration.m_threshold * m_configuration.m_threshold;
for (y = 0; y < m_src->getLy(); y++) {
TPixel32 *inPix = srcRGBM->pixels(y);
TPixel32 *inEndPix = inPix + srcRGBM->getLx();
DataPixel *dataPix = dataRaster->pixels(y + 1) + 1;
x = 0;
while (inPix < inEndPix) {
*dataPix = DataPixel();
int distance2 = colorDistance2(m_configuration.m_inkColor, *inPix);
if (y == 0 || y == m_src->getLy() - 1 || x == 0 || x == m_src->getLx() - 1 || inPix->m == 0) {
dataPix->m_value = 255;
dataPix->m_ink = false;
} else {
dataPix->m_value = (inPix->r + 2 * inPix->g + inPix->b) >> 2;
dataPix->m_ink = (distance2 < maxDistance2);
}
dataPix->m_pos.x = x++;
dataPix->m_pos.y = y;
dataPix->m_node = 0;
inPix++;
dataPix++;
}
}
} else if (srcGR) {
示例12: if
void Convert2Tlv::buildToonzRaster(TRasterCM32P &rout, const TRasterP &rin1, const TRasterP &rin2)
{
if (rin2)
assert(rin1->getSize() == rin2->getSize());
rout->clear();
std::cout << " computing inks...\n";
TRaster32P r1 = (TRaster32P)rin1;
TRasterGR8P r1gr = (TRasterGR8P)rin1;
TRaster32P r2 = (TRaster32P)rin2;
TRasterGR8P r2gr = (TRasterGR8P)rin2;
TRasterP rU, rP;
if (r1gr) {
rU = r1gr;
rP = r2;
} else if (r2gr) {
rU = r2gr;
rP = r1;
} else if (!r1)
rU = r2;
else if (!r2)
rU = r1;
else if (firstIsUnpainted(r1, r2)) {
rU = r1;
rP = r2;
} else {
rU = r2;
rP = r1;
}
TRasterCM32P r;
if (rout->getSize() != rU->getSize()) {
int dx = rout->getLx() - rU->getLx();
int dy = rout->getLy() - rU->getLy();
assert(dx >= 0 && dy >= 0);
r = rout->extract(dx / 2, dy / 2, dx / 2 + rU->getLx() - 1, dy / 2 + rU->getLy() - 1);
} else
r = rout;
if ((TRasterGR8P)rU)
buildInksFromGrayTones(r, rU);
else if (m_isUnpaintedFromNAA)
buildInksForNAAImage(r, (TRaster32P)rU);
else {
int maxMatte = getMaxMatte((TRaster32P)rU);
if (maxMatte == -1)
buildInksFromGrayTones(r, rU);
else {
if (maxMatte < 255)
normalize(rU, maxMatte);
buildInks(r, (TRaster32P)rU /*rP,*/);
}
}
if (m_autoclose)
TAutocloser(r, AutocloseDistance, AutocloseAngle, 1, AutocloseOpacity).exec();
if (rP) {
std::cout << " computing paints...\n";
doFill(r, rP);
}
if (m_antialiasType == 2) //remove antialias
removeAntialias(r);
else if (m_antialiasType == 1) //add antialias
{
TRasterCM32P raux(r->getSize());
TRop::antialias(r, raux, 10, m_antialiasValue);
rout = raux;
}
}