I want to make an app that uses the camera , gets the frame from it, converts it and puts it over the screen. I found a tutorial from microsoft that does that with a conversion to grayscale, but i don't really need that. Instead i need that int array i got to be like from a 8b bitmap so my conversion function can work properly.So the main question is how can i convert that pixel data array to a bitmap array and then turn it back so i can display it to screen?Another solution would be to get directly the bitmap int array from camera, but how can i do that?
I need to work on the following code:
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;
});
}
}
So,the fact is i don't need a bitmap , but an int array as a source of a 8b-bitmap. The tutorial i got from microsoft is here . Thanks.
Try something like:
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 */
}
Ok, i realised that the pixel data array was in fact an array of colors,that were in 32b.so i had to just convert a 32b color to a 8b one,not so hard as i thought.
Thanks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.