[英]vb.net code to make a image transparent
我希望使用 VB.NET 代碼使位圖圖像 (.bmp) 透明。 請幫助我。
VS 2012
Dim watermark_bm2 As Bitmap = 'someimage(來自文件或全局資源)
watermark_bm2.MakeTransparent()
我發現關鍵是使用imageAttributes
類。 基本上將顏色鍵設置為您用來表示透明區域的顏色,並使用接受imageAttribute
參數的drawImage
調用之一...
Imports System.Drawing.Imaging
' and in a sub somewhere:
Private mImageAttributes As New ImageAttributes
mImageAttributes.SetColorKey(Color.FromArgb(0, 220, 20, 255),
Color.FromArgb(0, 220, 20, 255))
Dim imageRectangle As New Rectangle(pX, pY, pBitmap.Width, pBitmap.Height)
e.Graphics.DrawImage(pBitmap, imageRectangle, 0, 0, pBitmap.Width, pBitmap.Height,
GraphicsUnit.Pixel, mImageAttributes)
這篇 msdn 文章提供了有關如何執行此操作的完整詳細信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.