Hi
Drawing Transparent Images and Shapes using Alpha Blending
http://www.vbdotnetheaven.com/Code/Aug2003/2149.asp
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim bgImg As New Bitmap("Back.png")
'Because FromImage did not support all format, we need to convert it first.
bgImg.Save("c:\test.jpg", ImageFormat.Jpeg)
bgImg = Image.FromFile("c:\test.jpg")
Dim g As Graphics = Graphics.FromImage(bgImg)
Dim fgImg As New Bitmap("mario.jpg")
Dim ptsArray As Single()() = {New Single() {1, 0, 0, 0, 0}, New
Single() {0, 1, 0, 0, 0}, New Single() {0, 0, 1, 0, 0}, New Single() {0, 0,
0, 0.5F, 0}, New Single() {0, 0, 0, 0, 1}}
Dim clrMatrix As New ColorMatrix(ptsArray)
Dim imgAttributes As New ImageAttributes
imgAttributes.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default,
ColorAdjustType.Bitmap)
g.DrawImage(fgImg, New Rectangle(0, 0, 100, 100), 0, 0,
fgImg.Width, fgImg.Height, GraphicsUnit.Pixel, imgAttributes)
Me.PictureBox1.Image = bgImg
' Or Save the bgImg directly
End Sub
For the detailed information about ColorMatrix, you may take a look at the
link below.
Using a Color Matrix to Set Alpha Values in Images
http://msdn.microsoft.com/library/de...us/gdicpp/GDIP
lus/usingGDIPlus/alphablendinglinesandfills/usingacolormatrixtosetalphavalue
sinimages.asp
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.