コード例 #1
0
void ImageLoader::buildAllIconsAndPutInCache(TXshSimpleLevel *level,
											 std::vector<TFrameId> fids,
											 std::vector<std::string> iconIds,
											 bool cacheImagesAsWell)
{
	if (m_path.getType() != "tlv")
		return;
	if (fids.empty() || iconIds.empty())
		return;
	/*- fidとアイコンidの数は同じはず -*/
	if ((int)fids.size() != (int)iconIds.size())
		return;

	try {
		TLevelReaderP lr(m_path);
		if (!lr)
			return;

		for (int i = 0; i < (int)fids.size(); i++) {
			lr->doReadPalette(false);
			TImageReaderP ir = lr->getFrameReader(fids[i]);
			lr->doReadPalette(true);

			TImageInfo info;
			TPalette *palette = level->getPalette();
			std::string fullImgId = level->getImageId(fids[i]);

			/*- 画像データも一緒にキャッシュする場合 -*/
			if (cacheImagesAsWell) {
				ir->enable16BitRead(m_64bitCompatible);
				ir->setShrink(1);
				TImageP fullImg = ir->load();
				if (fullImg) {
					if (palette)
						fullImg->setPalette(palette);
					TImageCache::instance()->add(fullImgId, fullImg, true);
					setImageInfo(info, fullImg.getPointer());
				}
			}

			/*- アイコンのロード -*/
			TImageP img = ir->loadIcon();
			ir->enable16BitRead(false);
			if (img) {
				if (palette)
					img->setPalette(palette);
				TImageCache::instance()->add(iconIds[i], img, true);
			}
		}
	} catch (...) {
		return;
	}
}
コード例 #2
0
/*-- Paste後のフローティング状態の画像の描画 --*/
void RasterSelectionTool::drawFloatingSelection()
{
	double pixelSize = TTool::getApplication()->getCurrentTool()->getTool()->getPixelSize();

	TAffine aff = m_rasterSelection.getTransformation();
	glPushMatrix();
	tglMultMatrix(aff);

	//draw m_floatingSelection
	if (isFloating()) {
		TRasterP floatingSelection = m_rasterSelection.getFloatingSelection();
		TImageP app;
		if (TRasterCM32P toonzRas = (TRasterCM32P)(floatingSelection))
			app = TToonzImageP(toonzRas, toonzRas->getBounds());
		if (TRaster32P fullColorRas = (TRaster32P)(floatingSelection))
			app = TRasterImageP(fullColorRas);
		if (TRasterGR8P grRas = (TRasterGR8P)(floatingSelection))
			app = TRasterImageP(grRas);
		app->setPalette(m_rasterSelection.getCurrentImage()->getPalette());
		FourPoints points = getBBox() * aff.inv();
		TRectD bbox = points.getBox();
		TPointD center((bbox.getP00() + bbox.getP11()) * 0.5);
		if (TToonzImageP ti = (TToonzImageP)app)
			GLRasterPainter::drawRaster(TTranslation(center), ti, false);
		if (TRasterImageP ri = (TRasterImageP)app)
			GLRasterPainter::drawRaster(TTranslation(center), ri, true);
	}

	std::vector<TStroke> strokes = m_rasterSelection.getStrokes();
	int i;
	for (i = 0; i < (int)strokes.size(); i++) {
		TStroke stroke = strokes[i];
		glEnable(GL_LINE_STIPPLE);
		glLineStipple(1, 0xF0F0);
		tglColor(TPixel32::Black);
		drawStrokeCenterline(stroke, pixelSize);
		glDisable(GL_LINE_STIPPLE);
	}

	glPopMatrix();
}
コード例 #3
0
ファイル: mergecmapped.cpp プロジェクト: Xmoggo/opentoonz
	void undo() const
	{
		std::map<TFrameId, QString>::const_iterator it = m_images.begin();
		TPalette *palette = m_palette->clone();
		m_level->setPalette(palette);
		vector<TFrameId> fids;
		for (; it != m_images.end(); ++it) //, ++mit)
		{
			QString id = "MergeCmappedUndo" + QString::number(m_mergeCmappedSessionId) + "-" + QString::number(it->first.getNumber());
			TImageP img = TImageCache::instance()->get(id, false)->cloneImage();
			img->setPalette(palette);
			m_level->setFrame(it->first, img);
			fids.push_back(it->first);
		}

		removeLevel(m_xl);

		TApp::instance()->getPaletteController()->getCurrentLevelPalette()->setPalette(palette);
		m_level->setDirtyFlag(true);
		TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
	}
コード例 #4
0
TImageP ImageLoader::build(int imFlags, void *extData)
{
	assert(extData);

	// Extract external data
	BuildExtData *data = static_cast<BuildExtData *>(extData);

	int subsampling = buildSubsampling(imFlags, data);

	try {
		// Initialize level reader
		TLevelReaderP lr(m_path);
		if (!lr)
			return TImageP();

		// Load info in cases where it's required first
		lr->doReadPalette(false);

		if ((m_path.getType() == "pli") || (m_path.getType() == "svg") || (m_path.getType() == "psd"))
			lr->loadInfo();

		lr->doReadPalette(true); // Allow palette loading

		TImageReaderP ir = lr->getFrameReader(m_fid);

		bool enable64bit = (imFlags & ImageManager::is64bitEnabled);
		ir->enable16BitRead(enable64bit); // Set 64-bit loading if required

		// Load the image
		TImageP img;

		if (data->m_icon && m_path.getType() == "tlv")
			img = ir->loadIcon(); // TODO: Why just in the tlv case??
		else {
			ir->setShrink(subsampling);
			img = ir->load();
		}

		ir->enable16BitRead(false);

		if (!img)
			return img; // There was an error loading the image.

		TPalette *palette = data->m_sl->getPalette();
		if (palette)
			img->setPalette(palette);

		if (subsampling > 1) {
			// Store the subsampling info in the image
			if (TRasterImageP ri = img)
				ri->setSubsampling(subsampling);
			else if (TToonzImageP ti = img)
				ti->setSubsampling(subsampling);
		}

		// In case the image will be cached, store its subsampling and 64 bit compatibility
		if (!(imFlags & ImageManager::dontPutInCache)) {
			m_subsampling = subsampling;
			m_64bitCompatible = data->m_sl->is16BitChannelLevel() ? enable64bit : true;
		}

		return img;
	} catch (...) {
		return TImageP();
	}
}