Can you make an alpha transparent PNG with C#?

后端 未结 9 1738
陌清茗
陌清茗 2020-12-02 14:31

I have a multi-browser page that shows vertical text.

As an ugly hack to get text to render vertically in all browsers I\'ve created a custom page handler that retur

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 14:51

    You can use the LockBits method on your Bitmap to return a BitmapData object, and set the Alpha for each pixel yourself (you could also use GetPixel and SetPixel, but these methods are insanely slow). See this answer.

    I know this works for sure, because when I first started using the technique I was setting the alpha value to 0, so none of the colors I was setting were visible.

    Edit: here is a sample of a fisheye lens effect, done entirely in .NET (using LockBits):

    alt text http://www.freeimagehosting.net/uploads/21ca8300cc.jpg

提交回复
热议问题