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


C++ TRasterCM32P::clear方法代码示例

本文整理汇总了C++中TRasterCM32P::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ TRasterCM32P::clear方法的具体用法?C++ TRasterCM32P::clear怎么用?C++ TRasterCM32P::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TRasterCM32P的用法示例。


在下文中一共展示了TRasterCM32P::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

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

示例2: drawChar

TPoint TFont::drawChar(TRasterCM32P &outImage, TPoint &glyphOrigin, int inkId, wchar_t charcode, wchar_t nextCharCode) const
{
	TRasterGR8P grayAppImage;
	TPoint glyphOrig = appDrawChar(grayAppImage, m_pimpl->m_hdc, charcode);

	if (glyphOrig.x < 0) {
		glyphOrigin.x = glyphOrig.x;
		glyphOrig.x = 0;
	} else
		glyphOrigin.x = 0;

	if (glyphOrig.y < 0) {
		glyphOrigin.y = glyphOrig.y;
		glyphOrig.y = 0;
	} else
		glyphOrigin.y = 0;

	int srcLx = grayAppImage->getLx();
	int srcLy = grayAppImage->getLy();

	int dstLx = srcLx + glyphOrig.x;
	int dstLy = getMaxHeight();

	outImage = TRasterCM32P(dstLx, dstLy);
	outImage->clear();

	assert(TPixelCM32::getMaxTone() == 255);
	// TPixelCM32 bgColor(BackgroundStyle,BackgroundStyle,TPixelCM32::getMaxTone());
	TPixelCM32 bgColor;

	int ty = m_pimpl->m_metrics.tmDescent - 1 + glyphOrig.y;
	assert(ty < dstLy);
	assert(ty >= srcLy - 1);
	grayAppImage->lock();
	outImage->lock();

	for (int sy = 0; sy < srcLy; ++sy, --ty) {
		TPixelGR8 *srcPix = grayAppImage->pixels(sy);
		TPixelCM32 *tarPix = outImage->pixels(ty) + glyphOrig.x;
		for (int x = 0; x < srcLx; ++x) {
			int tone = 256 - (srcPix->value << 2);

			// grayScale  ToonzImage tone   Meaning
			//         0  255               Bg = PurePaint
			//         1  252
			//                 ...
			//        63    4
			//        64    0               Fg = Pure Ink

			if (tone < 0)
				tone = 0;

			if (tone >= 255)
				*tarPix = bgColor;
			else
				*tarPix = TPixelCM32(inkId, 0, tone); // BackgroundStyle,tone);

			++srcPix;
			++tarPix;
		}
	}
	grayAppImage->unlock();
	outImage->unlock();

	return getDistance(charcode, nextCharCode);
}
开发者ID:AmEv7Fam,项目名称:opentoonz,代码行数:66,代码来源:tfont_nt.cpp


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