【问题标题】:Retain transparency of an image created on bitmap in VB.NET application保留在 VB.NET 应用程序中的位图上创建的图像的透明度
【发布时间】:2016-09-30 14:53:33
【问题描述】:

我必须在 Visual Studio 2005 中构建的 Windows 应用程序的表面上绘制图像。

图像的类型为 .png,并且包含透明背景。

当我用图像创建位图并在窗口上绘制时(在 onPaint 事件中),图像失去了透明背景,图像的透明部分变成了白色。如何保持透明度?

【问题讨论】:

  • 很可能是窗口的背景与透明像素混合在一起。在这种情况下,图像本身会很好。请分享您的代码,也许还可以提供显示问题的屏幕截图,这样我们可以更轻松地为您提供帮助。

标签: vb.net image bitmap visual-studio-2005 windows-applications


【解决方案1】:

在位图对象上调用此方法,将“Color tranparentColor”替换为您想要透明的颜色:

myBitmap->MakeTransparent(Color transparentColor);

如果您希望 bmp 的左上角像素为透明色,您可以这样做:

  // Get the color of a background pixel.
  Color backColor = myBitmap->GetPixel( 1, 1 );

  // Make backColor transparent for myBitmap.
  myBitmap->MakeTransparent( backColor );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-08
    • 2012-06-16
    • 2011-10-06
    • 2016-09-02
    • 2011-04-18
    • 1970-01-01
    相关资源
    最近更新 更多