Lo que he hecho es cargar el bmp con un fondo azul en un picturebox, y en el evento paint tratarlo y finalmente pasarlo a un segundo picturebox pero ya con el fondo transparente... pero no hay manera >_<
Espero que me puedan ayudar!!
Código:
Mi objetivo final es coger un archivo bmp de mi disco, y crear un gif con fondo transparente pasandole el colorkey (color de fondo), por si saben de alguna manera mas sencilla.Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.PictureBox1.Image = Image.FromFile(Application.StartupPath & "\rock.bmp") End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint Try Dim bmp As Bitmap Dim bmpFinal As Bitmap Dim g As Graphics bmp = Me.PictureBox1.Image bmpFinal = New Bitmap(bmp.Width, bmp.Height) bmpFinal.MakeTransparent() g = Graphics.FromImage(bmpFinal) Dim attr As New ImageAttributes attr.SetColorKey(Color.Blue, Color.Blue) Dim dstRect As New Rectangle(0, 0, bmp.Width, bmp.Height) e.Graphics.DrawImage(bmp, dstRect, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, attr) 'g.Dispose() 'g.Save() Me.PictureBox2.Image = bmpFinal Catch ex As Exception Call MsgBox("Error: " & ex.Message & vbNewLine & "Traza: " & ex.StackTrace) End Try End Sub
Saludos y espero que me puedan ayudar!
