【问题标题】:DrawThemeTextEx and clipped glowDrawThemeTextEx 和裁剪发光
【发布时间】:2011-11-06 08:22:49
【问题描述】:

使用this complete example 我可以在 Aero Glass 上绘制文本。渲染完美无缺,但存在视觉问题:发光在文本对齐侧被剪裁。

仅供参考,文本格式定义如下:

  Dim uFormat As Integer = TextFormatFlags.NoPrefix Or TextFormatFlags.WordBreak Or _
            TextFormatFlags.TextBoxControl Or TextFormatFlags.EndEllipsis

这可以解决吗?

【问题讨论】:

    标签: .net clipping drawtext aero-glass


    【解决方案1】:

    默认情况下,此example 用于文本的中间居中对齐。您使用的格式 (NoPrefix|WordBreak|TextBoxControl|EndEllipsis) 默认为左对齐。因此,要修复辉光剪辑,您应该扩展辉光边界。
    以下是更正后的示例:

    public void DrawTextOnGlass(IntPtr hwnd, String text, Font font, Rectangle bounds, int glowSize){
    //...
        RECT glowRect = new RECT();
        RECT textRect = new RECT();
    
        glowRect.left = bounds.Left - glowSize;
        glowRect.right = bounds.Right + glowSize;
        glowRect.top = bounds.Top - glowSize;
        glowRect.bottom = bounds.Bottom + glowSize;
    
        textRect.left = glowSize;
        textRect.top = glowSize;
        textRect.right = glowRect.right - glowRect.left;
        textRect.bottom = glowRect.bottom - glowRect.top;
    //...
        int uFormat = (int)(TextFormatFlags.NoPrefix
        | TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.EndEllipsis);
    //...
        DrawThemeTextEx(renderer.Handle, Memdc, 0, 0, text, -1, uFormat, ref textRect, ref dttOpts);
        BitBlt(destdc, glowRect.left, glowRect.top, 
            glowRect.right - glowRect.left, 
            glowRect.bottom - glowRect.top, 
            Memdc, 0, 0, SRCCOPY);
    //...    
    }
    

    【讨论】:

      猜你喜欢
      • 2017-03-22
      • 1970-01-01
      • 2018-11-02
      • 2011-04-19
      • 1970-01-01
      • 2013-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多