コード例 #1
0
ファイル: filmstrip.cpp プロジェクト: jcome/opentoonz
void FilmstripFrames::showEvent(QShowEvent *) {
  TApp *app = TApp::instance();

  // cambiamenti al livello
  TXshLevelHandle *levelHandle = app->getCurrentLevel();
  connect(levelHandle, SIGNAL(xshLevelSwitched(TXshLevel *)), this,
          SLOT(onLevelSwitched(TXshLevel *)));
  connect(levelHandle, SIGNAL(xshLevelChanged()), this, SLOT(onLevelChanged()));
  connect(levelHandle, SIGNAL(xshLevelViewChanged()), this,
          SLOT(onLevelChanged()));

  // al frame corrente
  connect(app->getCurrentFrame(), SIGNAL(frameSwitched()), this,
          SLOT(onFrameSwitched()));
  connect(app->getCurrentFrame(), SIGNAL(frameTypeChanged()), this,
          SLOT(update()));

  // iconcine
  connect(IconGenerator::instance(), SIGNAL(iconGenerated()), this,
          SLOT(update()));

  // onion skin
  connect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this,
          SLOT(update()));

  // enable navigator link with the Viewer in the InknPaint page
  ComboViewerPanel *inknPaintViewerPanel = app->getInknPaintViewerPanel();
  if (inknPaintViewerPanel) {
    SceneViewer *viewer = inknPaintViewerPanel->getSceneViewer();
    if (viewer) {
      connect(viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
      connect(viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
    }
  }
}
コード例 #2
0
ファイル: filmstrip.cpp プロジェクト: jcome/opentoonz
void FilmstripFrames::hideEvent(QHideEvent *) {
  TApp *app = TApp::instance();

  // cambiamenti al livello
  disconnect(app->getCurrentLevel());

  // al frame corrente
  disconnect(app->getCurrentFrame(), SIGNAL(frameSwitched()), this,
             SLOT(onFrameSwitched()));
  disconnect(app->getCurrentFrame(), SIGNAL(frameTypeChanged()), this,
             SLOT(update()));

  // iconcine
  disconnect(IconGenerator::instance(), SIGNAL(iconGenerated()), this,
             SLOT(update()));

  // onion skin
  disconnect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this,
             SLOT(update()));

  ComboViewerPanel *inknPaintViewerPanel = app->getInknPaintViewerPanel();
  if (inknPaintViewerPanel) {
    SceneViewer *viewer = inknPaintViewerPanel->getSceneViewer();
    if (viewer) {
      disconnect(viewer, SIGNAL(onZoomChanged()), this, SLOT(update()));
      disconnect(viewer, SIGNAL(refreshNavi()), this, SLOT(update()));
    }
  }
}
コード例 #3
0
void BrowserUtils::generateIconFromFile(const QString inFile, const QString outFile, const QSize imageSize)
{
	QImage inImage(inFile);
	if (inImage.isNull()) {
		qWarning() << "generateIconFromFile - failed to open source file";
		Q_EMIT iconGenerated(false, outFile);
		return;
	}
	const int nMargin = 4;// Must agree with pixel data in image files
	const int nIconSize = 64;// Width & height of output image
	const int nIconWidth = nIconSize-2*nMargin;// Width of icon image within file
	const int nIconHeight = nIconSize-2*nMargin;
	QImage outImage(nIconSize, nIconSize, QImage::Format_ARGB32_Premultiplied);
	outImage.fill(0);
	QPainter painter(&outImage);
	painter.setRenderHint(QPainter::SmoothPixmapTransform);
	QRectF source(0.0, 0.0, imageSize.width(), imageSize.height());
	QRectF target(nMargin, nMargin, nIconWidth, nIconHeight);
	QRectF size(0.0, 0.0, nIconSize, nIconSize);
	painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
	painter.drawImage(target, inImage, source);
	painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
	QImage maskImage(kIconMaskFile);
	painter.drawImage(target, maskImage, target);
	painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
	QImage overlayImage(kIconOverlayFile);
	painter.drawImage(size, overlayImage, size);

	QFileInfo imageInfo(outFile);
	QDir imageDir(imageInfo.path());
	if (!imageDir.exists()) {
		imageDir.mkpath(".");
	}

	bool saved = outImage.save(outFile);
	Q_EMIT iconGenerated(saved, outFile);
}
コード例 #4
0
void IconsGenerator::doConvertIcon(const IconToGenerate& icon)
{
	// Loading the svg file. Printing a message in case of errors
	QSvgRenderer svgSource(icon.sourceSvg);
	if (!svgSource.isValid()) {
		qDebug() << "Invalid svg image" << icon.sourceSvg;
		emit iconGenerated(icon.index, QString());

		return;
	}

	// Computing the output dimension
	int outputWidth = 0;
	int outputHeight = 0;
	const QSize inputSize = svgSource.defaultSize();
	if (icon.s == SpecifiedDimension::Width) {
		outputWidth = icon.iconDim;
		outputHeight = int((double(inputSize.height()) / double(inputSize.width())) * double(outputWidth));
	} else if (icon.s == SpecifiedDimension::Height) {
		outputHeight = icon.iconDim;
		outputWidth = int((double(inputSize.width()) / double(inputSize.height())) * double(outputHeight));
	} else {
		// We should really never get here...
		qDebug() << "INTERNAL ERROR: invalid specified dimension";
		emit iconGenerated(icon.index, QString());

		return;
	}

	// Generating the output filename
	const QString outputFilename = QString("%1/%2-%3-%4x%5.png")
			.arg(m_outputPath)
			.arg(QFileInfo(icon.sourceSvg).baseName())
			.arg(icon.index)
			.arg(outputWidth)
			.arg(outputHeight);

	// Checking that the icon doesn't already exist
	if (QFileInfo(outputFilename).exists()) {
		// Emitting the signal for the existing image and returning
		emit iconGenerated(icon.index, outputFilename);

		return;
	}

	// Creating the image and the painter to draw the image
	QImage outputImage(outputWidth, outputHeight, QImage::Format_ARGB32);
	outputImage.fill(Qt::transparent);
	QPainter painter(&outputImage);
	painter.setRenderHint(QPainter::Antialiasing, true);

	// Generating the image and saving it. Printing a message in case of errors
	svgSource.render(&painter);
	painter.end();
	if (!outputImage.save(outputFilename, nullptr, 100)) {
		qDebug() << "Could not save png icon" << outputFilename;
		emit iconGenerated(icon.index, QString());

		return;
	}

	// Emitting the signal
	emit iconGenerated(icon.index, outputFilename);
}