我收的:
----------------------------------
一个图象背景是黑色的,现在把黑色替换为透明色。
Public Sub Bmp2Gif(ByVal BmpFile As String, ByVal GifFile As String, ByVal BgColor As Color)
Try
Dim mBmp As Bitmap = Bitmap.FromFile(BmpFile)
Dim i, j As Integer
For i = 0 To mBmp.Width - 1
For j = 0 To mBmp.Height - 1
If mBmp.GetPixel(i, j).Equals(BgColor) Then
mBmp.SetPixel(i, j, Color.Transparent)
End If
Next
Next
mBmp.Save(GifFile, System.Drawing.Imaging.ImageFormat.Gif)
Catch ex As Exception
Throw ex
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Bmp2Gif("C:\aaa.bmp", "c:\aaa.gif", Color.FromArgb(0, 0, 0))
End Sub