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


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

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


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

示例1: 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

示例2: rectFill

void FullColorAreaFiller::rectFill(const TRect &rect,
                                   const FillParameters &params,
                                   bool onlyUnfilled) {
  TRect bbox = m_ras->getBounds();
  TRect r    = rect * bbox;
  if (r.isEmpty()) return;

  TRaster32P workRas = m_ras->extract(r);
  TRaster32P copy    = workRas->clone();

  TPixel32 color = params.m_palette->getStyle(params.m_styleId)->getMainColor();

  // Fillo tutto il quadaratino con color
  int x, y;
  for (y = 0; y < workRas->getLy(); y++) {
    TPixel32 *line = workRas->pixels(y);
    for (x        = 0; x < workRas->getLx(); x++)
      *(line + x) = overPix(color, workRas->pixels(y)[x]);
  }

  FillParameters paramsApp = params;
  TPixel32 refColor;
  for (y = 0; y < workRas->getLy(); y++) {
    paramsApp.m_p = TPoint(0, y);
    if (y == 0 ||
        refColor != workRas->pixels(paramsApp.m_p.y)[paramsApp.m_p.x]) {
      fill(workRas, copy, paramsApp);
      refColor = workRas->pixels(paramsApp.m_p.y)[paramsApp.m_p.x];
    }
  }
  for (y = 0; y < workRas->getLy(); y++) {
    paramsApp.m_p = TPoint(workRas->getLx() - 1, y);
    if (y == 0 ||
        refColor != workRas->pixels(paramsApp.m_p.y)[paramsApp.m_p.x]) {
      fill(workRas, copy, paramsApp);
      refColor = workRas->pixels(paramsApp.m_p.y)[paramsApp.m_p.x];
    }
  }

  for (x = 0; x < workRas->getLx(); x++) {
    paramsApp.m_p = TPoint(x, 0);
    if (x == 0 ||
        refColor != workRas->pixels(paramsApp.m_p.y)[paramsApp.m_p.x]) {
      fill(workRas, copy, paramsApp);
      refColor = workRas->pixels(paramsApp.m_p.y)[paramsApp.m_p.x];
    }
  }
  for (x = 0; x < workRas->getLx(); x++) {
    paramsApp.m_p = TPoint(x, workRas->getLy() - 1);
    if (x == 0 ||
        refColor != workRas->pixels(paramsApp.m_p.y)[paramsApp.m_p.x]) {
      fill(workRas, copy, paramsApp);
      refColor = workRas->pixels(paramsApp.m_p.y)[paramsApp.m_p.x];
    }
  }
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:56,代码来源:fillutil.cpp

示例3: pickStyleId

/*-- (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

示例4:

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

示例5: 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

示例6: 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

示例7: 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

示例8:

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

示例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: load

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

示例12: 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

示例13:

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

示例14: copyAndSwapRBChannels

TRaster32P TRop::copyAndSwapRBChannels(const TRaster32P &srcRaster) {
  TRaster32P newRaster(srcRaster->getSize());
  int lx = srcRaster->getLx();
  int y  = srcRaster->getLy();
  srcRaster->lock();
  newRaster->lock();
  while (--y >= 0) {
    TPixel32 *pix    = srcRaster->pixels(y);
    TPixel32 *newpix = newRaster->pixels(y);
    TPixel32 *endPix = pix + lx;
    while (pix < endPix) {
      newpix->r = pix->b;
      newpix->g = pix->g;
      newpix->b = pix->r;
      newpix->m = pix->m;
      ++pix;
      ++newpix;
    }
  }
  srcRaster->unlock();
  newRaster->unlock();

  return newRaster;
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:24,代码来源:trop.cpp

示例15: addSamples

// Calculates the estimate of blend selection in the neighbourhood specified by
// blurPattern.
inline void addSamples(const TRasterCM32P &cmIn, const TPoint &pos,
                       const TRaster32P &inkRas, const TRaster32P &paintRas,
                       const SelectionRaster &selRas,
                       const BlurPattern &blurPattern, DoubleRGBMPixel &pixSum,
                       double &factorsSum) {
  double inkFactor, paintFactor;
  unsigned int xy, j, l;
  int lx = cmIn->getLx(), ly = cmIn->getLy();
  TPixel32 *color;
  TPoint samplePos, pathPos;

  const TPoint *samplePoint =
      blurPattern.m_samples.empty() ? 0 : &blurPattern.m_samples[0];
  const TPoint *pathPoint;

  unsigned int i, blurSamplesCount = blurPattern.m_samples.size();
  for (i = 0; i < blurSamplesCount; ++i, ++samplePoint) {
    // Add each samples contribute to the sum
    samplePos.x = pos.x + samplePoint->x;
    samplePos.y = pos.y + samplePoint->y;
    if (samplePos.x < 0 || samplePos.y < 0 || samplePos.x >= lx ||
        samplePos.y >= ly)
      continue;

    // Ensure that each pixel on the sample's path (if any) is selected
    l         = blurPattern.m_samplePaths[i].size();
    pathPoint = blurPattern.m_samplePaths[i].empty()
                    ? 0
                    : &blurPattern.m_samplePaths[i][0];
    for (j = 0; j < l; ++j, ++pathPoint) {
      pathPos.x = pos.x + pathPoint->x;
      pathPos.y = pos.y + pathPoint->y;
      xy        = pathPos.x + lx * pathPos.y;

      if (!(selRas.isPurePaint(xy) || selRas.isSelectedInk(xy))) break;

      if (!(selRas.isPureInk(xy) || selRas.isSelectedPaint(xy))) break;
    }

    if (j < l) continue;

    xy = samplePos.x + lx * samplePos.y;

    if (selRas.isSelectedInk(xy) && !selRas.isPurePaint(xy)) {
      getFactors(cmIn->pixels(samplePos.y)[samplePos.x].getTone(), inkFactor,
                 paintFactor);

      color = &inkRas->pixels(samplePos.y)[samplePos.x];
      pixSum.r += inkFactor * color->r;
      pixSum.g += inkFactor * color->g;
      pixSum.b += inkFactor * color->b;
      pixSum.m += inkFactor * color->m;
      factorsSum += inkFactor;
    }

    if (selRas.isSelectedPaint(xy) && !selRas.isPureInk(xy)) {
      getFactors(cmIn->pixels(samplePos.y)[samplePos.x].getTone(), inkFactor,
                 paintFactor);

      color = &paintRas->pixels(samplePos.y)[samplePos.x];
      pixSum.r += paintFactor * color->r;
      pixSum.g += paintFactor * color->g;
      pixSum.b += paintFactor * color->b;
      pixSum.m += paintFactor * color->m;
      factorsSum += paintFactor;
    }
  }
}
开发者ID:luc--,项目名称:opentoonz,代码行数:70,代码来源:blend.cpp


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