【发布时间】:2013-04-02 17:18:20
【问题描述】:
我想制作一个使用相机的应用程序,从中获取帧,将其转换并放在屏幕上。我从微软找到了一个教程,它通过转换为灰度来做到这一点,但我真的不需要那个。相反,我需要像 8b 位图那样的 int 数组,这样我的转换功能才能正常工作。所以主要问题是如何将该像素数据数组转换为位图数组,然后将其转回以便我可以显示它屏幕?另一种解决方案是直接从相机获取位图 int 数组,但我该怎么做呢?
我需要处理以下代码:
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;
});
}
}
所以,事实上我不需要位图,而是需要一个 int 数组作为 8b 位图的来源。 我从微软那里得到的教程是here。 谢谢。
【问题讨论】:
标签: c# bitmap camera windows-phone-8