Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Bitmap to Image

Tags:

c#

winforms

gdi+

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?
}
like image 891
Saeid Yazdani Avatar asked Feb 20 '12 19:02

Saeid Yazdani


People also ask

Can you convert a bitmap image to a vector?

It is impossible to perfectly convert a Bitmap image into a vector one, but with some experimentation it is possible to achieve good results. To convert a Bitmap image, first import it into Animate (File -> Import to Stage). Then select the image, and select Modify -> Bitmap -> Trace Bitmap.


3 Answers

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

From MSDN:

[SerializableAttribute]
[ComVisibleAttribute(true)]
public sealed class Bitmap : Image
like image 115
vcsjones Avatar answered Oct 01 '22 17:10

vcsjones


This is what has worked for me:

var codeBitmap = new Bitmap(your_info);
Image image = (Image)codeBitmap;
like image 33
Illia.K Avatar answered Oct 01 '22 17:10

Illia.K


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

like image 29
STG Avatar answered Oct 01 '22 18:10

STG