基於OpenCV的視頻圖像組態 (7) :輪子動畫效果

輪子效果 ui

bool __fastcall TCbwAnimationEffect_Wheel::BuildMaskMat(cv::Mat& destMat,spa

    cv::Mat& srcMat, TRect displayRect) {it

    TRect wholeRect(0, 0, displayRect.right - displayRect.left,io

        displayRect.bottom - displayRect.top);ast

    double cx = wholeRect.right / 2.0, cy = wholeRect.bottom / 2.0;im

    TCbwFloatPoint centerPoint(cx, cy);call

    double unitDegree = 360 / FPattern;top

    double deltaDegree = double(FCurrentIndex + 1) / FTotalFramesInOnePeriod * unitDegree;img

    BYTE * pDst = destMat.data;di

    for (int row = 0; row < destMat.rows; ++row)

        for (int col = 0; col < destMat.cols; ++col) {

            TCbwFloatPoint p(col, row);

            double theta = p.ThetaToPoint(centerPoint);

            if (FClockwiseFlag)

                theta = 360 - theta;

            bool inFlag = false;

            for (int i = 0; i < FPattern; ++i) {

                if (theta >= unitDegree * i && (theta - unitDegree * i) <=

                    deltaDegree)

                    inFlag = true;

            }

            *pDst++ = inFlag ? 255 : 0;

        }

    return true;

}

 

演示效果

相關文章
相關標籤/搜索