本文整理汇总了C++中LayerImage::setOpacity方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerImage::setOpacity方法的具体用法?C++ LayerImage::setOpacity怎么用?C++ LayerImage::setOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerImage
的用法示例。
在下文中一共展示了LayerImage::setOpacity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyLayerContent
void Document::copyLayerContent(const Layer* sourceLayer0, Document* destDoc, Layer* destLayer0) const
{
LayerFlags dstFlags = sourceLayer0->flags();
// Remove the "background" flag if the destDoc already has a background layer.
if (((int)dstFlags & (int)LayerFlags::Background) == (int)LayerFlags::Background &&
(destDoc->sprite()->backgroundLayer())) {
dstFlags = (LayerFlags)((int)dstFlags & ~(int)(LayerFlags::BackgroundLayerFlags));
}
// Copy the layer name
destLayer0->setName(sourceLayer0->name());
destLayer0->setFlags(dstFlags);
if (sourceLayer0->isImage() && destLayer0->isImage()) {
const LayerImage* sourceLayer = static_cast<const LayerImage*>(sourceLayer0);
LayerImage* destLayer = static_cast<LayerImage*>(destLayer0);
// Copy blend mode and opacity
destLayer->setBlendMode(sourceLayer->blendMode());
destLayer->setOpacity(sourceLayer->opacity());
// Copy cels
CelConstIterator it = sourceLayer->getCelBegin();
CelConstIterator end = sourceLayer->getCelEnd();
std::map<ObjectId, Cel*> linked;
for (; it != end; ++it) {
const Cel* sourceCel = *it;
if (sourceCel->frame() > destLayer->sprite()->lastFrame())
break;
base::UniquePtr<Cel> newCel;
auto it = linked.find(sourceCel->data()->id());
if (it != linked.end()) {
newCel.reset(Cel::createLink(it->second));
newCel->setFrame(sourceCel->frame());
}
else {
newCel.reset(create_cel_copy(sourceCel,
destLayer->sprite(),
sourceCel->frame()));
linked.insert(std::make_pair(sourceCel->data()->id(), newCel.get()));
}
destLayer->addCel(newCel);
newCel.release();
}
}
else if (sourceLayer0->isFolder() && destLayer0->isFolder()) {
const LayerFolder* sourceLayer = static_cast<const LayerFolder*>(sourceLayer0);
LayerFolder* destLayer = static_cast<LayerFolder*>(destLayer0);
LayerConstIterator it = sourceLayer->getLayerBegin();
LayerConstIterator end = sourceLayer->getLayerEnd();
for (; it != end; ++it) {
Layer* sourceChild = *it;
base::UniquePtr<Layer> destChild(NULL);
if (sourceChild->isImage()) {
destChild.reset(new LayerImage(destLayer->sprite()));
copyLayerContent(sourceChild, destDoc, destChild);
}
else if (sourceChild->isFolder()) {
destChild.reset(new LayerFolder(destLayer->sprite()));
copyLayerContent(sourceChild, destDoc, destChild);
}
else {
ASSERT(false);
}
ASSERT(destChild != NULL);
// Add the new layer in the sprite.
Layer* newLayer = destChild.release();
Layer* afterThis = destLayer->getLastLayer();
destLayer->addLayer(newLayer);
destChild.release();
destLayer->stackLayer(newLayer, afterThis);
}
}
else {
ASSERT(false && "Trying to copy two incompatible layers");
}
}