当前位置: 首页>>代码示例>>C++>>正文


C++ TRasterP::extract方法代码示例

本文整理汇总了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();
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:29,代码来源:tover.cpp

示例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]));
	}
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:26,代码来源:fullcolorbrushtool.cpp

示例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);
  }
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:13,代码来源:trop.cpp

示例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;
}
开发者ID:GREYFOXRGR,项目名称:opentoonz,代码行数:49,代码来源:tcacheresource.cpp

示例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;
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:18,代码来源:trasterimageutils.cpp

示例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;
}
开发者ID:GREYFOXRGR,项目名称:opentoonz,代码行数:44,代码来源:tcacheresource.cpp

示例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)));
}
开发者ID:GREYFOXRGR,项目名称:opentoonz,代码行数:44,代码来源:tcacheresource.cpp

示例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);
      }
    }
  }
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:101,代码来源:glowfx.cpp


注:本文中的TRasterP::extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。