Necesito convertir una imagen a un mapa de bits.Convirtiendo Imagen a mapa de bits se vuelve negro
inicialmente un gif se leyó en bytes y luego se convirtió en una imagen.
Pero cuando intento convertir la imagen a un mapa de bits, el gráfico que se muestra en mi cuadro de imagen tiene un fondo negro cuando solía ser blanco.
Aquí está el código:
var image = (System.Drawing.Image)value;
// Winforms Image we want to get the WPF Image from...
var bitmap = new System.Windows.Media.Imaging.BitmapImage();
bitmap.BeginInit();
MemoryStream memoryStream = new MemoryStream();
// Save to a memory stream...
image.Save(memoryStream, ImageFormat.Bmp);
// Rewind the stream...
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
bitmap.StreamSource = memoryStream;
bitmap.EndInit();
return bitmap;
Puede alguien explicar por qué el fondo va negro y cómo puedo detenerlo haciendo esto.
Gracias
Muchas gracias mucho. Funcionó como un encanto – SetiSeeker
Funcionó bien para mí también. Hay un poco de código que muestra esta solución aquí: http://stackoverflow.com/questions/6513633/convert-transparent-png-to-jpg-with-non-black-background-color – TripleAntigen
Pero BMP no admite la transparencia, ¿verdad? ? – Robula