本文整理汇总了C++中KisImageSP::nextLayerName方法的典型用法代码示例。如果您正苦于以下问题:C++ KisImageSP::nextLayerName方法的具体用法?C++ KisImageSP::nextLayerName怎么用?C++ KisImageSP::nextLayerName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisImageSP
的用法示例。
在下文中一共展示了KisImageSP::nextLayerName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert
KisImportExportFilter::ConversionStatus KisBMPImport::convert(const QByteArray& from, const QByteArray& to)
{
dbgFile << "BMP import! From:" << from << ", To:" << to << 0;
if (to != "application/x-krita")
return KisImportExportFilter::BadMimeType;
KisDocument * doc = outputDocument();
if (!doc)
return KisImportExportFilter::NoDocumentCreated;
QString filename = inputFile();
doc->prepareForImport();
if (!filename.isEmpty()) {
QFileInfo fi(filename);
if (!fi.exists()) {
return KisImportExportFilter::FileNotFound;
}
QImage img(filename);
const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(doc->createUndoStore(), img.width(), img.height(), colorSpace, "imported from bmp");
KisPaintLayerSP layer = new KisPaintLayer(image, image->nextLayerName(), 255);
layer->paintDevice()->convertFromQImage(img, 0, 0, 0);
image->addNode(layer.data(), image->rootLayer().data());
doc->setCurrentImage(image);
return KisImportExportFilter::OK;
}
return KisImportExportFilter::StorageCreationError;
}
示例2: convert
KoFilter::ConversionStatus KisOpenEXRImport::convert(const QByteArray& from, const QByteArray& to)
{
if (from != "image/x-exr" || to != "application/x-krita") {
return KoFilter::NotImplemented;
}
dbgFile << "\n\n\nKrita importing from OpenEXR";
KisDoc2 * doc = dynamic_cast<KisDoc2*>(m_chain -> outputDocument());
if (!doc) {
return KoFilter::CreationError;
}
doc -> prepareForImport();
QString filename = m_chain -> inputFile();
if (filename.isEmpty()) {
return KoFilter::FileNotFound;
}
RgbaInputFile file(QFile::encodeName(filename));
Box2i dataWindow = file.dataWindow();
Box2i displayWindow = file.displayWindow();
dbgFile << "Data window:" << QRect(dataWindow.min.x, dataWindow.min.y, dataWindow.max.x - dataWindow.min.x + 1, dataWindow.max.y - dataWindow.min.y + 1);
dbgFile << "Display window:" << QRect(displayWindow.min.x, displayWindow.min.y, displayWindow.max.x - displayWindow.min.x + 1, displayWindow.max.y - displayWindow.min.y + 1);
int imageWidth = displayWindow.max.x - displayWindow.min.x + 1;
int imageHeight = displayWindow.max.y - displayWindow.min.y + 1;
QString imageName = "Imported from OpenEXR";
int dataWidth = dataWindow.max.x - dataWindow.min.x + 1;
int dataHeight = dataWindow.max.y - dataWindow.min.y + 1;
const KoColorSpace *cs = static_cast<const KoColorSpace *>((KoColorSpaceRegistry::instance()->colorSpace(KoID("RgbAF16", ""), "")));
if (cs == 0) {
return KoFilter::InternalError;
}
doc -> undoAdapter() -> setUndo(false);
KisImageSP image = new KisImage(doc->undoAdapter(), imageWidth, imageHeight, cs, imageName);
if (!image) {
return KoFilter::CreationError;
}
image->lock();
KisPaintLayerSP layer = new KisPaintLayer(image, image->nextLayerName(), OPACITY_OPAQUE, cs);
layer->setCompositeOp(COMPOSITE_OVER);
if (!layer) {
return KoFilter::CreationError;
}
Q3MemArray<Rgba> pixels(dataWidth);
for (int y = 0; y < dataHeight; ++y) {
file.setFrameBuffer(pixels.data() - dataWindow.min.x - (dataWindow.min.y + y) * dataWidth, 1, dataWidth);
file.readPixels(dataWindow.min.y + y);
KisHLineIterator it = layer->paintDevice()->createHLineIterator(dataWindow.min.x, dataWindow.min.y + y, dataWidth);
Rgba *rgba = pixels.data();
while (!it.isDone()) {
// XXX: For now unmultiply the alpha, though compositing will be faster if we
// keep it premultiplied.
half unmultipliedRed = rgba -> r;
half unmultipliedGreen = rgba -> g;
half unmultipliedBlue = rgba -> b;
if (rgba -> a >= HALF_EPSILON) {
unmultipliedRed /= rgba -> a;
unmultipliedGreen /= rgba -> a;
unmultipliedBlue /= rgba -> a;
}
setPixel(it.rawData(), unmultipliedRed, unmultipliedGreen, unmultipliedBlue, rgba -> a);
++it;
++rgba;
}
}
image->addNode(layer.data(), image->rootLayer().data());
layer->setDirty();
doc -> setCurrentImage(image);
doc -> undoAdapter() -> setUndo(true);
doc -> setModified(false);
image->unlock();
return KoFilter::OK;
}