コード例 #1
0
        // Handles the pictures button tap event.
        static void btnPics_TapEvent(object sender)
        {
            //check for sd card
            if (picCounter < 0)
            {
                Glide.MessageBoxManager.Show("SD Card not found.", "SD Card");
                return;
            }

            RoverJoystickControlTimer.Change(-1, -1); //stop timer
            UpdateMainWindowTimer.Change(-1, -1);     //stop timer

            string[] sdCardfiles   = Directory.GetFiles(SD_ROOT_DIRECTORY);
            string[] tempFileNames = new string[sdCardfiles.Length];

            //string[] folders = Directory.GetDirectories(SD_ROOT_DIRECTORY);
            FileStream fileStream = null;

            picCounter = 0;

            var i = 0;

            foreach (string sdfile in sdCardfiles)
            {
                if (sdfile.IndexOf(".jpg") != -1)
                {
                    tempFileNames[i++] = sdfile;
                }
            }

            if (tempFileNames.Length > 0)
            {
                sdCardJpgFileNames = new string[i];
                Array.Copy(tempFileNames, sdCardJpgFileNames, i);

                Tween.SlideWindow(_mainWindow, pictureWindow, GHI.Glide.Direction.Up);

                //Use FileStream to read a text file
                //fileStream = new FileStream(SD_ROOT_DIRECTORY + @"\" + sdCardJpgFileNames[0] + ".jpg", FileMode.Open);
                fileStream = new FileStream(sdCardJpgFileNames[picCounter], FileMode.Open);

                //load the data from the stream
                byte[] data = new byte[fileStream.Length];
                fileStream.Read(data, 0, data.Length);

                Bitmap myPic = new Bitmap(data, Bitmap.BitmapImageType.Jpeg);

                GHI.Glide.UI.Image image = (GHI.Glide.UI.Image)pictureWindow.GetChildByName("imgPicture");
                //image.Bitmap = Resources.GetBitmap(Resources.BitmapResources.logo);
                image.Bitmap.DrawImage(0, 0, myPic, 0, 0, 320, 240);

                fileStream.Close();

                image.Invalidate();

                PictureViewerTimer.Change(0, PictureViewerTimerPeriod);
            }
            else
            {
                Glide.MessageBoxManager.Show("No Pictures found.", "Picture Viewer");
                RoverJoystickControlTimer.Change(0, RoverJoystickTimerPeriod);
                UpdateMainWindowTimer.Change(0, UpdateMainWindowTimerPeriod);
            }
        }
コード例 #2
0
 void camera_BitmapStreamed(Camera sender, Bitmap e)
 {
     imgPhoto.Bitmap = e;
     imgPhoto.Alpha  = 255;      //image component is set to non-transparent
     imgPhoto.Invalidate();
 }