SetWorldTransform()和字体旋转 [英] SetWorldTransform() and font rotation

查看:170
本文介绍了SetWorldTransform()和字体旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Windows控件上显示文字,旋转90度,以便从自下而上读取所说的内容;通过使用SetGraphicsMode(GM_ADVANCED)改变我的坐标系为DC,然后我的文本垂直显示,然后使用

  XFORM转换; 
const double angle = 90 *(boost :: math :: constants :: pi< double>()/ 180);
transform.eM11 =(FLOAT)cos(angle);
transform.eM12 =(FLOAT)( - sin(angle));
transform.eM21 =(FLOAT)sin(angle);
transform.eM22 =(FLOAT)cos(angle);
transform.eDx = 0.0;
transform.eDy = 0.0;
dc.SetWorldTransform(& transform);

现在,当我运行我的程序时,旋转后的文本与正常显示的文本看起来不同'(水平)。我尝试过使用固定宽度(系统)字体和默认的WinXP字体。系统字体出来看起来反锯齿,另一个看起来好像它被绘制成比水平版本小1个字体的字体,尽管它们使用相同的DC绘制并且没有字体间的变化。它看起来好像Windows检测到我正在绘制不是沿着正常(0度)轴的字体,而是试图通过消除锯齿来优化。



现在我不想要这些。我只想绘制与水平绘制的文字完全相同的文字,除了90度旋转之外,这是可能的,因为它是完全旋转90度的。有没有人知道发生了什么,以及我是否可以轻松地将其改变为按照我的意愿工作?我讨厌经历了所有这些麻烦,并且发现我不得不求助于渲染到离屏位图,使用一个简单的逐像素旋转来旋转它,并且必须将其转换为我的控件:(

解决方案

您是否尝试设置 nEscapement nOrientation 参数创建字体而不是使用 SetWorldTransform ?请参阅 CreateFont 了解详情。


I'm trying to display text on a Windows control, rotated by 90 degrees, so that it reads from 'bottom to top' so to speak; basically it's the label on the Y axis of a graph.

I got my text to display vertically by changing my coordinate system for the DC by using SetGraphicsMode(GM_ADVANCED) and then using

XFORM transform;
const double angle = 90 * (boost::math::constants::pi<double>() / 180);
transform.eM11 = (FLOAT)cos(angle);
transform.eM12 = (FLOAT)(-sin(angle));
transform.eM21 = (FLOAT)sin(angle);
transform.eM22 = (FLOAT)cos(angle);
transform.eDx = 0.0;
transform.eDy = 0.0;
dc.SetWorldTransform(&transform);

Now when I run my program, the rotated text looks different from the same text when it's shown 'normally' (horizontally). I've tried with a fixed-width (system) font and the default WinXP font. The system font comes out look anti-aliased and the other one looks almost as if it's being drawn in a 1-pixel smaller font than the horizontal version, although they are drawn using the same DC and with no font changes in between. It looks as if Windows detects that I'm drawing a font not along the normal (0 degrees) axis and that it's trying to 'optimize' by anti-aliasing.

Now I don't want any of that. I just want to same text that I draw horizontally to be drawn exactly the same, except 90 degrees rotated, which is possible since it's a rotation of exactly 90 degrees. Does anyone know what's going on and whether I can change this easily to work as I want? I'd hate to have gone through all this trouble and finding up that I will have to resort to rendering to an off-screen bitmap, rotating it using a simple pixel-by-pixel rotation and having to bitblt that into my control :(

解决方案

Have you tried setting the nEscapement and nOrientation parameters when you create the font instead of using SetWorldTransform? See CreateFont for details.

这篇关于SetWorldTransform()和字体旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆