如题:
  GDI+ 方法 ,如何在图片上垂直镜像的添加文字?即添加后的文字是倒立的,垂直镜像的。

解决方案 »

  1.   

    GDI+有旋转图片一项。
    把文字写在一个“黑色”的DC上,把DC镜像了,再和原始DC合成。
      

  2.   

    这是一个旋转图片的例子。void CMyDlg::MyDrawjpg(CDC* pDC,CString strPathname,int cx,int cy,int iRotate,int iZoom)
    {
        Image m_pImage(strPathname.AllocSysString());//图片名
    m_pImage.RotateFlip(RotateFlipType(iRotate));//旋转
    Graphics graphics(pDC->m_hDC);
    graphics.DrawImage(&m_pImage,cx,cy,m_pImage.GetWidth()*iZoom,m_pImage.GetHeight()*iZoom);//画图
    }
      

  3.   

    // 绘制X横轴标签
    Font myFont(_T("Arial"), 11); //Times New Roman
    StringFormat format;
    format.SetAlignment(StringAlignmentCenter);
    format.SetLineAlignment(StringAlignmentCenter);
    SolidBrush blackBrush(Color(255, 0, 0, 128)); RectF layoutRect1((REAL)m_nLeft+m_nLeftMargin, (REAL)m_nTop+m_nHeight-20, (REAL)m_nXAxesLen, 20);
    int strLen = lstrlen(m_szXLabel);
    graph.DrawString(m_szXLabel, strLen, &myFont, layoutRect1, &format, &blackBrush);
    #ifdef _DEBUG
    Pen tPen(Color(16, 0, 0, 0), 1);
    graph.DrawRectangle(&tPen, layoutRect1);
    #endif // 绘制Y竖轴标签
    //format.SetAlignment(StringAlignmentCenter);
    //format.SetLineAlignment(StringAlignmentCenter);
    //format.SetFormatFlags(StringFormatFlagsDirectionVertical);
    RectF layoutRect2((REAL)m_nLeft, (REAL)m_nTop+m_nTopMargin+m_nYAxesLen, (REAL)m_nYAxesLen, 20);
    strLen = lstrlen(m_szYLabel);
    // 旋转文字  
    Matrix oldMatrix;
    graph.GetTransform(&oldMatrix);
    Matrix* pMatrix = oldMatrix.Clone();
    pMatrix->RotateAt(270.0f, PointF((REAL)m_nLeft, (REAL)m_nTop+m_nTopMargin+m_nYAxesLen)); // 在顶点旋转270度
    graph.SetTransform(pMatrix); graph.DrawString(m_szYLabel, strLen, &myFont, layoutRect2, &format, &blackBrush);
    #ifdef _DEBUG
    graph.DrawRectangle(&tPen, layoutRect2);
    #endif delete pMatrix;
    graph.SetTransform(&oldMatrix);