void Image::copyUnProcessedChannels(const RectI& roi, const ImagePremultiplicationEnum outputPremult, const ImagePremultiplicationEnum originalImagePremult, const std::bitset<4> processChannels, const ImagePtr& originalImage, bool ignorePremult) { int numComp = getComponents().getNumComponents(); if (numComp == 0) { return; } if ( (numComp == 1) && processChannels[3] ) { // 1 component is alpha return; } else if ( (numComp == 2) && processChannels[0] && processChannels[1] ) { return; } else if ( (numComp == 3) && processChannels[0] && processChannels[1] && processChannels[2] ) { return; } else if ( (numComp == 4) && processChannels[0] && processChannels[1] && processChannels[2] && processChannels[3] ) { return; } if ( originalImage && ( getMipMapLevel() != originalImage->getMipMapLevel() ) ) { qDebug() << "WARNING: attempting to call copyUnProcessedChannels on images with different mipMapLevel"; return; } QWriteLocker k(&_entryLock); assert( !originalImage || getBitDepth() == originalImage->getBitDepth() ); RectI intersected; roi.intersect(_bounds, &intersected); bool premult = (outputPremult == eImagePremultiplicationPremultiplied); bool originalPremult = (originalImagePremult == eImagePremultiplicationPremultiplied); switch ( getBitDepth() ) { case eImageBitDepthByte: copyUnProcessedChannelsForDepth<unsigned char, 255>(premult, roi, processChannels, originalImage, originalPremult, ignorePremult); break; case eImageBitDepthShort: copyUnProcessedChannelsForDepth<unsigned short, 65535>(premult, roi, processChannels, originalImage, originalPremult, ignorePremult); break; case eImageBitDepthFloat: copyUnProcessedChannelsForDepth<float, 1>(premult, roi, processChannels, originalImage, originalPremult, ignorePremult); break; default: return; } }
void Image::copyUnProcessedChannels(const RectI& roi, const ImagePremultiplicationEnum outputPremult, const ImagePremultiplicationEnum originalImagePremult, const std::bitset<4> processChannels, const ImagePtr& originalImage, bool ignorePremult, const OSGLContextPtr& glContext) { int numComp = getComponents().getNumComponents(); if (numComp == 0) { return; } if ( (numComp == 1) && processChannels[3] ) { // 1 component is alpha return; } else if ( (numComp == 2) && processChannels[0] && processChannels[1] ) { return; } else if ( (numComp == 3) && processChannels[0] && processChannels[1] && processChannels[2] ) { return; } else if ( (numComp == 4) && processChannels[0] && processChannels[1] && processChannels[2] && processChannels[3] ) { return; } if ( originalImage && ( getMipMapLevel() != originalImage->getMipMapLevel() ) ) { qDebug() << "WARNING: attempting to call copyUnProcessedChannels on images with different mipMapLevel"; return; } QWriteLocker k(&_entryLock); assert( !originalImage || getBitDepth() == originalImage->getBitDepth() ); RectI srcRoi; roi.intersect(_bounds, &srcRoi); if (getStorageMode() == eStorageModeGLTex) { assert(glContext); if (glContext->isGPUContext()) { copyUnProcessedChannelsGL<GL_GPU>(roi, outputPremult, originalImagePremult, processChannels, originalImage, ignorePremult, glContext, _bounds, srcRoi, getGLTextureTarget(), getGLTextureID(), originalImage->getGLTextureID()); } else { copyUnProcessedChannelsGL<GL_CPU>(roi, outputPremult, originalImagePremult, processChannels, originalImage, ignorePremult, glContext, _bounds, srcRoi, getGLTextureTarget(), getGLTextureID(), originalImage->getGLTextureID()); } return; } bool premult = (outputPremult == eImagePremultiplicationPremultiplied); bool originalPremult = (originalImagePremult == eImagePremultiplicationPremultiplied); switch ( getBitDepth() ) { case eImageBitDepthByte: copyUnProcessedChannelsForDepth<unsigned char, 255>(premult, roi, processChannels, originalImage, originalPremult, ignorePremult); break; case eImageBitDepthShort: copyUnProcessedChannelsForDepth<unsigned short, 65535>(premult, roi, processChannels, originalImage, originalPremult, ignorePremult); break; case eImageBitDepthFloat: copyUnProcessedChannelsForDepth<float, 1>(premult, roi, processChannels, originalImage, originalPremult, ignorePremult); break; default: return; } } // copyUnProcessedChannels