Dumbo
Dumbo

Reputation: 14132

How to convert Bitmap to Image

I am making a median filter, the problem is manipulating pixes are only possible in Bitmap. Later I want to show the result in a PictureBox which uses Image. I can't figure out a way to to solve this...Only thing I can think of is using a Stream but no idea how. Help will be appriciated~

private void toolStripPerformMedian_Click(object sender, EventArgs e)
{
    var filtered = Filters.MedianFilter(new Bitmap(_activeImageFile), 3);
    var n = Image.FromStream() //How to do this?
}

Upvotes: 45

Views: 130542

Answers (3)

Illia.K
Illia.K

Reputation: 49

This is what has worked for me:

var codeBitmap = new Bitmap(your_info);
Image image = (Image)codeBitmap;

Upvotes: 3

Sargis Tovmasyan
Sargis Tovmasyan

Reputation: 123

Check up the namespaces. System.Drawing.Image compatible with bitmap, System.Window.Control.Image - not!

Upvotes: 1

vcsjones
vcsjones

Reputation: 141703

A Bitmap is an Image. It inherits from the Image class.

From MSDN:

[SerializableAttribute]
[ComVisibleAttribute(true)]
public sealed class Bitmap : Image

Upvotes: 97

Related Questions