How do you Draw Transparent Image using System.Drawing?

前端 未结 4 1735
孤独总比滥情好
孤独总比滥情好 2020-12-17 19:02

I\'m trying to return a transparent GIF from an .aspx page for display within a web page. I am trying to get the image to have transparency, but I just keep getting Black be

4条回答
  •  粉色の甜心
    2020-12-17 19:13

    It is possible, but not easy
    If you are able to use unsafe code in your project, there are a few methods to use pointers to rip through the colour table and make the transparency work.

    A sample forms app by Bob Powell is available here http://www.bobpowell.net/giftransparency.htm. I used a variation on this method on a web handler a few years ago that was getting hit about 10 million times a month, and it seemed to work fine.

    If you are only using a limited colour pallete you can reduce the colour table processing to just the colours you need (can't remember exactly how I did that...).

    That being said, png is a metric crapload easier.

提交回复
热议问题