void CqMixedImageBuffer::compositeOver(const CqMixedImageBuffer& source, const TqChannelNameMap& nameMap, TqInt topLeftX, TqInt topLeftY, const std::string alphaName) { if(!source.channelList().hasChannel(alphaName)) { copyFrom(source, nameMap, topLeftX, topLeftY); } else { // compute size and top left coords of region to copy. TqInt copyWidth = 0; TqInt destTopLeftX = 0; TqInt srcTopLeftX = 0; getCopyRegionSize(topLeftX, source.m_width, m_width, srcTopLeftX, destTopLeftX, copyWidth); TqInt copyHeight = 0; TqInt destTopLeftY = 0; TqInt srcTopLeftY = 0; getCopyRegionSize(topLeftY, source.m_height, m_height, srcTopLeftY, destTopLeftY, copyHeight); // return if no overlap if(copyWidth <= 0 || copyHeight <= 0) return; for(TqChannelNameMap::const_iterator i = nameMap.begin(), e = nameMap.end(); i != e; ++i) { channel(i->first, destTopLeftX, destTopLeftY, copyWidth, copyHeight) ->compositeOver(*source.channel(i->second, srcTopLeftX, srcTopLeftY, copyWidth, copyHeight), *source.channel(alphaName, srcTopLeftX, srcTopLeftY, copyWidth, copyHeight)); } } }
void CqMixedImageBuffer::copyFrom(const CqMixedImageBuffer& source, TqInt topLeftX, TqInt topLeftY) { if(source.m_channelList.numChannels() != m_channelList.numChannels()) AQSIS_THROW_XQERROR(XqInternal, EqE_Limit, "Number of source and destination channels do not match"); // compute size and top left coords of region to copy. TqInt copyWidth = 0; TqInt destTopLeftX = 0; TqInt srcTopLeftX = 0; getCopyRegionSize(topLeftX, source.m_width, m_width, srcTopLeftX, destTopLeftX, copyWidth); TqInt copyHeight = 0; TqInt destTopLeftY = 0; TqInt srcTopLeftY = 0; getCopyRegionSize(topLeftY, source.m_height, m_height, srcTopLeftY, destTopLeftY, copyHeight); // return if no overlap if(copyWidth <= 0 || copyHeight <= 0) return; for(TqInt i = 0; i < m_channelList.numChannels(); ++i) { channel(i, destTopLeftX, destTopLeftY, copyWidth, copyHeight) ->copyFrom(*source.channel(i, srcTopLeftX, srcTopLeftY, copyWidth, copyHeight)); } }