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


C++ TRasterImageP类代码示例

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


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

示例1: build_gr_cum

void build_gr_cum(const TRasterImageP &image, int cum[256])
{
	int lx, ly, wrap, true_lx, true_ly;
	int i, x, y;
	UCHAR *pix, *buffer;
	int histo[256], raster_is_savebox;

	get_virtual_buffer(image, &lx, &ly, &wrap, &buffer);

	for (i = 0; i < 256; i++)
		histo[i] = 0;
	for (y = 0; y < ly; y++) {
		pix = buffer + y * wrap;
		for (x = 0; x < lx; x++)
			histo[*pix++]++;
	}

	raster_is_savebox = 1;
	TRect saveBox = image->getSavebox();
	if ((saveBox.getLx() > 0 && saveBox.getLx() < image->getRaster()->getLx()) ||
		(saveBox.getLy() > 0 && saveBox.getLy() < image->getRaster()->getLy()))
		raster_is_savebox = 0;

	if (raster_is_savebox) {
		true_lx = saveBox.getLx() ? saveBox.getLx() : image->getRaster()->getLx();
		true_ly = saveBox.getLy() ? saveBox.getLy() : image->getRaster()->getLy();
	} else {
		true_lx = image->getRaster()->getLx();
		true_ly = image->getRaster()->getLy();
	}
	histo[255] += true_lx * true_ly - lx * ly;

	build_cum(histo, cum);
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:34,代码来源:autoadjust.cpp

示例2: delta_

/*! Add to current trasformation matrix a \b delta traslation.
*/
void ImageViewer::panQt(const QPoint &delta) {
  if (delta == QPoint()) return;

  // stop panning when the image is at the edge of window
  QPoint delta_(delta.x(), delta.y());

  TToonzImageP timg  = (TToonzImageP)m_image;
  TRasterImageP rimg = (TRasterImageP)m_image;
  if (timg || rimg) {
    bool isXPlus = delta.x() > 0;
    bool isYPlus = delta.y() > 0;

    TDimension imgSize((timg) ? timg->getSize() : rimg->getRaster()->getSize());
    int subSampling = (timg) ? timg->getSubsampling() : rimg->getSubsampling();

    TPointD cornerPos = TPointD(imgSize.lx * ((isXPlus) ? -1 : 1),
                                imgSize.ly * ((isYPlus) ? 1 : -1)) *
                        (0.5 / (double)subSampling);
    cornerPos = m_viewAff * cornerPos;

    if ((cornerPos.x > 0) == isXPlus) delta_.setX(0);
    if ((cornerPos.y < 0) == isYPlus) delta_.setY(0);
  }

  setViewAff(TTranslation(delta_.x(), -delta_.y()) * m_viewAff);

  update();
}
开发者ID:janisozaur,项目名称:opentoonz,代码行数:30,代码来源:imageviewer.cpp

示例3: pickColor

TPixel32 StylePicker::pickColor(const TPointD &pos, double radius2) const
{
	TToonzImageP ti = m_image;
	TRasterImageP ri = m_image;
	if (!!ri) // !!ti || !!ri)
	{
		TRasterP raster;
		//if(ti)
		//  raster = ti->getRGBM(true);
		//else
		raster = ri->getRaster();

		TPoint point = getRasterPoint(pos);
		if (!raster->getBounds().contains(point))
			return TPixel32::Transparent;

		TRaster32P raster32 = raster;
		if (raster32)
			return raster32->pixels(point.y)[point.x];

		TRasterGR8P rasterGR8 = raster;
		if (rasterGR8)
			return toPixel32(rasterGR8->pixels(point.y)[point.x]);
	} else if (TVectorImageP vi = m_image) {
		const TPalette *palette = m_palette.getPointer();
		if (!palette)
			return TPixel32::Transparent;
		int styleId = pickStyleId(pos, radius2);
		if (0 <= styleId && styleId < palette->getStyleCount())
			return palette->getStyle(styleId)->getAverageColor();
	}
	return TPixel32::Transparent;
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:33,代码来源:stylepicker.cpp

示例4: TImageP

void FullColorBrushTool::updateWorkAndBackupRasters(const TRect &rect)
{
	TRasterImageP ri = TImageP(getImage(false, 1));
	if (!ri)
		return;

	TRasterP ras = ri->getRaster();

	TRect _rect = rect * ras->getBounds();
	TRect _lastRect = m_lastRect * ras->getBounds();

	if (_rect.isEmpty())
		return;

	if (m_lastRect.isEmpty()) {
		m_workRaster->extract(_rect)->clear();
		m_backUpRas->extract(_rect)->copy(ras->extract(_rect));
		return;
	}

	QList<TRect> rects = ToolUtils::splitRect(_rect, _lastRect);
	for (int i = 0; i < rects.size(); i++) {
		m_workRaster->extract(rects[i])->clear();
		m_backUpRas->extract(rects[i])->copy(ras->extract(rects[i]));
	}
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:26,代码来源:fullcolorbrushtool.cpp

示例5: draw

void PlaneViewer::draw(TRasterImageP ri) {
  double dpiX, dpiY;
  ri->getDpi(dpiX, dpiY);

  if (dpiX == 0.0 || dpiY == 0.0) dpiX = dpiY = Stage::inch;

  draw(ri->getRaster(), dpiX, dpiY);
}
开发者ID:walkerka,项目名称:opentoonz,代码行数:8,代码来源:planeviewer.cpp

示例6: glDisable

void ImagePainter::paintImage(const TImageP &image, const TDimension &imageSize,
                              const TDimension &viewerSize, const TAffine &aff,
                              const VisualSettings &visualSettings,
                              const CompareSettings &compareSettings,
                              const TRect &loadbox) {
  glDisable(GL_DEPTH_TEST);

  if (visualSettings.m_drawExternalBG) {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);
  }

  GLenum error = glGetError();
  // assert(error==GL_NO_ERROR);
  if (error != GL_NO_ERROR) {
    printf("ImagePainter::paintImage() gl_error:%d\n", error);
  }

  if (!image) return;

  TRasterImageP rimg = (TRasterImageP)image;
  TVectorImageP vimg = (TVectorImageP)image;
  TToonzImageP timg  = (TToonzImageP)image;

  TRect clipRect(viewerSize);
  clipRect -= TPoint(viewerSize.lx * 0.5, viewerSize.ly * 0.5);
  Painter painter(viewerSize, imageSize, aff, image->getPalette(),
                  visualSettings);

  if (rimg)
    painter.onRasterImage(rimg.getPointer());
  else if (vimg)
    painter.onVectorImage(vimg.getPointer());
  else if (timg)
    painter.onToonzImage(timg.getPointer());

  if (visualSettings.m_blankColor != TPixel::Transparent) {
    painter.drawBlank();
    return;
  }

  // if I have a color filter applied using a glmask, , drawing of images must
  // be done on black bg!
  if (!vimg)
    painter.flushRasterImages(
        loadbox, visualSettings.m_doCompare ? compareSettings.m_compareX
                                            : DefaultCompareValue,
        visualSettings.m_doCompare ? compareSettings.m_compareY
                                   : DefaultCompareValue,
        compareSettings.m_swapCompared);

  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

  if (visualSettings.m_doCompare)
    drawCompareLines(viewerSize, compareSettings.m_compareX,
                     compareSettings.m_compareY);
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:57,代码来源:imagepainter.cpp

示例7: TBinarizeUndo

	// note: create Undo BEFORE binarizing. Undo is keeping a copy of the current raster
	TBinarizeUndo(TXshSimpleLevel *sl, const TFrameId &fid, bool alphaEnabled)
		: m_levelName(sl->getName()), m_fid(fid), m_alphaEnabled(alphaEnabled)
	{
		/* FIXME: clang でコンパイルできなかったのでキャストにしたがこのダウンキャスト本当に大丈夫か? */
		TRasterImageP ri = (TRasterImageP)sl->getFrame(m_fid, false)->cloneImage();
		m_rasId = QString("BinarizeUndo") + QString::number((uintptr_t) this);
		TImageCache::instance()->add(m_rasId, ri);
		m_rasSize = ri->getRaster()->getLx() * ri->getRaster()->getLy() * 4;
	}
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:10,代码来源:binarizepopup.cpp

示例8: leftButtonDrag

void FullColorBrushTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e)
{
	m_brushPos = m_mousePos = pos;

	TRasterImageP ri = (TRasterImageP)getImage(true);
	if (!ri)
		return;

	double maxThickness = m_thickness.getValue().second;
	double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThickness;
	double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01;
	TDimension size = m_workRaster->getSize();
	TPointD rasCenter = TPointD(size.lx * 0.5, size.ly * 0.5);
	TThickPoint point(pos + rasCenter, thickness);

	TThickPoint old = m_points.back();
	if (norm2(point - old) < 4)
		return;

	TThickPoint mid((old + point) * 0.5, (point.thick + old.thick) * 0.5);
	m_points.push_back(mid);
	m_points.push_back(point);

	TRect bbox;
	int m = m_points.size();
	TRectD invalidateRect;
	if (m == 3) {
		// ho appena cominciato. devo disegnare un segmento
		TThickPoint pa = m_points.front();
		vector<TThickPoint> points;
		points.push_back(pa);
		points.push_back(mid);
		invalidateRect = ToolUtils::getBounds(points, maxThickness);
		bbox = m_brush->getBoundFromPoints(points);
		updateWorkAndBackupRasters(bbox + m_lastRect);
		m_tileSaver->save(bbox);
		m_brush->addArc(pa, (pa + mid) * 0.5, mid, m_oldOpacity, opacity);
		m_lastRect += bbox;
	} else {
		// caso generale: disegno un arco
		vector<TThickPoint> points;
		points.push_back(m_points[m - 4]);
		points.push_back(old);
		points.push_back(mid);
		invalidateRect = ToolUtils::getBounds(points, maxThickness);
		bbox = m_brush->getBoundFromPoints(points);
		updateWorkAndBackupRasters(bbox + m_lastRect);
		m_tileSaver->save(bbox);
		m_brush->addArc(m_points[m - 4], old, mid, m_oldOpacity, opacity);
		m_lastRect += bbox;
	}
	m_oldOpacity = opacity;
	m_brush->updateDrawing(ri->getRaster(), m_backUpRas, m_currentColor, bbox, m_opacity.getValue().second * 0.01);
	invalidate(invalidateRect.enlarge(2) - rasCenter);
	m_strokeRect += bbox;
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:56,代码来源:fullcolorbrushtool.cpp

示例9: invalidate

void RasterSelectionTool::leftButtonDrag(const TPointD &pos,
                                         const TMouseEvent &e) {
  if (m_setSaveboxTool && m_modifySavebox.getValue()) {
    m_setSaveboxTool->leftButtonDrag(pos);
    invalidate();
    return;
  }
  if (m_dragTool) {
    m_dragTool->leftButtonDrag(pos, e);
    invalidate();
    return;
  }

  TImageP image    = getImage(true);
  TToonzImageP ti  = (TToonzImageP)image;
  TRasterImageP ri = (TRasterImageP)image;
  if (!ti && !ri) return;

  if (m_selecting) {
    if (m_strokeSelectionType.getValue() == RECT_SELECTION) {
      TDimension imageSize;
      if (ti)
        imageSize = ti->getSize();
      else if (ri)
        imageSize = ri->getRaster()->getSize();
      TPointD p(imageSize.lx % 2 ? 0.5 : 0.0, imageSize.ly % 2 ? 0.5 : 0.0);
      TRectD rectD(tround(std::min(m_firstPos.x, pos.x) - p.x) + p.x,
                   tround(std::min(m_firstPos.y, pos.y) - p.y) + p.y,
                   tround(std::max(m_firstPos.x, pos.x) - p.x) + p.x,
                   tround(std::max(m_firstPos.y, pos.y) - p.y) + p.y);

      m_selectingRect = rectD;
      m_bboxs.clear();
      invalidate();
    } else if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION)
      freehandDrag(pos);
    return;
  }

  double pixelSize        = getPixelSize();
  TTool::Application *app = TTool::getApplication();
  if (!app || m_justSelected || !m_selecting ||
      tdistance2(pos, m_curPos) < 9.0 * pixelSize * pixelSize)
    return;

  m_curPos = pos;

  if (m_strokeSelectionType.getValue() == FREEHAND_SELECTION)
    freehandDrag(pos);
  else if (m_strokeSelectionType.getValue() == RECT_SELECTION) {
    bool selectOverlappingStroke = (m_firstPos.x > pos.x);
    TRectD rect(m_firstPos, pos);
    m_selectingRect = rect;
    invalidate();
  }
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:56,代码来源:rasterselectiontool.cpp

示例10: convertWorldToRaster

TRect TRasterImageUtils::convertWorldToRaster(const TRectD &area, const TRasterImageP ri)
{
	if (area.isEmpty())
		return TRect();
	if (!ri || !ri->getRaster())
		return TRect(tfloor(area.x0), tfloor(area.y0), tfloor(area.x1) - 1, tfloor(area.y1) - 1);
	TRasterP ras = ri->getRaster();
	TRectD rect(area + ras->getCenterD());
	return TRect(tfloor(rect.x0), tfloor(rect.y0), tceil(rect.x1) - 1, tceil(rect.y1) - 1);
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:10,代码来源:trasterimageutils.cpp

示例11: convertRasterToWorld

TRectD TRasterImageUtils::convertRasterToWorld(const TRect &area, const TRasterImageP ri)
{
	if (area.isEmpty())
		return TRectD();

	TRectD rect(area.x0, area.y0, area.x1 + 1, area.y1 + 1);
	if (ri && ri->getRaster())
		rect = rect - ri->getRaster()->getCenterD();
	return rect;
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:10,代码来源:trasterimageutils.cpp

示例12: leftButtonUp

void FullColorBrushTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e)
{
	m_brushPos = m_mousePos = pos;

	TRasterImageP ri = (TRasterImageP)getImage(true);
	if (!ri)
		return;

	if (m_points.size() != 1) {
		double maxThickness = m_thickness.getValue().second;
		double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThickness;
		double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01;
		TPointD rasCenter = ri->getRaster()->getCenterD();
		TThickPoint point(pos + rasCenter, thickness);
		m_points.push_back(point);
		int m = m_points.size();
		vector<TThickPoint> points;
		points.push_back(m_points[m - 3]);
		points.push_back(m_points[m - 2]);
		points.push_back(m_points[m - 1]);
		TRect bbox = m_brush->getBoundFromPoints(points);
		updateWorkAndBackupRasters(bbox);
		m_tileSaver->save(bbox);
		m_brush->addArc(points[0], points[1], points[2], m_oldOpacity, opacity);
		m_brush->updateDrawing(ri->getRaster(), m_backUpRas, m_currentColor, bbox, m_opacity.getValue().second * 0.01);
		TRectD invalidateRect = ToolUtils::getBounds(points, maxThickness);
		invalidate(invalidateRect.enlarge(2) - rasCenter);
		m_strokeRect += bbox;
		m_lastRect.empty();
	}

	if (m_brush) {
		delete m_brush;
		m_brush = 0;
	}

	m_workRaster->unlock();

	if (m_tileSet->getTileCount() > 0) {
		delete m_tileSaver;
		TTool::Application *app = TTool::getApplication();
		TXshLevel *level = app->getCurrentLevel()->getLevel();
		TXshSimpleLevelP simLevel = level->getSimpleLevel();
		TFrameId frameId = getCurrentFid();
		TRasterP ras = ri->getRaster()->extract(m_strokeRect)->clone();
		TUndoManager::manager()->add(new FullColorBrushUndo(m_tileSet, simLevel.getPointer(), frameId,
															m_isFrameCreated, ras, m_strokeRect.getP00()));
	}

	notifyImageChanged();
	m_strokeRect.empty();
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:52,代码来源:fullcolorbrushtool.cpp

示例13: undo

	void undo() const
	{
		TXshSimpleLevel *sl = getLevel();
		if (!sl)
			return;
		TRasterImageP ri = sl->getFrame(m_fid, true);
		if (!ri)
			return;

		TRasterImageP oldRaster = TImageCache::instance()->get(m_rasId, false);
		ri->getRaster()->copy(oldRaster->getRaster());
		notify(sl);
	}
开发者ID:JosefMeixner,项目名称:opentoonz,代码行数:13,代码来源:binarizepopup.cpp

示例14: getViewer

void FullColorBrushTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e)
{
	m_brushPos = m_mousePos = pos;

	Viewer *viewer = getViewer();
	if (!viewer)
		return;

	TRasterImageP ri = (TRasterImageP)getImage(true);
	if (!ri)
		ri = (TRasterImageP)touchImage();

	if (!ri)
		return;

	TRasterP ras = ri->getRaster();
	TDimension dim = ras->getSize();

	if (!(m_workRaster && m_backUpRas))
		setWorkAndBackupImages();

	m_workRaster->lock();

	double maxThick = m_thickness.getValue().second;
	double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThick;
	double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01;
	TPointD rasCenter = TPointD(dim.lx * 0.5, dim.ly * 0.5);
	TThickPoint point(pos + rasCenter, thickness);
	TPointD halfThick(maxThick * 0.5, maxThick * 0.5);
	TRectD invalidateRect(pos - halfThick, pos + halfThick);

	m_points.clear();
	m_points.push_back(point);

	m_tileSet = new TTileSetFullColor(ras->getSize());
	m_tileSaver = new TTileSaverFullColor(ras, m_tileSet);
	double hardness = m_hardness.getValue() * 0.01;

	m_brush = new BluredBrush(m_workRaster, maxThick, m_brushPad, hardness == 1.0);
	m_strokeRect = m_brush->getBoundFromPoints(m_points);
	updateWorkAndBackupRasters(m_strokeRect);
	m_tileSaver->save(m_strokeRect);
	m_brush->addPoint(point, opacity);
	m_brush->updateDrawing(ras, m_backUpRas, m_currentColor, m_strokeRect, m_opacity.getValue().second * 0.01);
	m_oldOpacity = opacity;
	m_lastRect = m_strokeRect;

	invalidate(invalidateRect.enlarge(2));
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:49,代码来源:fullcolorbrushtool.cpp

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


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