Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

convert bitmap to imagesource

 public BitmapSource ConvertToBitmapSource(Bitmap src, ImageFormat imageFormat)
        {
            try
            {
                MemoryStream ms = new MemoryStream();
                src.Save(ms, imageFormat);
                BitmapImage image = new BitmapImage();
                image.BeginInit();
                ms.Seek(0, SeekOrigin.Begin);
                image.StreamSource = ms;
                image.EndInit();
                return image;
            }
            catch
            {
                // ignored
            }

            return null;
        }
 
PREVIOUS NEXT
Tagged: #convert #bitmap #imagesource
ADD COMMENT
Topic
Name
1+4 =