• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TRaster32P类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TRaster32P的典型用法代码示例。如果您正苦于以下问题:C++ TRaster32P类的具体用法?C++ TRaster32P怎么用?C++ TRaster32P使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: scale

void MeshTexturizer::Imp::allocateTextures(int groupIdx, const TRaster32P &ras, const TRaster32P &aux,
										   int x, int y, int textureLx, int textureLy,
										   bool premultiplied)
{
	TextureData *data = m_textureDatas[groupIdx].get();

	// Test the specified texture allocation
	if (testTextureAlloc(textureLx, textureLy)) {
		TPointD scale(data->m_geom.getLx() / (double)ras->getLx(),
					  data->m_geom.getLy() / (double)ras->getLy());
		TRectD tileGeom(
			TRectD(
				scale.x * (x - TOTAL_BORDER), scale.y * (y - TOTAL_BORDER),
				scale.x * (x + textureLx + TOTAL_BORDER), scale.y * (y + textureLy + TOTAL_BORDER)) +
			data->m_geom.getP00());

		GLuint texId = textureAlloc(ras, aux, x, y, textureLx, textureLy, premultiplied);

		TextureData::TileData td = {texId, tileGeom};
		data->m_tileDatas.push_back(td);

		return;
	}

	if (textureLx <= 1 && textureLy <= 1)
		return; // No texture can be allocated

	// The texture could not be allocated. Then, bisecate and branch.
	if (textureLx > textureLy) {
		int textureLx_2 = textureLx >> 1;
		allocateTextures(groupIdx, ras, aux, x, y, textureLx_2, textureLy, premultiplied);
		allocateTextures(groupIdx, ras, aux, x + textureLx_2, y, textureLx_2, textureLy, premultiplied);
	} else {
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:33,代码来源:meshtexturizer.cpp


示例2: getRasterPoint

/*-- (StylePickerTool内で)LineとAreaを切り替えてPickできる。mode: 0=Area, 1=Line, 2=Line&Areas(default)  --*/
int StylePicker::pickStyleId(const TPointD &pos, double radius2, int mode) const
{
	int styleId = 0;
	if (TToonzImageP ti = m_image) {
		TRasterCM32P ras = ti->getRaster();
		TPoint point = getRasterPoint(pos);
		if (!ras->getBounds().contains(point))
			return -1;
		TPixelCM32 col = ras->pixels(point.y)[point.x];

		switch (mode) {
		case 0: //AREAS
			styleId = col.getPaint();
			break;
		case 1: //LINES
			styleId = col.getInk();
			break;
		case 2: //ALL (Line & Area)
		default:
			styleId = col.isPurePaint() ? col.getPaint() : col.getInk();
			break;
		}
	} else if (TRasterImageP ri = m_image) {
		const TPalette *palette = m_palette.getPointer();
		if (!palette)
			return -1;
		TRaster32P ras = ri->getRaster();
		if (!ras)
			return -1;
		TPoint point = getRasterPoint(pos);
		if (!ras->getBounds().contains(point))
			return -1;
		TPixel32 col = ras->pixels(point.y)[point.x];
		styleId = palette->getClosestStyle(col);
	} else if (TVectorImageP vi = m_image) {
		// prima cerca lo stile della regione piu' vicina
		TRegion *r = vi->getRegion(pos);
		if (r)
			styleId = r->getStyle();
		// poi cerca quello della stroke, ma se prima aveva trovato una regione, richiede che
		// il click sia proprio sopra la stroke, altrimenti cerca la stroke piu' vicina (max circa 10 pixel)
		const double maxDist2 = (styleId == 0) ? 100.0 * radius2 : 0;
		bool strokeFound;
		double dist2, w, thick;
		UINT index;
		//!funzionerebbe ancora meglio con un getNearestStroke che considera
		//la thickness, cioe' la min distance dalla outline e non dalla centerLine
		strokeFound = vi->getNearestStroke(pos, w, index, dist2);
		if (strokeFound) {
			TStroke *stroke = vi->getStroke(index);
			thick = stroke->getThickPoint(w).thick;
			if (dist2 - thick * thick < maxDist2) {
				assert(stroke);
				styleId = stroke->getStyle();
			}
		}
	}
	return styleId;
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:60,代码来源:stylepicker.cpp


示例3:

FullColorAreaFiller::FullColorAreaFiller(const TRaster32P &ras)
    : m_ras(ras)
    , m_bounds(ras->getBounds())
    , m_pixels(ras->pixels())
    , m_wrap(ras->getWrap())
    , m_color(0) {
  m_ras->lock();
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:8,代码来源:fillutil.cpp


示例4: setMatteAndYMirror

//------------------------------------------------
inline void setMatteAndYMirror(const TRaster32P &ras)
{
	ras->lock();
	TPixel32 *upRow = ras->pixels();
	TPixel32 *dwRow = ras->pixels(ras->getLy() - 1);
	int hLy = (int)(ras->getLy() / 2. + 0.5); //piccola pessimizzazione...
	int wrap = ras->getWrap();
	int lx = ras->getLx();
	TPixel32 *upPix = 0;
	TPixel32 *lastPix = ras->pixels(hLy);
	while (upPix < lastPix) {
		upPix = upRow;
		TPixel32 *dwPix = dwRow;
		TPixel32 *endPix = upPix + lx;
		while (upPix < endPix) {
			TPixel32 tmpPix(upPix->r, upPix->g, upPix->b, 0xff);
			*upPix = *dwPix;
			upPix->m = 0xff;
			*dwPix = tmpPix;
			++upPix;
			++dwPix;
		}
		upRow += wrap;
		dwRow -= wrap;
	}
	ras->unlock();
}
开发者ID:AmEv7Fam,项目名称:opentoonz,代码行数:28,代码来源:tiio_3gpM.cpp


示例5: computeCentroid

TPoint computeCentroid(const TRaster32P &r) {
  TPoint ret(1, 1);

  TRasterGR8P raux(r->getLx() + 2, r->getLy() + 2);

  if (fillByteRaster(r, raux)) doComputeCentroid(raux, ret);

  ret.x--;
  ret.y--; /* per il bordo aggiunto */
  return ret;
}
开发者ID:luc--,项目名称:opentoonz,代码行数:11,代码来源:trastercentroid.cpp


示例6: addBackground32

static void addBackground32(TRaster32P ras, const TPixel32 &col)
{
	ras->lock();
	int nrows = ras->getLy();
	while (nrows-- > 0) {
		TPixel32 *pix = ras->pixels(nrows);
		TPixel32 *endPix = pix + ras->getLx();
		while (pix < endPix) {
			*pix = overPix(col, *pix);
			pix++;
		}
	}
	ras->unlock();
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:14,代码来源:tover.cpp


示例7: swapRBChannels

void TRop::swapRBChannels(const TRaster32P &r) {
  int lx = r->getLx();
  int y  = r->getLy();
  r->lock();
  while (--y >= 0) {
    TPixel32 *pix    = r->pixels(y);
    TPixel32 *endPix = pix + lx;
    while (pix < endPix) {
      tswap(pix->r, pix->b);
      ++pix;
    }
  }
  r->unlock();
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:14,代码来源:trop.cpp


示例8: overPixOnWhite

void Naa2TlvConverter::setSourceImage(const TRaster32P &srcRas) {
  int lx = srcRas->getSize().lx;
  int ly = srcRas->getSize().ly;

  m_colors.clear();
  m_regions.clear();
  delete m_regionRas;
  m_regionRas = new WorkRaster<unsigned short>(lx, ly);
  delete m_borderRas;
  m_borderRas = 0;

  delete m_dotRas;
  m_dotRas = 0;

  delete m_syntheticInkRas;
  m_syntheticInkRas = 0;

  QMap<TPixel32, int> colorTable;
  for (int y = 0; y < ly; y++) {
    TPixel32 *srcScanLine          = srcRas->pixels(y);
    unsigned short *regionScanLine = m_regionRas->pixels(y);
    for (int x = 0; x < lx; x++) {
      TPixel32 srcPix = overPixOnWhite(srcScanLine[x]);
      QMap<TPixel32, int>::ConstIterator it = colorTable.find(srcPix);
      if (it == colorTable.end()) {
        // found new color (and therefore new region)
        RegionInfo r;
        // add new color
        r.colorIndex = m_colors.count();
        m_colors.append(srcPix);
        r.pixelCount = 1;
        // add new region
        int regionIndex = m_regions.count();
        m_regions.append(r);
        // update raster and colorTable
        regionScanLine[x] = regionIndex;
        colorTable.insert(srcPix, regionIndex);
        if (m_colors.count() > MaxColorCount) {
          return;
        }
      } else {
        // already defined color
        int regionIndex   = it.value();
        regionScanLine[x] = regionIndex;
        m_regions[regionIndex].pixelCount++;
      }
    }
  }
  m_valid = true;
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:50,代码来源:Naa2TlvConverter.cpp


示例9: do_over

void do_over(TRaster32P rout, const TRasterGR8P &rup, const TPixel32 &color)
{
	assert(rout->getSize() == rup->getSize());
	for (int y = rout->getLy(); --y >= 0;) {
		TPixel32 *out_pix = rout->pixels(y);
		TPixel32 *const out_end = out_pix + rout->getLx();
		const TPixelGR8 *up_pix = rup->pixels(y);

		for (; out_pix < out_end; ++out_pix, ++up_pix) {
			double v = up_pix->value / 255.0;
			TPixel32 up(troundp(v * color.r), troundp(v * color.g), troundp(v * color.b), troundp(v * color.m));
			*out_pix = overPix(*out_pix, up);
		}
	}
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:15,代码来源:tover.cpp


示例10: my_do_over

//Usata tinylinetest
static void my_do_over(TRaster32P rout, const TRasterGR8P &rup)
{
	assert(rout->getSize() == rup->getSize());
	for (int y = rout->getLy(); --y >= 0;) {
		TPixel32 *out_pix = rout->pixels(y);
		TPixel32 *const out_end = out_pix + rout->getLx();
		const TPixelGR8 *up_pix = rup->pixels(y);

		for (; out_pix < out_end; ++out_pix, ++up_pix) {
			int v = up_pix->value;
			out_pix->r = out_pix->r * v / 255;
			out_pix->g = out_pix->r;
			out_pix->b = out_pix->r;
		}
	}
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:17,代码来源:tover.cpp


示例11: checkColor

QScriptValue ImageBuilder::fill(const QString &colorName) {
  QColor color;
  QScriptValue err = checkColor(context(), colorName, color);
  if (err.isError()) return err;
  TPixel32 pix(color.red(), color.green(), color.blue(), color.alpha());
  if (m_img) {
    if (m_img->getType() != TImage::RASTER)
      context()->throwError("Can't fill a non-'Raster' image");
    TRaster32P ras = m_img->raster();
    if (ras) ras->fill(pix);
  } else if (m_width > 0 && m_height > 0) {
    TRaster32P ras(m_width, m_height);
    ras->fill(pix);
    m_img = TRasterImageP(ras);
  }
  return context()->thisObject();
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:17,代码来源:scriptbinding_image_builder.cpp


示例12: clearMatte

		static void clearMatte(const TRaster32P &ras, int xBegin, int yBegin, int xEnd, int yEnd)
		{
			for (int y = yBegin; y != yEnd; ++y) {
				TPixel32 *line = ras->pixels(y), *pixEnd = line + xEnd;

				for (TPixel32 *pix = line + xBegin; pix != pixEnd; ++pix)
					pix->m = 0;
			}
		}
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:9,代码来源:meshtexturizer.cpp


示例13: assert

TImageP ImageFiller::build(int imFlags, void *extData)
{
	assert(imFlags == ImageManager::none);

	// Fetch image
	assert(extData);

	ImageLoader::BuildExtData *data = (ImageLoader::BuildExtData *)extData;
	assert(data->m_subs == 0);

	const std::string &srcImgId = data->m_sl->getImageId(data->m_fid);

	TImageP img = ImageManager::instance()->getImage(srcImgId, imFlags, extData);
	if (img) {
		TRasterImageP ri = img;
		if (ri) {
			TRaster32P ras = ri->getRaster();
			if (ras) {
				TRaster32P newRas = ras->clone();
				FullColorAreaFiller filler(newRas);

				TPaletteP palette = new TPalette();
				int styleId = palette->getPage(0)->addStyle(TPixel32::White);

				FillParameters params;
				params.m_palette = palette.getPointer();
				params.m_styleId = styleId;
				params.m_minFillDepth = 0;
				params.m_maxFillDepth = 15;
				filler.rectFill(newRas->getBounds(), params, false);

				TRasterImageP ri = TRasterImageP(newRas);
				return ri;
			}
		}
	}

	// Error case: return a dummy image (is it really required?)

	TRaster32P ras(10, 10);
	ras->fill(TPixel32(127, 0, 127, 127));

	return TRasterImageP(ras);
}
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:44,代码来源:imagebuilders.cpp


示例14: readbmp

TImageP TImageReaderBmp::load()
{
	TImageP image;
	void *buff;
	int retCode = readbmp(getFilePath().getWideString().c_str(), &m_lx, &m_ly, &buff);
	if (retCode != OK) {
		throw TImageException(getFilePath(), buildBMPExceptionString(retCode));
	}

	TRaster32P raster;
	raster.create(m_lx, m_ly);
	raster->lock();
	memcpy(raster->pixels(), buff, m_lx * m_ly * sizeof(TPixel32));
	raster->unlock();
	TRasterImageP rasImage(raster);
	// image->setRaster(raster);
	delete[] buff;
	return TImageP(rasImage);
}
开发者ID:AmEv7Fam,项目名称:opentoonz,代码行数:19,代码来源:tiio_bmp.cpp


示例15: write

void Writer::write(const TRaster32P &ras, Processor *processor)
{
	m_context->makeCurrent();
	glClear(GL_COLOR_BUFFER_BIT);
	if (ras) {
		glRasterPos2d(0, 0);
		glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // ras->getWrap());
		glDrawPixels(ras->getLx(), ras->getLy(), TGL_FMT, TGL_TYPE, ras->getRawData());
	}
	if (processor) {
		processor->draw();
	}
	glRasterPos2d(0, 0);
	glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // ras->getWrap());
	glReadPixels(0, 0, m_raster->getLx(), m_raster->getLy(), TGL_FMT, TGL_TYPE, m_raster->getRawData());

	TImageP img = TRasterImageP(m_raster);
	m_levelWriter->getFrameWriter(++m_frameCount)->save(img);
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:19,代码来源:writer.cpp


示例16: clearMatte_border

		static void clearMatte_border(const TRaster32P &ras, int border0, int border1)
		{
			assert(border0 < border1);

			// Horizontal
			clearMatte(ras, border0, border0, ras->getLx() - border0, border1);
			clearMatte(ras, border0, ras->getLy() - border1, ras->getLx() - border0, ras->getLy() - border0);

			// Vertical
			clearMatte(ras, border0, border1, border1, ras->getLy() - border1);
			clearMatte(ras, ras->getLx() - border1, border1, ras->getLx() - border0, ras->getLy() - border1);
		}
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:12,代码来源:meshtexturizer.cpp


示例17: buildLayers

// Copies the cmIn paint and ink colors to the output rasters.
void buildLayers(const TRasterCM32P &cmIn,
                 const std::vector<TPixel32> &palColors, TRaster32P &inkRaster,
                 TRaster32P &paintRaster) {
  // Separate cmIn by copying the ink & paint colors directly to the layer
  // rasters.
  TPixelCM32 *cmPix, *cmBegin = (TPixelCM32 *)cmIn->getRawData();
  TPixel32 *inkPix   = (TPixel32 *)inkRaster->getRawData();
  TPixel32 *paintPix = (TPixel32 *)paintRaster->getRawData();

  unsigned int i, j, lx = cmIn->getLx(), ly = cmIn->getLy(),
                     wrap = cmIn->getWrap();
  for (i = 0; i < ly; ++i) {
    cmPix = cmBegin + i * wrap;

    for (j = 0; j < lx; ++j, ++cmPix, ++inkPix, ++paintPix) {
      *inkPix   = palColors[cmPix->getInk()];
      *paintPix = palColors[cmPix->getPaint()];

      // Should pure colors be checked...?
    }
  }
}
开发者ID:luc--,项目名称:opentoonz,代码行数:23,代码来源:blend.cpp


示例18: TRaster32P

void LinesFadePopup::setCurrentSampleRaster()
{
	TRaster32P sampleRas;

	m_startRas = TRaster32P();
	TSelection *selection = TApp::instance()->getCurrentSelection()->getSelection();
	TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(selection);
	TFilmstripSelection *filmstripSelection = dynamic_cast<TFilmstripSelection *>(selection);
	if (cellSelection) {
		TApp *app = TApp::instance();
		TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
		TXshCell cell = xsh->getCell(app->getCurrentFrame()->getFrameIndex(), app->getCurrentColumn()->getColumnIndex());
		TRasterImageP rasImage = cell.getImage(true);
		if (rasImage && rasImage->getRaster())
			sampleRas = rasImage->getRaster()->clone();
	} else if (filmstripSelection) {
		TApp *app = TApp::instance();
		TXshSimpleLevel *simpleLevel = app->getCurrentLevel()->getSimpleLevel();
		if (simpleLevel) {
			TRasterImageP rasImage = (TRasterImageP)simpleLevel->getFrame(app->getCurrentFrame()->getFid(), true);
			if (rasImage && rasImage->getRaster())
				sampleRas = rasImage->getRaster()->clone();
		}
	}
	if (!sampleRas) {
		m_viewer->raster() = TRasterP();
		m_viewer->update();
		m_okBtn->setEnabled(false);
		return;
	}

	m_okBtn->setEnabled(true);
	m_startRas = sampleRas->clone();
	onChange(m_startRas, sampleRas, m_linesColorField->getColor(), m_intensity->getValue());

	m_viewer->raster() = sampleRas;
	m_viewer->update();
}
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:38,代码来源:linesfadepopup.cpp


示例19: process

void DummyProcessor::process(TRaster32P raster)
{
	if (isActive()) {
		int x, y, lx = raster->getLx(), ly = raster->getLy();
		m_dummyData.clear();
		m_dummyData.resize(ly, 0);
		std::vector<int> hues(lx);
		for (y = 0; y < ly; y++) {
			TPixel32 *pix = raster->pixels(y);
			for (x = 0; x < lx; x++) {
				int hsv[3];
				rgb2hsv(hsv, *pix);
				hues[x] = hsv[0];
				pix++;
			}
			std::pair<int, int> range;
			for (x = 0; x + 1 < lx; x++)
				if (abs(hues[x] - hues[x + 1]) > 5)
					break;
			m_dummyData[y] = x;
		}
	}
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:23,代码来源:dummyprocessor.cpp


示例20:

void Convert2Tlv::buildInksForNAAImage(TRasterCM32P &rout, const TRaster32P &rin)
{
	std::map<TPixel, int>::iterator it;
	TPixel curColor = TPixel::Transparent;
	int i, j;
	int curIndex;

	//prima passata: identifico i colori di inchiostro e metto in rout i pixel di inchiostro puro
	for (i = 0; i < rin->getLy(); i++) {
		TPixel *pixin = rin->pixels(i);
		TPixelCM32 *pixout = rout->pixels(i);
		for (j = 0; j < rin->getLx(); j++, pixin++, pixout++) {
			TPixel colorIn;

			/*- treat white/transparent pixels as transparent -*/
			if (*pixin == TPixel(255, 255, 255) || *pixin == TPixel::Transparent) {
				*pixout = TPixelCM32(0, 0, 255);
				continue;
			}

			if (curColor != *pixin) {
				curColor = *pixin;
				if ((it = m_colorMap.find(curColor)) == m_colorMap.end()) {
					if (m_lastIndex < 4095)
						m_colorMap[curColor] = ++m_lastIndex;
					curIndex = m_lastIndex;
				} else
					curIndex = it->second;
			}
			*pixout = TPixelCM32(curIndex, 0, 0);
		}
	}

	if (m_colorMap.empty())
		m_colorMap[TPixel::Black] = ++m_lastIndex;
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:36,代码来源:convert2tlv.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TRasterCM32P类代码示例发布时间:2022-05-31
下一篇:
C++ TRange类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap