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


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

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


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

示例1: fill

/*-- 戻り値はsaveBoxが更新されたかどうか --*/
bool fill(const TRasterCM32P &r, const FillParameters &params, TTileSaverCM32 *saver)
{
	TPixelCM32 *pix, *limit, *pix0, *oldpix;
	int oldy, xa, xb, xc, xd, dy;
	int oldxc, oldxd;
	int tone, oldtone;
	TPoint p = params.m_p;
	int x = p.x, y = p.y;
	int paint = params.m_styleId;
	int fillDepth = params.m_shiftFill ? params.m_maxFillDepth : params.m_minFillDepth;

	/*-- getBoundsは画像全面 --*/
	TRect bbbox = r->getBounds();

	/*- 画面外のクリックの場合はreturn -*/
	if (!bbbox.contains(p))
		return false;
	/*- 既に同じ色が塗られている場合はreturn -*/
	if ((r->pixels(p.y) + p.x)->getPaint() == paint)
		return false;
	/*- 「透明部分だけを塗る」オプションが有効で、既に色が付いている場合はreturn -*/
	if (params.m_emptyOnly && (r->pixels(p.y) + p.x)->getPaint() != 0)
		return false;

	assert(fillDepth >= 0 && fillDepth < 16);

	switch (TPixelCM32::getMaxTone()) {
	case 15:
		fillDepth = (15 - fillDepth);
		break;
	case 255:
		fillDepth = ((15 - fillDepth) << 4) | (15 - fillDepth);
		break;
	default:
		assert(false);
	}

	/*-- 四隅の色を見て、一つでも変わったらsaveBoxを更新する --*/
	TPixelCM32 borderIndex[4];
	TPixelCM32 *borderPix[4];
	pix = r->pixels(0);
	borderPix[0] = pix;
	borderIndex[0] = *pix;
	pix += r->getLx() - 1;
	borderPix[1] = pix;
	borderIndex[1] = *pix;
	pix = r->pixels(r->getLy() - 1);
	borderPix[2] = pix;
	borderIndex[2] = *pix;
	pix += r->getLx() - 1;
	borderPix[3] = pix;
	borderIndex[3] = *pix;

	std::stack<FillSeed> seeds;

	fillRow(r, p, xa, xb, paint, params.m_palette, saver);
	seeds.push(FillSeed(xa, xb, y, 1));
	seeds.push(FillSeed(xa, xb, y, -1));

	while (!seeds.empty()) {
		FillSeed fs = seeds.top();
		seeds.pop();

		xa = fs.m_xa;
		xb = fs.m_xb;
		oldy = fs.m_y;
		dy = fs.m_dy;
		y = oldy + dy;
		if (y > bbbox.y1 || y < bbbox.y0)
			continue;
		pix = pix0 = r->pixels(y) + xa;
		limit = r->pixels(y) + xb;
		oldpix = r->pixels(oldy) + xa;
		x = xa;
		oldxd = (std::numeric_limits<int>::min)();
		oldxc = (std::numeric_limits<int>::max)();
		while (pix <= limit) {
			oldtone = threshTone(*oldpix, fillDepth);
			tone = threshTone(*pix, fillDepth);
			if (pix->getPaint() != paint && tone <= oldtone && tone != 0) {
				fillRow(r, TPoint(x, y), xc, xd, paint, params.m_palette, saver);
				if (xc < xa)
					seeds.push(FillSeed(xc, xa - 1, y, -dy));
				if (xd > xb)
					seeds.push(FillSeed(xb + 1, xd, y, -dy));
				if (oldxd >= xc - 1)
					oldxd = xd;
				else {
					if (oldxd >= 0)
						seeds.push(FillSeed(oldxc, oldxd, y, dy));
					oldxc = xc;
					oldxd = xd;
				}
				pix += xd - x + 1;
				oldpix += xd - x + 1;
				x += xd - x + 1;
			} else {
				pix++;
				oldpix++, x++;
//.........这里部分代码省略.........
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:101,代码来源:fill.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::pixels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。