本文整理汇总了C++中TRasterP::extract方法的典型用法代码示例。如果您正苦于以下问题:C++ TRasterP::extract方法的具体用法?C++ TRasterP::extract怎么用?C++ TRasterP::extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRasterP
的用法示例。
在下文中一共展示了TRasterP::extract方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: over
void TRop::over(const TRasterP &rout, const TRasterP &rdn, const TRasterP &rup)
{
TRect rect = rout->getBounds() * rdn->getBounds() * rup->getBounds();
if (rect.isEmpty())
return;
TRasterP cRout = rout->extract(rect);
TRasterP cRdn = rdn->extract(rect);
TRasterP cRup = rup->extract(rect);
rout->lock();
rdn->lock();
rup->lock();
TRaster32P rout32 = cRout, rdn32 = cRdn, rup32 = cRup;
TRaster64P rout64 = cRout, rdn64 = cRdn, rup64 = cRup;
if (rout32 && rdn32 && rup32)
do_overT3<TPixel32>(rout32, rdn32, rup32);
else if (rout64 && rdn64 && rup64)
do_overT3<TPixel64>(rout64, rdn64, rup64);
else {
rout->unlock();
rdn->unlock();
rup->unlock();
throw TRopException("unsupported pixel type");
}
rout->unlock();
rdn->unlock();
rup->unlock();
}
示例2: updateWorkAndBackupRasters
void FullColorBrushTool::updateWorkAndBackupRasters(const TRect &rect)
{
TRasterImageP ri = TImageP(getImage(false, 1));
if (!ri)
return;
TRasterP ras = ri->getRaster();
TRect _rect = rect * ras->getBounds();
TRect _lastRect = m_lastRect * ras->getBounds();
if (_rect.isEmpty())
return;
if (m_lastRect.isEmpty()) {
m_workRaster->extract(_rect)->clear();
m_backUpRas->extract(_rect)->copy(ras->extract(_rect));
return;
}
QList<TRect> rects = ToolUtils::splitRect(_rect, _lastRect);
for (int i = 0; i < rects.size(); i++) {
m_workRaster->extract(rects[i])->clear();
m_backUpRas->extract(rects[i])->copy(ras->extract(rects[i]));
}
}
示例3: copy
void TRop::copy(TRasterP dst, const TRasterP &src) {
assert(!((TRasterCM32P)src) || (TRasterCM32P)dst);
if (dst->getPixelSize() == src->getPixelSize())
dst->copy(src);
else {
if (dst->getBounds() != src->getBounds()) {
TRect rect = dst->getBounds() * src->getBounds();
if (rect.isEmpty()) return;
TRop::convert(dst->extract(rect), src->extract(rect));
} else
TRop::convert(dst, src);
}
}
示例4: upload
//! Copies the passed tile in the tile complex. The passed tile \b must
//! possess integer geometry (ie tile.m_pos must have integer coordinates),
//! otherwise this function is a no-op.
bool TCacheResource::upload(const TPoint &pos, TRasterP ras)
{
int tileType;
if (!checkRasterType(ras, tileType))
return false;
if (m_tileType == NONE)
m_tileType = tileType;
//For all cells of the lattice which intersect the tile, upload the content in the
//complex
TRect tileRect(ras->getBounds() + pos);
TPoint initialPos(getCellPos(tileRect.getP00()));
//DIAGNOSTICS_NUMBEREDSTRSET(prefix + QString::number((UINT) this) + " | Stack | ",
//"crStack", "upload", ::traduce(TRect(pos, ras->getSize())));
TPoint currPos;
for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep)
for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) {
//Copy tile's content into the cell's raster.
TRect cellRect(currPos, TDimension(latticeStep, latticeStep));
TRect overlapRect(tileRect * cellRect);
assert(!overlapRect.isEmpty());
PointLess cellIndex(getCellIndex(currPos));
std::pair<TRasterP, CellData *> cellInfos(touch(cellIndex));
TRasterP cellRas(cellInfos.first);
TRect temp(overlapRect - currPos);
TRasterP overlappingCellRas(cellRas->extract(temp));
temp = TRect(overlapRect - tileRect.getP00());
TRasterP overlappingTileRas(ras->extract(temp));
assert(overlappingCellRas->getBounds() == overlappingTileRas->getBounds());
TRop::copy(overlappingCellRas, overlappingTileRas);
cellInfos.second->m_modified = true;
}
//Update the complex's content region
m_region += toQRect(tileRect);
return true;
}
示例5: eraseRect
TRect TRasterImageUtils::eraseRect(const TRasterImageP &ri, const TRectD &area)
{
TRasterP ras = ri->getRaster();
TRect rect = convertWorldToRaster(area, ri) * ras->getBounds();
if (rect.isEmpty())
return rect;
ras->lock();
TRasterP workRas = ras->extract(rect);
if (workRas->getPixelSize() == 4)
workRas->clear();
else {
TRasterGR8P rasGR8(workRas);
if (rasGR8)
rasGR8->fill(TPixelGR8::White);
}
ras->unlock();
return rect;
}
示例6: downloadAll
bool TCacheResource::downloadAll(const TPoint &pos, TRasterP ras)
{
int tileType;
if (!checkRasterType(ras, tileType))
return false;
//Build the tile's rect
TRect tileRect(ras->getBounds() + pos);
if (!contains(m_region, tileRect))
return false;
//DIAGNOSTICS_NUMBEREDSTRSET(prefix + QString::number((UINT) this) + " | Stack | ",
//"crStack", "downloadAll", ::traduce(TRect(pos, ras->getSize())));
//For all cells intersecting the tile's rect, copy all those intersecting the
//complex's content region.
TPoint initialPos(getCellPos(tileRect.getP00()));
TPoint currPos;
for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep)
for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) {
TRect cellRect(currPos, TDimension(latticeStep, latticeStep));
TRect overlapRect(tileRect * cellRect);
assert(!overlapRect.isEmpty());
QRect overlapQRect(toQRect(overlapRect));
if (m_region.intersects(overlapQRect)) {
//Extract the associated rasters and perform the copy to the input tile.
std::pair<TRasterP, CellData *> cellInfos(touch(getCellIndex(currPos)));
TRasterP cellRas(cellInfos.first);
TRect temp(overlapRect - currPos);
TRasterP overlappingCellRas(cellRas->extract(temp));
temp = TRect(overlapRect - tileRect.getP00());
TRasterP overlappingTileRas(ras->extract(temp));
TRop::copy(overlappingTileRas, overlappingCellRas);
}
}
return true;
}
示例7: download
//! Fills the passed tile with the data contained in the complex, returning
//! the copied region.
//! The same restriction of the upload() method applies here.
QRegion TCacheResource::download(const TPoint &pos, TRasterP ras)
{
int tileType;
if (!checkRasterType(ras, tileType))
return QRegion();
//Build the tile's rect
TRect tileRect(ras->getBounds() + pos);
if (!m_region.intersects(toQRect(tileRect)))
return QRegion();
//For all cells intersecting the tile's rect, copy all those intersecting the
//complex's content region.
TPoint initialPos(getCellPos(tileRect.getP00()));
TPoint currPos;
for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep)
for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) {
TRect cellRect(currPos, TDimension(latticeStep, latticeStep));
TRect overlapRect(tileRect * cellRect);
assert(!overlapRect.isEmpty());
QRect overlapQRect(toQRect(overlapRect));
if (m_region.intersects(overlapQRect)) {
//Extract the associated rasters and perform the copy to the input tile.
std::pair<TRasterP, CellData *> cellInfos(touch(getCellIndex(currPos)));
TRasterP cellRas(cellInfos.first);
TRect temp(overlapRect - currPos);
TRasterP overlappingCellRas(cellRas->extract(temp));
temp = TRect(overlapRect - tileRect.getP00());
TRasterP overlappingTileRas(ras->extract(temp));
TRop::copy(overlappingTileRas, overlappingCellRas);
}
}
return m_region.intersected(QRegion(toQRect(tileRect)));
}
示例8: doCompute
//.........这里部分代码省略.........
// Calculate source
if (status & Port1Connected) m_lighted->compute(tile, frame, ri);
// Calculate light
if (status & Port0Connected) {
// Init light infos
TDimension tileSize(tile.getRaster()->getSize());
TRectD tileRect(tile.m_pos, TDimensionD(tileSize.lx, tileSize.ly));
double scale = sqrt(fabs(ri.m_affine.det()));
double blur = m_value->getValue(frame) * scale;
// Build the light interesting rect
TRectD lightRect, blurOutRect;
m_light->getBBox(frame, lightRect, ri);
buildLightRects(tileRect, lightRect, blurOutRect, blur);
if ((lightRect.getLx() <= 0) || (lightRect.getLy() <= 0)) return;
if ((blurOutRect.getLx() <= 0) || (blurOutRect.getLy() <= 0)) return;
// Calculate the light tile
TTile lightTile;
TDimension lightSize(tround(lightRect.getLx()),
tround(lightRect.getLy()));
m_light->allocateAndCompute(lightTile, lightRect.getP00(), lightSize,
tile.getRaster(), frame, ri);
// Init glow parameters
TPixel32 color = m_color->getValue(frame);
double brightness = m_brightness->getValue(frame) / 100.0;
double fade = m_fade->getValue(frame) / 100.0;
// Now, apply the glow
// First, deal with the fade
{
TRasterP light = lightTile.getRaster();
TRaster32P light32 = light;
TRaster64P light64 = light;
if (light32)
::fade(light32, fade, color);
else if (light64)
::fade(light64, fade, toPixel64(color));
else
assert(false);
}
// Then, build the blur
TRasterP blurOut;
if (blur > 0) {
// Build a temporary output to the blur
{
TRasterP light(lightTile.getRaster());
blurOut = light->create(tround(blurOutRect.getLx()),
tround(blurOutRect.getLy()));
// Apply the blur. Please note that SSE2 should not be used for now -
// I've seen it
// doing strange things to the blur...
TPointD displacement(lightRect.getP00() - blurOutRect.getP00());
TRop::blur(blurOut, light, blur, tround(displacement.x),
tround(displacement.y), false);
}
} else
blurOut = lightTile.getRaster();
// Apply the rgbm scale
TRop::rgbmScale(blurOut, blurOut, 1, 1, 1, brightness);
// Apply the add
{
TRectD interestingRect(tileRect * blurOutRect);
TRect interestingTileRect(tround(interestingRect.x0 - tileRect.x0),
tround(interestingRect.y0 - tileRect.y0),
tround(interestingRect.x1 - tileRect.x0) - 1,
tround(interestingRect.y1 - tileRect.y0) - 1);
TRect interestingBlurRect(
tround(interestingRect.x0 - blurOutRect.x0),
tround(interestingRect.y0 - blurOutRect.y0),
tround(interestingRect.x1 - blurOutRect.x0) - 1,
tround(interestingRect.y1 - blurOutRect.y0) - 1);
if ((interestingTileRect.getLx() <= 0) ||
(interestingTileRect.getLy() <= 0))
return;
if ((interestingBlurRect.getLx() <= 0) ||
(interestingBlurRect.getLy() <= 0))
return;
TRasterP tileInterestRas(
tile.getRaster()->extract(interestingTileRect));
TRasterP blurInterestRas(blurOut->extract(interestingBlurRect));
TRop::add(blurInterestRas, tileInterestRas, tileInterestRas);
}
}
}