且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Windows窗体中显示透明gif文件

更新时间:2023-12-06 16:18:58

您要的内容称为Alpha通道.不幸的是,GIF不支持它.摘自本文:

What you are asking for is called alpha channel. Unfortunately, it is not supported for GIFs. From this article:

TIFF,TGA,PNG,PSD和GIF均支持alpha,但实际上仅支持PNG和 GIF用于应用程序和Web.但是,Gif使用 特殊类型的Alpha.代替GIF图像中的Alpha通道 包含透明度,它仅具有打开/关闭透明度. 这意味着 GIF图像中的像素可以完全不透明 或完全透明.两者之间没有.

TIFF, TGA, PNG, PSD and GIF all support alpha but really only PNG and GIF are used for applications, and the web. Gif, however, uses a special type of alpha. Instead of the alpha channel in a GIF image containing degrees of transparency it only has an on/off transparency. This means that pixels within a GIF image can either be fully opaque or fully transparent. There is no in between.

可以通过程序以自定义不透明度绘制图像.看到这些:

It is possible to paint an image with custom opacity programmatically. See these:

  • Using Graphics.DrawImage() to Draw Image with Transparency/Alpha Channel
  • .DrawImage with opacity?
  • How to implement Alpha blending
  • Alpha Blending using GDI+