void flipVertical( const SurfaceT<T> &srcSurface, SurfaceT<T> *destSurface ) { std::pair<Area,ivec2> srcDst = clippedSrcDst( srcSurface.getBounds(), destSurface->getBounds(), destSurface->getBounds(), ivec2(0,0) ); if( destSurface->getChannelOrder() == srcSurface.getChannelOrder() ) flipVerticalRawSameChannelOrder( srcSurface, destSurface, srcDst.first.getSize() ); else if( destSurface->hasAlpha() && srcSurface.hasAlpha() ) flipVerticalRawRgba( srcSurface, destSurface, srcDst.first.getSize() ); else if( destSurface->hasAlpha() && ( ! srcSurface.hasAlpha() ) ) flipVerticalRawRgbFullAlpha( srcSurface, destSurface, srcDst.first.getSize() ); else flipVerticalRawRgb( srcSurface, destSurface, srcDst.first.getSize() ); }
void edgeDetectSobel( const SurfaceT<T> &srcSurface, const Area &srcArea, const Vec2i &dstLT, SurfaceT<T> *dstSurface ) { edgeDetectSobel( *srcSurface.getChannelRed(), srcArea, dstLT, dstSurface->getChannelRed() ); edgeDetectSobel( *srcSurface.getChannelGreen(), srcArea, dstLT, dstSurface->getChannelGreen() ); edgeDetectSobel( *srcSurface.getChannelBlue(), srcArea, dstLT, dstSurface->getChannelBlue() ); if( srcSurface.hasAlpha() && dstSurface->hasAlpha() ) edgeDetectSobel( *srcSurface.getChannelAlpha(), srcArea, dstLT, dstSurface->getChannelAlpha() ); }
void SurfaceT<T>::copyFrom( const SurfaceT<T> &srcSurface, const Area &srcArea, const Vec2i &relativeOffset ) { std::pair<Area,Vec2i> srcDst = clippedSrcDst( srcSurface.getBounds(), srcArea, getBounds(), srcArea.getUL() + relativeOffset ); if( getChannelOrder() == srcSurface.getChannelOrder() ) copyRawSameChannelOrder( srcSurface, srcDst.first, srcDst.second ); else if( hasAlpha() && srcSurface.hasAlpha() ) copyRawRgba( srcSurface, srcDst.first, srcDst.second ); else copyRawRgb( srcSurface, srcDst.first, srcDst.second ); }
Area findNonTransparentArea( const SurfaceT<T> &surface, const Area &unclippedBounds ) { const Area bounds = unclippedBounds.getClipBy( surface.getBounds() ); // if no alpha we'll fail over the to alpha-less fill if( ! surface.hasAlpha() ) { return surface.getBounds(); } int32_t topLine, bottomLine; int32_t leftColumn, rightColumn; // find the top and bottom lines for( topLine = bounds.getY1(); topLine < bounds.getY2(); ++topLine ) { if( ! transparentHorizontalScanline( surface, topLine, bounds.getX1(), bounds.getX2() ) ) { break; } } for( bottomLine = bounds.getY2() - 1; bottomLine > topLine; --bottomLine ) { if( ! transparentHorizontalScanline( surface, bottomLine, bounds.getX1(), bounds.getX2() ) ) { break; } } // find the left and right columns for( leftColumn = bounds.getX1(); leftColumn < bounds.getX2(); ++leftColumn ) { if( ! transparentVerticalScanline( surface, leftColumn, topLine, bottomLine ) ) { break; } } for( rightColumn = bounds.getX2(); rightColumn > leftColumn; --rightColumn ) { if( ! transparentVerticalScanline( surface, rightColumn, topLine, bottomLine ) ) { break; } } // we add one to right and bottom because Area represents an inclusive range on top/left and exclusive range on bottom/right rightColumn = std::min( bounds.getX2(), rightColumn + 1 ); bottomLine = std::min( bounds.getY2(), bottomLine + 1 ); return Area( leftColumn, topLine, rightColumn, bottomLine ); }