古詩詞大全網 - 古詩大全 - C# GDI+導入如何讓背景透明

C# GDI+導入如何讓背景透明

GDI+中這個重載函數可以實現

Graphics.DrawImage ( _

image As Image, _

destRect As Rectangle, _

srcX As Integer, _

srcY As Integer, _

srcWidth As Integer, _

srcHeight As Integer, _

srcUnit As GraphicsUnit, _

imageAttr As ImageAttributes _

)

ImageAttributes有個成員方法.SetColorKey (Color, Color) ,可以設置透明色範圍.如果妳要做漸變透明也可以修改其他屬性.比如使用顏色替換,背景色替換成半透明色