none
Windows 8 - Garbled text with GDI+ Graphics::DrawString RRS feed

  • Question

  • Hello,

    I am testing my programs on Windows 8 Release Preview Build 8400 (x86), I noticed that all text drawn with gdi+ function Graphics::DrawString is unreadable when using SetCompositingMode(CompositingModeSourceCopy), characters are garbled and totally unreadable.

    Here is what is drawn for the text "Line One\nTwo"

    When using SetCompositingMode(CompositingModeSourceOver) everything is ok.

    I tried both on a VM and a real pc with the same results.

    The same code on windows 7 and Vista works fine.

    Did somebody else noticed this issue ?

    Is this a known bug ?

    Thanks

    Tuesday, June 19, 2012 9:21 AM

All replies

  • Hi Gianpaolo64,

    Could you share some code that we could test it in our side?


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, June 20, 2012 4:34 AM
    Moderator
  • Hi Bob,

    thanks for your reply, here is the code, I am using Visual Studio 2008 with all SP and updates, C++ and MFC. I wrote it quickly so maybe it's not the best however on win7 works fine.

    Gdiplus::Bitmap *TestDrawStringOnWin8()
    {
        Gdiplus::Bitmap *pBmp=new Bitmap(400,90,PixelFormat32bppPARGB);
        StringFormat stringFormat;
        Font font(_T("Arial Bold"),20,FontStyleRegular,UnitPixel);
        Graphics graph(pBmp);

        graph.Clear(Color(255, 255, 255));
        stringFormat.SetLineAlignment(StringAlignmentNear);

        graph.SetTextRenderingHint(TextRenderingHintSingleBitPerPixelGridFit);
        graph.SetCompositingMode(CompositingModeSourceCopy);

        SolidBrush   txtCol(Color(255,0,0,128));

        RectF rt1(0, 0, 400, 90);
        graph.DrawString(_T("Line One"), -1, &font, rt1, &stringFormat, &txtCol);

        graph.SetCompositingMode(CompositingModeSourceOver);
        RectF rt2(0, 30, 400, 90);
        graph.DrawString(_T("Line Two"), -1, &font, rt2, &stringFormat, &txtCol);

        return pBmp;
    }

    Then the bitmap is displayed inside a owner draw button with this code:

                Gdiplus::Bitmap *pBmp=TestDrawStringOnWin8();
                Gdiplus::Graphics graph(lpDrawItemStruct->hDC);
                graph.DrawImage(pBmp, 0, 0);
                delete pBmp;

    and this is the result on Win8 x86 build 8400


    I tried to change font name and other things but it seems the only thing that causes that effect is CompositingModeSourceCopy operation.

    Thanks,

    Gianpaolo

    Wednesday, June 20, 2012 12:28 PM
  • Hi Gianpaolo,

    Yes, I reproduce it in my side.  I will involve more experts to investigate it. Thanks.


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us


    Thursday, June 21, 2012 10:22 AM
    Moderator
  • Hi Bob,

    thanks for your help. In the meanwhile I found a workaround, I replaced DrawString with something like the following lines and it works correctly.

        GraphicsPath path;
        FontFamily ffam;
        font->GetFamily(&ffam);
        Status status = path.AddString(string,length,&ffam,font->GetStyle(),font->GetSize(),layoutRect,stringFormat);
        if(status!=Ok)
            return status;
        return grp.FillPath(brush, &path);

    I opened the Microsoft Connect web site but I am really wondering for which product to submit the bug. Windows 8 is not there and I don't think this issue has anything to do with VS2012. Can you suggest something ?

    Thanks,

    Gianpaolo

    Thursday, June 21, 2012 10:42 AM
  • Hi Gianpaolo,

    If no one can provide solution here, how about open a case to Microsoft? With a support case,
    a support engineer will request to check Inspect source code, and assist you to
    find the solution. I believe you can do what Inspect has implemented after
    having someone check the source code.

     Please visit the below link to see the various paid support options that are available to better
    meet your needs. 

    http://support.microsoft.com/default.aspx?id=fh%3ben-us%3bofferprophone

    Regards,

    Jenny

    Thursday, August 2, 2012 8:38 AM
  • Hi Bob,

    My application also has this issue.

    Do you have any update for this issue?

    Thanks


    • Edited by kkkccc Wednesday, August 8, 2012 2:22 AM
    Wednesday, August 8, 2012 2:22 AM
  • Hi Gianpaolo,

    If no one can provide solution here, how about open a case to Microsoft? With a support case,
    a support engineer will request to check Inspect source code, and assist you to
    find the solution. I believe you can do what Inspect has implemented after
    having someone check the source code.

     Please visit the below link to see the various paid support options that are available to better
    meet your needs. 

    http://support.microsoft.com/default.aspx?id=fh%3ben-us%3bofferprophone

    Regards,

    Jenny

    What is the meaning of this answer ??

    I found a workaroud by myself but this is not the point. The point is: since the same code works on XP, Vista, 7 but does NOT work on 8, is  gdi+ in win 8 buggy ?

    Is MS aware of this bug ? Is MS doing something to fix it before RTM ? Until now no answer to these questions.

    Saturday, August 11, 2012 3:11 PM
  • They did. DrawString() now returns InvalidParameter... Sigh. This is even misleading as all parameters are fine.
    • Edited by chksr Wednesday, January 15, 2020 8:30 AM
    Wednesday, January 15, 2020 8:29 AM