2013-04-02 1 views
2

카메라를 사용하는 앱을 만들고 프레임을 가져 와서 변환 한 다음 화면 위에 놓습니다. Microsoft에서 회색 음영으로 변환하여 튜토리얼을 찾았지만 정말 필요하지 않습니다. 대신 int 배열을 내가 8b 비트 맵에서 내 변환 함수를 제대로 작동 할 수 있도록해야합니다. 그래서 주된 질문은 비트 맵 배열로 해당 픽셀 데이터 배열을 변환 할 수 및 다시 표시 할 수 있도록 그래서 그것을 다시 수 있습니다. 다른 해결책은 카메라에서 비트 맵 int 배열을 직접 가져 오는 것이지만 어떻게 할 수 있습니까?픽셀 데이터를 비트 맵 int 배열로 변환 - WP8 - C#

는 다음 코드에서 작동해야합니다

void PumpARGBFrames() 
    { 
     // Create capture buffer. 
     Width = (int)cam.PreviewResolution.Width; 
     Height = (int)cam.PreviewResolution.Height; 
     int[] ARGBPx = new int[Width * Height]; 

     try 
     { 
      PhotoCamera phCam = (PhotoCamera)cam; 

      while (pumpARGBFrames) 
      { 
       pauseFramesEvent.WaitOne(); 

       phCam.GetPreviewBufferArgb32(ARGBPx); 

       //here i need to do the conversion back and forward 

       pauseFramesEvent.Reset(); 
       Deployment.Current.Dispatcher.BeginInvoke(delegate() 
       { 
        ARGBPx.CopyTo(wb.Pixels, 0); 
        wb.Invalidate(); 

        pauseFramesEvent.Set(); 
       }); 
      } 

     } 
     catch (Exception e) 
     { 
      this.Dispatcher.BeginInvoke(delegate() 
      { 
       // Display error message. 
       txtDebug.Text = e.Message; 
      }); 
     } 
    } 

그래서, 사실은 내가 비트 맵을 필요가 없습니다이지만, 8B - 비트 맵의 ​​소스로 int 배열. Microsoft에서 얻은 자습서는 here입니다. 감사합니다. . 같은 시도

답변

0

좋아, 내가 픽셀 데이터 배열 사실 난 단지 8B 하나에 32B 색상을 변환했다 32b.so에 있던 색상의 배열 것을 깨달았다 , 그렇게 열심히 나는 생각하지 않았다.

감사합니다.

0

:

Bitmap bmp = new Bitmap(Width, Height); 

for (int i = 0; i < ARGBPx.Length; ++i) 
{ 
    bmp.SetPixel(
     i % Width, 
     i/Width, 
     /* something to create a Color object from the pixel int value */ 
} 
+0

WP8 개발은 Bitmap.Only BitmapImage를 지원하지 않지만, 내가 말한 것처럼 사용할 수는 없습니다. –

+0

그런 경우에는 2 차원 배열로 변환하고 Bitmap 대신 조작 할 수 있습니다. – BlargleMonster

관련 문제