当前位置: 首页>>代码示例>>C++>>正文


C++ KisConfig::showSingleChannelAsColor方法代码示例

本文整理汇总了C++中KisConfig::showSingleChannelAsColor方法的典型用法代码示例。如果您正苦于以下问题:C++ KisConfig::showSingleChannelAsColor方法的具体用法?C++ KisConfig::showSingleChannelAsColor怎么用?C++ KisConfig::showSingleChannelAsColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KisConfig的用法示例。


在下文中一共展示了KisConfig::showSingleChannelAsColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: retrieveImageData

void KisImagePyramid::retrieveImageData(const QRect &rect)
{
    // XXX: use QThreadStorage to cache the two patches (512x512) of pixels. Note
    // that when we do that, we need to reset that cache when the projection's
    // colorspace changes.
    const KoColorSpace *projectionCs = m_originalImage->projection()->colorSpace();
    KisPaintDeviceSP originalProjection = m_originalImage->projection();
    quint32 numPixels = rect.width() * rect.height();

    QScopedArrayPointer<quint8> originalBytes(
        new quint8[originalProjection->colorSpace()->pixelSize() * numPixels]);

    originalProjection->readBytes(originalBytes.data(), rect);

    if (m_displayFilter &&
        m_useOcio &&
        projectionCs->colorModelId() == RGBAColorModelID) {

#ifdef HAVE_OCIO
        const KoColorProfile *destinationProfile =
            m_displayFilter->useInternalColorManagement() ?
            m_monitorProfile : projectionCs->profile();

        const KoColorSpace *floatCs =
            KoColorSpaceRegistry::instance()->colorSpace(
                RGBAColorModelID.id(),
                Float32BitsColorDepthID.id(),
                destinationProfile);

        const KoColorSpace *modifiedMonitorCs =
            KoColorSpaceRegistry::instance()->colorSpace(
                RGBAColorModelID.id(),
                Integer8BitsColorDepthID.id(),
                destinationProfile);

        if (projectionCs->colorDepthId() == Float32BitsColorDepthID) {
            m_displayFilter->filter(originalBytes.data(), numPixels);
        } else {
            QScopedArrayPointer<quint8> dst(new quint8[floatCs->pixelSize() * numPixels]);
            projectionCs->convertPixelsTo(originalBytes.data(), dst.data(), floatCs, numPixels, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags);
            m_displayFilter->filter(dst.data(), numPixels);
            originalBytes.swap(dst);
        }

        {
            QScopedArrayPointer<quint8> dst(new quint8[modifiedMonitorCs->pixelSize() * numPixels]);
            floatCs->convertPixelsTo(originalBytes.data(), dst.data(), modifiedMonitorCs, numPixels, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags);
            originalBytes.swap(dst);
        }
#endif
    }
    else {
        QList<KoChannelInfo*> channelInfo = projectionCs->channels();
        if (!m_channelFlags.size() == channelInfo.size()) {
            setChannelFlags(QBitArray());
        }
        if (!m_channelFlags.isEmpty() && !m_allChannelsSelected) {
            QScopedArrayPointer<quint8> dst(new quint8[projectionCs->pixelSize() * numPixels]);

            int channelSize = channelInfo[m_selectedChannelIndex]->size();
            int pixelSize = projectionCs->pixelSize();

            KisConfig cfg;

            if (m_onlyOneChannelSelected && !cfg.showSingleChannelAsColor()) {
                int selectedChannelPos = channelInfo[m_selectedChannelIndex]->pos();
                for (uint pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
                    for (uint channelIndex = 0; channelIndex < projectionCs->channelCount(); ++channelIndex) {

                        if (channelInfo[channelIndex]->channelType() == KoChannelInfo::COLOR) {
                            memcpy(dst.data() + (pixelIndex * pixelSize) + (channelIndex * channelSize),
                                   originalBytes.data() + (pixelIndex * pixelSize) + selectedChannelPos,
                                   channelSize);
                        }
                        else if (channelInfo[channelIndex]->channelType() == KoChannelInfo::ALPHA) {
                            memcpy(dst.data() + (pixelIndex * pixelSize) + (channelIndex * channelSize),
                                   originalBytes.data()  + (pixelIndex * pixelSize) + (channelIndex * channelSize),
                                   channelSize);
                        }
                    }
                }
            }
            else {
                for (uint pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
                    for (uint channelIndex = 0; channelIndex < projectionCs->channelCount(); ++channelIndex) {
                        if (m_channelFlags.testBit(channelIndex)) {
                            memcpy(dst.data() + (pixelIndex * pixelSize) + (channelIndex * channelSize),
                                   originalBytes.data()  + (pixelIndex * pixelSize) + (channelIndex * channelSize),
                                   channelSize);
                        }
                        else {
                            memset(dst.data() + (pixelIndex * pixelSize) + (channelIndex * channelSize), 0, channelSize);
                        }
                    }
                }

            }
            originalBytes.swap(dst);
        }

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的KisConfig::showSingleChannelAsColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。