DrawImage in XP Mode or Remote Desktop

Posted by simplecoder on Stack Overflow See other posts from Stack Overflow or by simplecoder
Published on 2010-04-20T20:32:45Z Indexed on 2010/04/20 20:33 UTC
Read the original article Hit count: 203

Filed under:
|
|
|

I'm displaying a PNG with a transparent background that looks good in Windows 7, but then I run my app in XP Mode or remote desktop to a Windows XP machine and the PNG looks incorrect. I noticed that if I disable "Integration Mode" or run the app on XP without remote desktop, the image looks fine.

How do I get DrawImage to render the PNG correctly in XP Mode or remote desktop?

Image inside Windows 7

alt text

Image inside XP Mode or remote desktop

alt text

Here's my code:

protected override void OnPaint(PaintEventArgs e)
{
    Image image = Image.FromFile("hello.png", false);
    Bitmap bmp = new Bitmap(image);

    Rectangle destRect = new Rectangle(0, 0, image.Width, image.Height);

    e.Graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
    base.OnPaint(e);
}

© Stack Overflow or respective owner

Related posts about drawimage

Related posts about png