XP模式或远程桌面中的DrawImage

时间:2010-04-20 20:32:46

标签: c# gdi+ png drawimage

我正在显示一个透明背景的PNG,它在Windows 7中看起来不错,但后来我在XP模式或远程桌面上运行我的应用程序到Windows XP机器,并且PNG看起来不正确。我注意到如果我禁用“集成模式”或在没有远程桌面的XP上运行应用程序,图像看起来很好。

如何让DrawImage在XP模式或远程桌面中正确渲染PNG?

Windows 7中的图像

alt text http://www.freeimagehosting.net/uploads/957bb6ea8b.png

XP模式或远程桌面内的图像

alt text http://www.freeimagehosting.net/uploads/08f1fbec46.png

这是我的代码:

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);
}

1 个答案:

答案 0 :(得分:2)

默认情况下,远程桌面以16位颜色运行,我认为这与alpha混合不兼容。如果可能,您需要将显示重新配置为32位模式。

相关问题