コード例 #1
0
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;
}
コード例 #2
0
ファイル: tover.cpp プロジェクト: CroW-CZ/opentoonz
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);
		}
	}
}
コード例 #3
0
ファイル: tover.cpp プロジェクト: CroW-CZ/opentoonz
//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;
		}
	}
}
コード例 #4
0
ファイル: trop.cpp プロジェクト: Makoto-Sasahara/opentoonz
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;
}