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);
}
}
}
}
Windows 응용 프로그램에서 위 코드를 사용하여 jpg 파일을 비트 맵으로 변환하고 작동되는 이미지를 스트리밍합니다. 하지만 wpf 응용 프로그램에서이 작업을 수행하는 방법을 알아야합니다. 그리드를 사용하여 이미지를 설정하고 있습니다. 그리드에서만 비트 맵 이미지를 사용할 수 있습니다. 어떻게해야합니까? 같은jpg 이미지를 비트 맵 이미지로 변환하는 방법?
가능 중복 된 [I은 C#을 사용, 비트 맵으로 JPG 파일을 변환 할 수있는 방법 ?] (http://stackoverflow.com/questions/24383256/how-can-i-convert-a-jpg-file-into-a-bitmap-using-c) –
Daniel kin dly는 내 질문을 읽었습니다. wpf 응용 프로그램에서 어떻게 할 수 있는지 알아야합니다. – KVK