GDI+ 方法 ,如何在图片上垂直镜像的添加文字? 如题: GDI+ 方法 ,如何在图片上垂直镜像的添加文字?即添加后的文字是倒立的,垂直镜像的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GDI+有旋转图片一项。把文字写在一个“黑色”的DC上,把DC镜像了,再和原始DC合成。 这是一个旋转图片的例子。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);//画图} // 绘制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); VC 录音 问题 动态改变运算符 求线程编程的解释。AfxBeginThread 第2个参数是LPVOID pParam。是什么呢? 求助:如何实时响应键盘消息? 网络方面有个问题,请教一下 gdy119, 内容发到了你的邮箱 *** 绝对难度: 怎么改变CListCtrl列表头的高度** 100分* 透明位图的问题 VC中的SetPixel速度太慢,有没什么方法可以加快显示速度. 刚刚把欠各位兄弟的分数给了,心情倍爽,祝大家元旦快乐! 如何解决这么简单的问题 求助:关于局域网内一对多的通信 对话框程序弹出非模态对话框问题!
把文字写在一个“黑色”的DC上,把DC镜像了,再和原始DC合成。
{
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);//画图
}
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);