本文整理汇总了C++中KisLayerSP::setCompositeOpId方法的典型用法代码示例。如果您正苦于以下问题:C++ KisLayerSP::setCompositeOpId方法的具体用法?C++ KisLayerSP::setCompositeOpId怎么用?C++ KisLayerSP::setCompositeOpId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisLayerSP
的用法示例。
在下文中一共展示了KisLayerSP::setCompositeOpId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromDevice
KisImportExportFilter::ConversionStatus KisXCFImport::loadFromDevice(QIODevice* device, KisDocument* doc)
{
dbgFile << "Start decoding file";
// Read the file into memory
device->open(QIODevice::ReadOnly);
QByteArray data = device->readAll();
xcf_file = (uint8_t*)data.data();
xcf_length = data.size();
device->close();
// Decode the data
getBasicXcfInfo() ;
initColormap();
dbgFile << XCF.version << "width = " << XCF.width << "height = " << XCF.height << "layers = " << XCF.numLayers;
// Create the image
KisImageSP image = new KisImage(doc->createUndoStore(), XCF.width, XCF.height, KoColorSpaceRegistry::instance()->rgb8(), "built image");
QVector<Layer> layers;
uint maxDepth = 0;
// Read layers
for (int i = 0; i < XCF.numLayers; ++i) {
Layer layer;
xcfLayer& xcflayer = XCF.layers[i];
dbgFile << i << " name = " << xcflayer.name << " opacity = " << xcflayer.opacity << "group:" << xcflayer.isGroup << xcflayer.pathLength;
dbgFile << ppVar(xcflayer.dim.width) << ppVar(xcflayer.dim.height) << ppVar(xcflayer.dim.tilesx) << ppVar(xcflayer.dim.tilesy) << ppVar(xcflayer.dim.ntiles) << ppVar(xcflayer.dim.c.t) << ppVar(xcflayer.dim.c.l) << ppVar(xcflayer.dim.c.r) << ppVar(xcflayer.dim.c.b);
maxDepth = qMax(maxDepth, xcflayer.pathLength);
bool isRgbA = false;
// Select the color space
const KoColorSpace* colorSpace = 0;
switch (xcflayer.type) {
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
colorSpace = KoColorSpaceRegistry::instance()->rgb8();
isRgbA = true;
break;
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
colorSpace = KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), "");
isRgbA = false;
break;
}
// Create the layer
KisLayerSP kisLayer;
if (xcflayer.isGroup) {
kisLayer = new KisGroupLayer(image, QString::fromUtf8(xcflayer.name), xcflayer.opacity);
}
else {
kisLayer = new KisPaintLayer(image, QString::fromUtf8(xcflayer.name), xcflayer.opacity, colorSpace);
}
// Set some properties
kisLayer->setCompositeOpId(layerModeG2K(xcflayer.mode));
kisLayer->setVisible(xcflayer.isVisible);
kisLayer->disableAlphaChannel(xcflayer.mode != GIMP_NORMAL_MODE);
layer.layer = kisLayer;
layer.depth = xcflayer.pathLength;
// Copy the data in the image
initLayer(&xcflayer);
int left = xcflayer.dim.c.l;
int top = xcflayer.dim.c.t;
if (!xcflayer.isGroup) {
// Copy the data;
for (unsigned int x = 0; x < xcflayer.dim.width; x += TILE_WIDTH) {
for (unsigned int y = 0; y < xcflayer.dim.height; y += TILE_HEIGHT) {
rect want;
want.l = x + left;
want.t = y + top;
want.b = want.t + TILE_HEIGHT;
want.r = want.l + TILE_WIDTH;
Tile* tile = getMaskOrLayerTile(&xcflayer.dim, &xcflayer.pixels, want);
KisHLineIteratorSP it = kisLayer->paintDevice()->createHLineIteratorNG(x, y, TILE_WIDTH);
rgba* data = tile->pixels;
for (int v = 0; v < TILE_HEIGHT; ++v) {
if (isRgbA) {
// RGB image
do {
KoBgrTraits<quint8>::setRed(it->rawData(), GET_RED(*data));
KoBgrTraits<quint8>::setGreen(it->rawData(), GET_GREEN(*data));
KoBgrTraits<quint8>::setBlue(it->rawData(), GET_BLUE(*data));
KoBgrTraits<quint8>::setOpacity(it->rawData(), quint8(GET_ALPHA(*data)), 1);
++data;
} while (it->nextPixel());
} else {
// Grayscale image
do {
//.........这里部分代码省略.........