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;
namespace newconvert
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Bitmap bitmap;
public void Form1_Load(object sender, EventArgs e)
{
String fileName =
@"C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg";
using (Stream bmpStream =
System.IO.File.Open(fileName, System.IO.FileMode.Open))
{
Image image = Image.FromStream(bmpStream);
bitmap = new Bitmap(image);
pictureBox1.Image = bitmap;
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
try
{
String fileName =
@"C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg";
String fName =
@"C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg";
String Naming =
@"C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg";
String Nam =
@"C:\Users\Public\Pictures\Sample Pictures\Lighthouse.jpg";
String Namd =
@"C:\Users\Public\Pictures\Sample Pictures\Amazingly Funny People Photo #1 (11).jpg";
using (Stream bmpStream =
System.IO.File.Open(fileName, System.IO.FileMode.Open))
{
bitmap.Dispose();
Image image = Image.FromStream(bmpStream);
bitmap = new Bitmap(image);
pictureBox2.Image = bitmap;
pictureBox2.Height = bitmap.Height;
pictureBox2.Width = bitmap.Width;
}
}
catch (Exception a)
{
MessageBox.Show("" + a);
}
}
}
}
I use the above code in windows application to convert jpg file into bitmap and stream the image it works. But I need to know how to do this in wpf application. I'm using grid to set the images. In grid only bitmapimage available. How can I do this?