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


C++ TRasterP::getLy方法代码示例

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


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

示例1: processColors

//this one incorporate the preprocessColors and the finalize function; used for swatch.(tipically on very small rasters)
TRasterP TCleanupper::processColors(const TRasterP &rin)
{
	if (m_parameters->m_lineProcessingMode == lpNone)
		return rin;

	TRasterCM32P rcm = TRasterCM32P(rin->getSize());
	if (!rcm) {
		assert(!"failed finalRas allocation!");
		return TRasterCM32P();
	}

	// Copy current cleanup palette to parameters' colors
	m_parameters->m_colors.update(m_parameters->m_cleanupPalette.getPointer(), m_parameters->m_noAntialias);

	bool toGr8 = (m_parameters->m_lineProcessingMode == lpGrey);
	if (toGr8) {
		//No (color) processing. Not even thresholding. This just means that all the important
		//stuff here is made in the brightness/contrast stage...

		//NOTE: Most of the color processing should be DISABLED in this case!!

		//finalRas->clear();
		rin->lock();
		rcm->lock();

		if (TRasterGR8P(rin)) {
			UCHAR *rowin = rin->getRawData();
			TUINT32 *rowout = reinterpret_cast<TUINT32 *>(rcm->getRawData());
			for (int i = 0; i < rin->getLy(); i++) {
				for (int j = 0; j < rin->getLx(); j++)
					*rowout++ = *rowin++; //Direct copy for now... :(
				rowin += rin->getWrap() - rin->getLx();
				rowout += rcm->getWrap() - rcm->getLx();
			}
		} else {
			TPixel32 *rowin = reinterpret_cast<TPixel32 *>(rin->getRawData());
			TUINT32 *rowout = reinterpret_cast<TUINT32 *>(rcm->getRawData());
			for (int i = 0; i < rin->getLy(); i++) {
				for (int j = 0; j < rin->getLx(); j++)
					*rowout++ = TPixelGR8::from(*rowin++).value;
				rowin += rin->getWrap() - rin->getLx();
				rowout += rcm->getWrap() - rcm->getLx();
			}
		}

		rin->unlock();
		rcm->unlock();
	} else {
		assert(TRaster32P(rin));
		preprocessColors(rcm, rin, m_parameters->m_colors);
	}

	//outImg->setDpi(outDpi.x, outDpi.y);
	CleanupPreprocessedImage cpi(m_parameters, TToonzImageP(rcm, rcm->getBounds()), toGr8);
	cpi.m_autocentered = true;

	TRaster32P rout = TRaster32P(rin->getSize());
	finalize(rout, &cpi);
	return rout;
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:61,代码来源:tcleanupper.cpp

示例2: tglBuildMipmaps

void tglBuildMipmaps(std::vector<TRaster32P> &rasters,
					 const TFilePath &filepath)
{
	assert(rasters.size() > 0);
	TRop::ResampleFilterType resampleFilter = TRop::ClosestPixel;
	TRasterP ras;
	TImageReader::load(filepath, ras);
	int rasLx = ras->getLx();
	int rasLy = ras->getLy();

	int lx = 1;
	while (lx < rasLx)
		lx <<= 1;

	int ly = 1;
	while (ly < rasLy)
		ly <<= 1;

	TRaster32P ras2(lx, ly);
	double sx = (double)lx / (double)ras->getLx();
	double sy = (double)ly / (double)ras->getLy();
#ifndef SCALE_BY_GLU
	TRop::resample(ras2, ras, TScale(sx, sy), resampleFilter);
#else
	ras->lock();
	gluScaleImage(GL_RGBA, ras->getLx(), ras->getLy(), GL_UNSIGNED_BYTE, ras->getRawData(),
				  lx, ly, GL_UNSIGNED_BYTE, ras2->getRawData());
	ras->unlock();
#endif

	rasters[0] = ras2;
	int ras2Lx = ras2->getLx();
	int ras2Ly = ras2->getLy();
	for (int i = 1; i < (int)rasters.size(); ++i) {
		lx >>= 1;
		ly >>= 1;
		if (lx < 1)
			lx = 1;
		if (ly < 1)
			ly = 1;
		rasters[i] = TRaster32P(lx, ly);
		sx = (double)lx / (double)ras2Lx;
		sy = (double)ly / (double)ras2Ly;
		rasters[i] = TRaster32P(lx, ly);
#ifndef SCALE_BY_GLU
		TRop::resample(rasters[i], ras2, TScale(sx, sy), resampleFilter);
#else
		ras2->lock();
		gluScaleImage(GL_RGBA, ras->getLx(), ras->getLy(), GL_UNSIGNED_BYTE, ras2->getRawData(),
					  lx, ly, GL_UNSIGNED_BYTE, rasters[i]->getRawData());
		ras2->unlock();
#endif
	}
}
开发者ID:guozanhua,项目名称:opentoonz,代码行数:54,代码来源:tgl.cpp

示例3: addGlobalNumbering

void TRasterImageUtils::addGlobalNumbering(const TRasterImageP &ri, const std::wstring &sceneName, int globalIndex)
{
	if (!ri)
		return;
	TRasterP raster = ri->getRaster();
	int lx = raster->getLx(), ly = raster->getLy();
	QColor greyOverlay(100, 100, 100, 140);
	QImage image = rasterToQImage(raster, true, false);
	QPainter p(&image);
	QFont numberingFont = QFont();
	numberingFont.setPixelSize(ly * 0.04);
	numberingFont.setBold(true);
	p.setFont(numberingFont);
	QMatrix matrix;
	p.setMatrix(matrix.translate(0, ly).scale(1, -1), true);
	QFontMetrics fm = p.fontMetrics();
	int fontHeight = fm.height();
	int offset = fontHeight * 0.2;
	QString globalFrame = QString::number(globalIndex);
	while (globalFrame.size() < 4)
		globalFrame.push_front("0");
	QString globalNumberingString = QString::fromStdWString(sceneName) + ": " + globalFrame;

	int globalNumberingWidth = fm.width(globalNumberingString);
	p.setPen(Qt::NoPen);
	p.setBrush(QColor(255, 255, 255, 255));
	p.drawRect(offset, ly - offset - fontHeight, globalNumberingWidth + offset * 2, fontHeight);
	p.setBrush(greyOverlay);
	p.drawRect(offset, ly - offset - fontHeight, globalNumberingWidth + offset * 2, fontHeight);
	p.setPen(Qt::white);
	p.drawText(2 * offset, ly - 2 * offset, globalNumberingString);
	p.end();
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:33,代码来源:trasterimageutils.cpp

示例4: shrink

TRasterP TRop::shrink(TRasterP rin, int shrink) {
  int pixelSize = rin->getPixelSize();

  int lx = (rin->getLx() - 1) / shrink + 1;
  int ly = (rin->getLy() - 1) / shrink + 1;

  TRasterP rout;

  if ((TRaster32P)rin)
    rout = TRaster32P(lx, ly);
  else if ((TRaster64P)rin)
    rout                      = TRaster64P(lx, ly);
  if ((TRasterCM32P)rin) rout = TRasterCM32P(lx, ly);
  if ((TRasterGR8P)rin) rout  = TRasterGR8P(lx, ly);

  int i, j;

  for (i = 0; i < ly; i++) {
    UCHAR *bufin =
        (UCHAR *)rin->getRawData() + (i * shrink) * rin->getWrap() * pixelSize;
    UCHAR *bufout =
        (UCHAR *)rout->getRawData() + i * rout->getWrap() * pixelSize;
    for (j = 0; j < lx; j++) {
      memcpy(bufout, bufin, pixelSize);
      bufin += shrink * pixelSize;
      bufout += pixelSize;
    }
  }
  return rout;
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:30,代码来源:trop.cpp

示例5: load

void TLevelReaderMov::load(const TRasterP &ras, int frameIndex,
                           const TPoint &pos, int shrinkX, int shrinkY) {
  QLocalSocket socket;
  tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
                             t32bitsrv::srvCmdline());

  tipc::Stream stream(&socket);
  tipc::Message msg;

  unsigned int size = ras->getLx() * ras->getLy() * ras->getPixelSize();

  // Send the appropriate command to the 32-bit server
  stream << (msg << QString("$LRMovImageRead") << m_id << ras->getLx()
                 << ras->getLy() << ras->getPixelSize() << frameIndex << pos.x
                 << pos.y << shrinkX << shrinkY);

  t32bitsrv::RasterExchanger<TPixel32> exch(ras);
  if (!tipc::readShMemBuffer(stream, msg << tipc::clr, &exch))
    throw TException("Couldn't load image");
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:20,代码来源:tiio_mov_proxy.cpp

示例6:

void Convert2Tlv::buildInksFromGrayTones(TRasterCM32P &rout, const TRasterP &rin)
{
	int i, j;

	TRasterGR8P r8 = (TRasterGR8P)rin;
	TRaster32P r32 = (TRaster32P)rin;
	if (r8)
		for (i = 0; i < rin->getLy(); i++) {
			TPixelGR8 *pixin = r8->pixels(i);
			TPixelCM32 *pixout = rout->pixels(i);
			for (j = 0; j < rin->getLx(); j++, pixin++, pixout++)
				*pixout = TPixelCM32(1, 0, pixin->value);
		}
	else
		for (i = 0; i < rin->getLy(); i++) {
			TPixel *pixin = r32->pixels(i);
			TPixelCM32 *pixout = rout->pixels(i);
			for (j = 0; j < rin->getLx(); j++, pixin++, pixout++)
				*pixout = TPixelCM32(1, 0, TPixelGR8::from(*pixin).value);
		}
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:21,代码来源:convert2tlv.cpp

示例7: rasterToQImage

QImage rasterToQImage(const TRasterP &ras, bool premultiplied, bool mirrored) {
  if (TRaster32P ras32 = ras) {
    QImage image(ras->getRawData(), ras->getLx(), ras->getLy(),
                 premultiplied ? QImage::Format_ARGB32_Premultiplied
                               : QImage::Format_ARGB32);
    if (mirrored) return image.mirrored();
    return image;
  } else if (TRasterGR8P ras8 = ras) {
    QImage image(ras->getRawData(), ras->getLx(), ras->getLy(), ras->getWrap(),
                 QImage::Format_Indexed8);
    static QVector<QRgb> colorTable;
    if (colorTable.size() == 0) {
      int i;
      for (i = 0; i < 256; i++) colorTable.append(QColor(i, i, i).rgb());
    }
    image.setColorTable(colorTable);
    if (mirrored) return image.mirrored();
    return image;
  }
  return QImage();
}
开发者ID:jcome,项目名称:opentoonz,代码行数:21,代码来源:gutil.cpp

示例8: sizeof

AdjustLevelsUndo::AdjustLevelsUndo(int *in0, int *in1, int *out0, int *out1,
								   int r, int c, TRasterP ras)
	: m_r(r), m_c(c), m_rasSize(ras->getLx() * ras->getLy() * ras->getPixelSize())
{
	memcpy(m_in0, in0, sizeof(m_in0));
	memcpy(m_in1, in1, sizeof(m_in1));
	memcpy(m_out0, out0, sizeof(m_out0));
	memcpy(m_out1, out1, sizeof(m_out1));

	static int counter = 0;
	m_rasId = QString("AdjustLevelsUndo") + QString::number(++counter);

	TImageCache::instance()->add(m_rasId, TRasterImageP(ras));
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:14,代码来源:adjustlevelspopup.cpp

示例9: QString

	TRasterAntialiasUndo(int threshold, int softness, int r, int c, TRasterP ras)
		: m_r(r), m_c(c), m_rasId(), m_threshold(threshold), m_softness(softness), m_rasSize(ras->getLx() * ras->getLy() * ras->getPixelSize())
	{
		m_rasId = QString("AntialiasUndo_") + QString::number(uintptr_t(this));
		TImageCache::instance()->add(m_rasId, TRasterImageP(ras));
	}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:6,代码来源:antialiaspopup.cpp

示例10: do_render

/*- render_particles から呼ばれる。粒子の数だけ繰り返し -*/
void Particles_Engine::do_render(
    TFlash *flash, Particle *part, TTile *tile,
    std::vector<TRasterFxPort *> part_ports, std::map<int, TTile *> porttiles,
    const TRenderSettings &ri, TDimension &p_size, TPointD &p_offset,
    int lastframe, std::vector<TLevelP> partLevel,
    struct particles_values &values, double opacity_range, int dist_frame,
    std::map<std::pair<int, int>, double> &partScales) {
  // Retrieve the particle frame - that is, the *column frame* from which we are
  // picking
  // the particle to be rendered.
  int ndx = part->frame % lastframe;

  TRasterP tileRas(tile->getRaster());

  std::string levelid;
  double aim_angle = 0;
  if (values.pathaim_val) {
    double arctan = atan2(part->vy, part->vx);
    aim_angle     = arctan * M_180_PI;
  }

  // Calculate the rotational and scale components we have to apply on the
  // particle
  TRotation rotM(part->angle + aim_angle);
  TScale scaleM(part->scale);
  TAffine M(rotM * scaleM);

  // Particles deal with dpi affines on their own
  TAffine scaleAff(m_parent->handledAffine(ri, m_frame));
  double partScale =
      scaleAff.a11 * partScales[std::pair<int, int>(part->level, ndx)];
  TDimensionD partResolution(0, 0);
  TRenderSettings riNew(ri);

  // Retrieve the bounding box in the standard reference
  TRectD bbox(-5.0, -5.0, 5.0, 5.0), standardRefBBox;
  if (part->level <
          (int)part_ports.size() &&  // Not the default levelless cases
      part_ports[part->level]->isConnected()) {
    TRenderSettings riIdentity(ri);
    riIdentity.m_affine = TAffine();

    (*part_ports[part->level])->getBBox(ndx, bbox, riIdentity);

    // A particle's bbox MUST be finite. Gradients and such which have an
    // infinite bbox
    // are just NOT rendered.

    // NOTE: No fx returns half-planes or similar (ie if any coordinate is
    // either
    // (std::numeric_limits<double>::max)() or its opposite, then the rect IS
    // THE infiniteRectD)
    if (bbox == TConsts::infiniteRectD) return;
  }

  // Now, these are the particle rendering specifications
  bbox            = bbox.enlarge(3);
  standardRefBBox = bbox;
  riNew.m_affine  = TScale(partScale);
  bbox            = riNew.m_affine * bbox;
  /*- 縮小済みのParticleのサイズ -*/
  partResolution = TDimensionD(tceil(bbox.getLx()), tceil(bbox.getLy()));

  if (flash) {
    if (!partLevel[part->level]->frame(ndx)) {
      if (part_ports[0]->isConnected()) {
        TTile auxTile;
        TRaster32P tmp;
        tmp = TRaster32P(p_size);
        (*part_ports[0])
            ->allocateAndCompute(auxTile, p_offset, p_size, tmp, ndx, ri);
        partLevel[part->level]->setFrame(ndx,
                                         TRasterImageP(auxTile.getRaster()));
      }
    }

    flash->pushMatrix();

    const TAffine aff;

    flash->multMatrix(scaleM * aff.place(0, 0, part->x, part->y));

    // if(curr_opacity!=1.0 || part->gencol.fadecol || part->fincol.fadecol ||
    // part->foutcol.fadecol)
    {
      TColorFader cf(TPixel32::Red, .5);
      flash->draw(partLevel[part->level]->frame(ndx), &cf);
    }
    // flash->draw(partLevel->frame(ndx), 0);

    flash->popMatrix();
  } else {
    TRasterP ras;

    std::string alias;
    TRasterImageP rimg;
    if (rimg = partLevel[part->level]->frame(ndx)) {
      ras = rimg->getRaster();
    } else {
//.........这里部分代码省略.........
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:101,代码来源:particlesengine.cpp

示例11: makeDataRaster

void OutlineVectorizer::makeDataRaster(const TRasterP &src)
{
	m_vimage = new TVectorImage();
	if (!src)
		return;
	m_src = src;

	clearNodes();
	clearJunctions();

	int x, y, ii = 0;
	TRaster32P srcRGBM = (TRaster32P)m_src;
	TRasterCM32P srcCM = (TRasterCM32P)m_src;
	TRasterGR8P srcGR = (TRasterGR8P)m_src;

	// Inizializzo DataRasterP per i casi in cui si ha un TRaster32P, un TRasterGR8P o un TRasterCM32P molto grande
	DataRasterP dataRaster(m_src->getSize().lx + 2, m_src->getSize().ly + 2);
	if (srcRGBM || srcGR || (srcCM && srcCM->getLx() * srcCM->getLy() > 5000000)) {
		int ly = dataRaster->getLy();
		int lx = dataRaster->getLx();
		int wrap = dataRaster->getWrap();
		DataPixel *dataPix0 = dataRaster->pixels(0);
		DataPixel *dataPix1 = dataRaster->pixels(0) + m_src->getLx() + 1;
		for (y = 0; y < ly; y++, dataPix0 += wrap, dataPix1 += wrap) {
			dataPix0->m_pos.x = 0;
			dataPix1->m_pos.x = lx - 1;
			dataPix0->m_pos.y = dataPix1->m_pos.y = y;
			dataPix0->m_value = dataPix1->m_value = 0;
			dataPix0->m_ink = dataPix1->m_ink = false;
			dataPix0->m_node = dataPix1->m_node = 0;
		}
		dataPix0 = dataRaster->pixels(0);
		dataPix1 = dataRaster->pixels(ly - 1);
		for (x = 0; x < lx; x++, dataPix0++, dataPix1++) {
			dataPix0->m_pos.x = dataPix1->m_pos.x = x;
			dataPix0->m_pos.y = 0;
			dataPix1->m_pos.y = ly - 1;
			dataPix0->m_value = dataPix1->m_value = 0;
			dataPix0->m_ink = dataPix1->m_ink = false;
			dataPix0->m_node = dataPix1->m_node = 0;
		}
	}

	if (srcRGBM) {
		assert(m_palette);
		int inkId = m_palette->getClosestStyle(m_configuration.m_inkColor);
		if (!inkId || m_configuration.m_inkColor != m_palette->getStyle(inkId)->getMainColor()) {
			inkId = m_palette->getStyleCount();
			m_palette->getStylePage(1)->insertStyle(1, m_configuration.m_inkColor);
			m_palette->setStyle(inkId, m_configuration.m_inkColor);
		}
		assert(inkId);

		m_dataRasterArray.push_back(std::pair<int, DataRasterP>(inkId, dataRaster));
		int maxDistance2 = m_configuration.m_threshold * m_configuration.m_threshold;

		for (y = 0; y < m_src->getLy(); y++) {
			TPixel32 *inPix = srcRGBM->pixels(y);
			TPixel32 *inEndPix = inPix + srcRGBM->getLx();
			DataPixel *dataPix = dataRaster->pixels(y + 1) + 1;
			x = 0;
			while (inPix < inEndPix) {
				*dataPix = DataPixel();
				int distance2 = colorDistance2(m_configuration.m_inkColor, *inPix);

				if (y == 0 || y == m_src->getLy() - 1 || x == 0 || x == m_src->getLx() - 1 || inPix->m == 0) {
					dataPix->m_value = 255;
					dataPix->m_ink = false;
				} else {
					dataPix->m_value = (inPix->r + 2 * inPix->g + inPix->b) >> 2;
					dataPix->m_ink = (distance2 < maxDistance2);
				}
				dataPix->m_pos.x = x++;
				dataPix->m_pos.y = y;
				dataPix->m_node = 0;
				inPix++;
				dataPix++;
			}
		}
	} else if (srcGR) {
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:80,代码来源:toutlinevectorizer.cpp

示例12: doCompute

  void doCompute(TTile &tile, double frame,
                 const TRenderSettings &info) override {
    bool isWarped = m_warped.isConnected();

    if (!isWarped) return;

    if (fabs(m_intensity->getValue(frame)) < 0.01) {
      m_warped->compute(tile, frame, info);
      return;
    }

    int shrink      = (info.m_shrinkX + info.m_shrinkY) / 2;
    double scale    = sqrt(fabs(info.m_affine.det()));
    double gridStep = 1.5 * m_gridStep->getValue(frame);

    WarpParams params;
    params.m_intensity   = m_intensity->getValue(frame) / gridStep;
    params.m_warperScale = scale * gridStep;
    params.m_sharpen     = m_sharpen->getValue();
    params.m_shrink      = shrink;
    double period        = m_period->getValue(frame) / info.m_shrinkX;
    double count         = m_count->getValue(frame);
    double cycle         = m_cycle->getValue(frame) / info.m_shrinkX;
    double scaleX        = m_scaleX->getValue(frame) / 100.0;
    double scaleY        = m_scaleY->getValue(frame) / 100.0;
    double angle         = -m_angle->getValue(frame);
    TPointD center       = m_center->getValue(frame) * (1.0 / info.m_shrinkX);

    // The warper is calculated on a standard reference, with fixed dpi. This
    // makes sure
    // that the lattice created for the warp does not depend on camera
    // transforms and resolution.
    TRenderSettings warperInfo(info);
    double warperScaleFactor = 1.0 / params.m_warperScale;
    warperInfo.m_affine      = TScale(warperScaleFactor) * info.m_affine;

    // Retrieve tile's geometry
    TRectD tileRect;
    {
      TRasterP tileRas = tile.getRaster();
      tileRect =
          TRectD(tile.m_pos, TDimensionD(tileRas->getLx(), tileRas->getLy()));
    }

    // Build the compute rect
    TRectD warpedBox, warpedComputeRect, tileComputeRect;
    m_warped->getBBox(frame, warpedBox, info);

    getWarpComputeRects(tileComputeRect, warpedComputeRect, warpedBox, tileRect,
                        params);

    if (tileComputeRect.getLx() <= 0 || tileComputeRect.getLy() <= 0) return;
    if (warpedComputeRect.getLx() <= 0 || warpedComputeRect.getLy() <= 0)
      return;

    TRectD warperComputeRect(TScale(warperScaleFactor) * tileComputeRect);
    double warperEnlargement = getWarperEnlargement(params);
    warperComputeRect        = warperComputeRect.enlarge(warperEnlargement);
    warperComputeRect.x0     = tfloor(warperComputeRect.x0);
    warperComputeRect.y0     = tfloor(warperComputeRect.y0);
    warperComputeRect.x1     = tceil(warperComputeRect.x1);
    warperComputeRect.y1     = tceil(warperComputeRect.y1);

    // Compute the warped tile
    TTile tileIn;
    m_warped->allocateAndCompute(
        tileIn, warpedComputeRect.getP00(),
        TDimension(warpedComputeRect.getLx(), warpedComputeRect.getLy()),
        tile.getRaster(), frame, info);
    TRasterP rasIn = tileIn.getRaster();

    // Compute the warper tile
    TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White),
                                    TSpectrum::ColorKey(0.5, TPixel32::Black),
                                    TSpectrum::ColorKey(1, TPixel32::White)};

    TSpectrumParamP ripplecolors = TSpectrumParamP(tArrayCount(colors), colors);

    // Build the multiradial
    warperInfo.m_affine = warperInfo.m_affine * TTranslation(center) *
                          TRotation(angle) * TScale(scaleX, scaleY);
    TAffine aff      = warperInfo.m_affine.inv();
    TPointD posTrasf = aff * (warperComputeRect.getP00());
    TRasterP rasWarper =
        rasIn->create(warperComputeRect.getLx(), warperComputeRect.getLy());
    multiRadial(rasWarper, posTrasf, ripplecolors, period, count, cycle, aff,
                frame);
    // TImageWriter::save(TFilePath("C:\\ripple.tif"), rasWarper);

    // Warp
    TPointD db;
    TRect rasComputeRectI(convert(tileComputeRect - tileRect.getP00(), db));
    TRasterP tileRas = tile.getRaster()->extract(rasComputeRectI);

    TPointD rasInPos(warpedComputeRect.getP00() - tileComputeRect.getP00());
    TPointD warperPos(
        (TScale(params.m_warperScale) * warperComputeRect.getP00()) -
        tileComputeRect.getP00());
    warp(tileRas, rasIn, rasWarper, rasInPos, warperPos, params);
  }
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:100,代码来源:ripplefx.cpp

示例13: save

void TImageWriter::save(const TImageP &img)
{
	const std::string &type = toLower(m_path.getType());

	Tiio::Writer *writer = Tiio::makeWriter(type);
	if (!writer)
		throw TImageException(m_path, "unsupported format for raster images");

	writer->setProperties(m_properties);

	FILE *file = fopen(m_path, "wb");
	if (file == NULL)
		throw TImageException(m_path, "Can't write file");

	if (TRasterImageP ri = img) {
		TImageInfo info;
		TRasterP ras;

		TRasterGR8P rasGr = ri->getRaster();
		TRaster32P ras32 = ri->getRaster();
		TRaster64P ras64 = ri->getRaster();

		TEnumProperty *p = m_properties ? (TEnumProperty *)m_properties->getProperty("Bits Per Pixel")
										: 0;

		if (p && ri->isScanBW()) {
			const std::vector<std::wstring> &range = p->getRange();
			p->setValue(range[2]); // Horrible. See tiio_tif.cpp (732 or near)     -.-'
		}

		int bpp = p ? atoi((toString(p->getValue()).c_str())) : 32;

		//  bpp       1  8  16 24 32 40  48 56  64
		int spp[] = {1, 1, 1, 4, 4, 0, 4, 0, 4};	// 0s are for pixel sizes which are normally unsupported
		int bps[] = {1, 8, 16, 8, 8, 0, 16, 0, 16}; // by image formats, let alone by Toonz raster ones.
													// The 24 and 48 cases get automatically promoted to 32 and 64.
		int bypp = bpp / 8;
		assert(bypp < boost::size(spp) && spp[bypp] && bps[bypp]);

		info.m_samplePerPixel = spp[bypp];
		info.m_bitsPerSample = bps[bypp];

		if (rasGr) {
			if (bypp < 2)	// Seems 16 bit greymaps are not handled... why?
				ras = rasGr; // we do have a Toonz raster for those...    >:|
			else
				convertForWriting(ras, rasGr, bpp);
		} else if (ras32) {
			if (bpp == 32 || bpp == 24)
				ras = ras32;
			else
				convertForWriting(ras, ras32, bpp);
		} else if (ras64) {
			if (bpp == 64 || bpp == 48)
				ras = ras64;
			else
				convertForWriting(ras, ras64, bpp);
		} else {
			fclose(file);
			throw TImageException(m_path, "unsupported raster type");
		}

		info.m_lx = ras->getLx();
		info.m_ly = ras->getLy();

		ri->getDpi(info.m_dpix, info.m_dpiy);

		if (writer->getProperties() && m_properties)
			writer->getProperties()->setProperties(m_properties);

		writer->open(file, info);

		ras->lock();
		if (writer->getRowOrder() == Tiio::BOTTOM2TOP) {
			if (bpp == 1 || bpp == 8 || bpp == 24 || bpp == 32 || bpp == 16)
				for (int i = 0; i < ras->getLy(); i++)
					writer->writeLine((char *)ras->getRawData(0, i));
			else
				for (int i = 0; i < ras->getLy(); i++)
					writer->writeLine((short *)ras->getRawData(0, i));
		} else {
			if (bpp == 1 || bpp == 8 || bpp == 24 || bpp == 32 || bpp == 16)
				for (int i = ras->getLy() - 1; i >= 0; i--)
					writer->writeLine((char *)ras->getRawData(0, i));
			else
				for (int i = ras->getLy() - 1; i >= 0; i--)
					writer->writeLine((short *)ras->getRawData(0, i));
		}

		ras->unlock();

		writer->flush();
		delete writer;
	} else if (TVectorImageP vi = img) {
		Tiio::VectorWriter *writer = Tiio::makeVectorWriter(type);
		if (!writer) {
			fclose(file);
			throw TImageException(m_path, "unsupported format for vector images");
		}

//.........这里部分代码省略.........
开发者ID:PsmithG,项目名称:opentoonz,代码行数:101,代码来源:timage_io.cpp

示例14: QString

	TRasterBrightnessUndo(int brightness, int contrast, int r, int c, TRasterP ras)
		: m_r(r), m_c(c), m_rasId(), m_brightness(brightness), m_contrast(contrast), m_rasSize(ras->getLx() * ras->getLy() * ras->getPixelSize())
	{
		m_rasId = QString("BrightnessUndo") + QString::number((uintptr_t) this);
		TImageCache::instance()->add(m_rasId, TRasterImageP(ras));
	}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:6,代码来源:brightnessandcontrastpopup.cpp

示例15: add

QString ImageBuilder::add(const TImageP &img, const TAffine &aff) {
  if (fabs(aff.det()) < 0.001) return "";
  if (m_img && (m_img->getType() != img->getType()))
    return "Image type mismatch";

  if (!m_img && img->getType() != TImage::VECTOR && m_width > 0 &&
      m_height > 0) {
    TRasterP ras = img->raster()->create(m_width, m_height);
    if (img->getType() == TImage::RASTER)
      m_img = TRasterImageP(ras);
    else if (img->getType() == TImage::TOONZ_RASTER) {
      m_img = TToonzImageP(ras, ras->getBounds());
      m_img->setPalette(img->getPalette());
    } else
      return "Bad image type";
  }

  if (!m_img && aff.isIdentity()) {
    m_img = img->cloneImage();
  } else if (img->getType() == TImage::VECTOR) {
    // vector image
    if (!m_img) {
      // transform
      TVectorImageP vi = img->cloneImage();
      vi->transform(aff);
      m_img = vi;
    } else {
      // merge
      TVectorImageP up = img;
      TVectorImageP dn = m_img;
      dn->mergeImage(up, aff);
    }
  } else {
    if (img->getType() != TImage::TOONZ_RASTER &&
        img->getType() != TImage::RASTER) {
      // this should not ever happen
      return "Bad image type";
    }
    TRasterP up = img->raster();
    if (!m_img) {
      // create an empty bg
      TRasterP ras = up->create();
      ras->clear();
      if (img->getType() == TImage::TOONZ_RASTER) {
        TRasterCM32P rasCm = ras;
        m_img              = TToonzImageP(rasCm,
                             TRect(0, 0, ras->getLx() - 1, ras->getLy() - 1));
        m_img->setPalette(img->getPalette());
      } else {
        m_img = TRasterImageP(ras);
      }
    }
    TRasterP dn = m_img->raster();
    if (aff.isTranslation() && aff.a13 == floor(aff.a13) &&
        aff.a23 == floor(aff.a23)) {
      // just a integer coord translation
      TPoint delta = -up->getCenter() + dn->getCenter() +
                     TPoint((int)aff.a13, (int)aff.a23);
      TRop::over(dn, up, delta);
    } else {
      TAffine aff1 = TTranslation(dn->getCenterD()) * aff *
                     TTranslation(-up->getCenterD());
      TRop::over(dn, up, aff1, TRop::Mitchell);
    }
  }
  return "";
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:67,代码来源:scriptbinding_image_builder.cpp


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