2010-02-23 7 views
2

내가 얻은 것은 스크린 샷 응용 프로그램을 만드는 것과 같습니다. (직렬화 관리, 신의 감사 !!!) 버튼을 클릭하면 화면 캡처는 처리 클래스의 메소드에 액세스하여 수행됩니다. 이제 까다로운 부분은 클래스가 각각의 처리 메소드가 호출 될 때와 같은 방식으로 윈도우가 생성되고 (표시된 경우) 비트 맵 이미지가 그 창문. 문제는 지금까지 WPF에서 이미지 컨트롤의 소스가 이미지를 저장하는 변수에 귀속 될 수 없다는 것을 알게되었습니다. 변수를 저장하고 uri를 얻지 않고도 변수에 저장된 이미지를 어떻게 표시 할 수 있습니까? ?메모리에 저장된 WPF에서 이미지를 표시하는 방법이 있습니까?

답변

1

감사 : 여기에 당신이 시작하는 수 개의 링크가 있습니다. 여기에 어떻게 내가 해냈어 : 나는이 memstream에 BMP를 전달하는 방법에서 발견 된 일부 정보와 해당 페이지에서 발견 한 것을 나는 기본적으로 조합 한

MemoryStream ms = new MemoryStream(); 
sBmp = gBmp; //note: gBmp is a variable that stores the captured image and passes it on to the method that uses sBMP as a distribuitor of the variable holding the captured image data 
//variable that holds image 
sBmp.Save(ms,ImageFormat.Bmp); 
//my buffer byte 
byte[] buffer = ms.GetBuffer(); 
//Create new MemoryStream that has the contents of buffer 
MemoryStream bufferPasser = new MemoryStream(buffer); 
//Creates a window with parents classthatholdsthismethod and null 
Edit childEdit = new Edit(this, null); 
childEdit.Show(); 
//I create a new BitmapImage to work with 
BitmapImage bitmap = new BitmapImage(); 
bitmap.BeginInit(); 
bitmap.StreamSource = bufferPasser; 
bitmap.EndInit(); 
//I set the source of the image control type as the new BitmapImage created earlier. 
childEdit.imgImageCanvas.Source = bitmap; 
childEdit.Activate(); 

. 나는 이것을 100 % 일하게했다 :

관련 문제