Bueno, ya esta solucionado, hay un problema con guardarlo con el imageformat.gif, pongo como NO se tiene que hacer y como Si se tiene que hacer.
El ejemplo utiliza 2 picturebox un boton 'cmdTransformar' y una imagen bmp con el fondo azul.
COMO NO HACERLO:
Tal y como se hace este ejemplo se guarda en gif pero con fondo negro pese haberlo puesto transparente y guardarlo con imageformat.gif.
Código:
Imports System.Drawing.Imaging
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.PictureBox1.Image = Bitmap.FromFile("rock.bmp")
End Sub
Private Sub cmdTransformar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTransformar.Click
Dim imgObjeto As Bitmap = New Bitmap(Me.PictureBox1.Image)
Try
imgObjeto.MakeTransparent(Color.Blue)
Me.PictureBox2.Image = imgObjeto
Me.PictureBox2.Image.Save("rock.gif", ImageFormat.Gif)
Catch ex As Exception
Call MsgBox("Error: " & ex.Message & vbNewLine & "Traza: " & ex.StackTrace)
End Try
End Sub
End Class
Como SI hacerlo:
Simplemente se le quita el parametro imageformat.gif al guardarlo y funciona perfectamente:
Código:
Imports System.Drawing.Imaging
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.PictureBox1.Image = Bitmap.FromFile("rock.bmp")
End Sub
Private Sub cmdTransformar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTransformar.Click
Dim imgObjeto As Bitmap = New Bitmap(Me.PictureBox1.Image)
Try
imgObjeto.MakeTransparent(Color.Blue)
Me.PictureBox2.Image = imgObjeto
Me.PictureBox2.Image.Save("rock.gif")
Catch ex As Exception
Call MsgBox("Error: " & ex.Message & vbNewLine & "Traza: " & ex.StackTrace)
End Try
End Sub
End Class
Gracias por la ayuda RootK y espero que este codigo le sirva a mas gente.
Saludos.
PD. maldito imageformat......