基于单Dialog的,在对话框中显示风吹图片随意摆动的效果,求原理以及实现方法。

解决方案 »

  1.   

    两个要素:图片透明和旋转。透明的话,用png图片做,然后用GDI+来旋转图片。实现我就不帮你实现了。
      

  2.   

    GDI+怎么弄?3楼能说具体点吗?
      

  3.   

    水波,火焰,熔岩效果都可以用算法来render(处理)图片达到效果
    你所说的风吹效果倒是没实现过
      

  4.   


    我理解错了,我理解成风吹树叶了,如果是风吹树叶,可以把树叶做成透明png。gdi+转图片的代码类似于下面的:
    CRect rcClient;
    GetClientRect(rcClient);

    Gdiplus::Graphics graphics(pDC->GetSafeHdc());

    // draw background
    Gdiplus::Rect rect(0, 0, rcClient.Width(), rcClient.Height());
    graphics.DrawImage(m_hbmpBk, rect, 0, 0, rcClient.Width(), rcClient.Height(), Gdiplus::UnitPixel);

    // draw pointer
    #define PAI 3.1415926
    CSize sizePt;
    GetBITMAPOBJSize2(m_hbmpPointer, &sizePt);

    double fPos = 2*PAI*(double)m_nPos/double(m_nMax-m_nMin);

    double x = m_ptCenterBk.x + m_ptCenterPt.y * sin(fPos);
    double y = m_ptCenterBk.y - m_ptCenterPt.y * cos(fPos);

    double x1 = x - m_ptCenterPt.x*cos(fPos);
    double y1 = y - m_ptCenterPt.x*sin(fPos);
    double x2 = x + m_ptCenterPt.x*cos(fPos);
    double y2 = y + m_ptCenterPt.x*sin(fPos);

    double X = m_ptCenterBk.x - (sizePt.cy-m_ptCenterPt.y) * sin(fPos);
    double Y = m_ptCenterBk.y + (sizePt.cy-m_ptCenterPt.y) * cos(fPos);
    double x3 = X - m_ptCenterPt.x * cos(fPos);
    double y3 = Y - m_ptCenterPt.x * sin(fPos);

    Point destinationPoints[] = {
    Point(INT(x1), INT(y1)), // destination for upper-left point of original
    Point(INT(x2), INT(y2)), // destination for upper-right point of original
    Point(INT(x3), INT(y3)) };// destination for lower-left point of original
    graphics.DrawImage(m_hbmpPointer, destinationPoints, 3);