Main Site Documentation

Saving image files from a Camera module stream


#1

I’ve successfully used the Camera module to save images on the PictureCaptured event (from the GT.Picture picture data field) using the TakePicture method. However I would like to stream images to the display (and occasionally save them to disk) using the StartStreamingBitmaps method and the BitmapStreamed event.

I can get the bitmaps to stream to the display correctly, but I can’t figure out a way to save an image from the BitmapStreamed event (parameter is a Microsoft.SPOT.Bitmap instead of a GT.Picture). Is there something I’m overlooking? Or will I have to just fire the TakePicture method every second and deal with a slower updating display?

Thanks!
Tommy


#2

Try something like this, since all you really need to write to the file is an array of bytes.

void camera_BitmapStreamed(Camera sender, Bitmap bitmap)
        {
            if (sdCard.IsCardInserted && sdCard.IsCardMounted)
            {
                sdCard.GetStorageDevice().WriteFile(/*Add your file path and name here. Don't forget the file extention(.bmp)*/, bitmap.GetBitmap());
            }
            else
            {
                Debug.Print("SD card error");
            }
        }

Just make sure you put the file name/path in the way you want it. Hope this helps!


#3

Steven - thanks, I tried doing that, but it didn’t seem to be in any particular image format? When I transferred it to my PC, I couldn’t open the image. The GT.Picture picture data field when saved, I could open as a bmp.


#4

GHI library has a method to convert to BMP. It is in util class