Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How Can I Convert My new Byte Array To an Image

$
0
0
i have write this code for extracting bitplane1 of my image . but i have exception
 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
 

namespace bitplane
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
 
private void button1_Click(object sender, EventArgs e)
 
{
// Image grayImage;
OpenFileDialog o = new OpenFileDialog();
o.ShowDialog();

byte[] x = File.ReadAllBytes(o.FileName);

byte maskbyte1 = 2;
int [] newpix= new int [x.Length];
for (int i = 0; i < x.Length; i++)
{
 

newpix[i] = x[i] & maskbyte1;
 
string px=newpix[i].ToString();

 
x[i] = Convert.ToByte(px);

}
MemoryStream ms = new MemoryStream(x);
Image myImage = Image.FromStream(ms);
 
myImage.Save(@"C:\Users\Public\Pictures\Sample Pictures\New folder\fgh.jpg");
}
}
}


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>