示例#1
0
            protected void cameraTask_Completed(object sender, PhotoResult e)
            {
                rho.common.Hashtable <String, String> mapRes = new rho.common.Hashtable <String, String>();

                switch (e.TaskResult)
                {
                case TaskResult.OK:
                    WriteableBitmap writeableBitmap = new WriteableBitmap(1600, 1200);
                    writeableBitmap.LoadJpeg(e.ChosenPhoto);

                    string imageFolder = "rho/apps";    //CFilePath.join( rho_native_rhopath(), RHO_APPS_DIR);//"rho";
                    string datetime    = DateTime.Now.ToString().Replace("/", "");
                    datetime = datetime.Replace(":", "");
                    string imageFileName = "Foto_" + datetime.Replace(" ", String.Empty) + ".jpg";
                    string filePath      = "";
                    using (var isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        if (!isoFile.DirectoryExists(imageFolder))
                        {
                            isoFile.CreateDirectory(imageFolder);
                        }

                        filePath = System.IO.Path.Combine(imageFolder, imageFileName);
                        using (var stream = isoFile.CreateFile(filePath))
                        {
                            writeableBitmap.SaveJpeg(stream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 100);
                        }
                    }

                    mapRes["imageUri"]  = "/" + imageFileName; //e.OriginalFileName;
                    mapRes["image_uri"] = "/" + imageFileName; //e.OriginalFileName;
                    mapRes["status"]    = "ok";

                    break;

                case TaskResult.None:
                    mapRes["message"] = "Error";
                    mapRes["status"]  = "error";
                    break;

                case TaskResult.Cancel:
                    mapRes["message"] = "User cancelled operation";
                    mapRes["status"]  = "cancel";
                    break;

                default:
                    break;
                }

                _oResult.set(mapRes);

                //Code to display the photo on the page in an image control named myImage.
                //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                //bmp.SetSource(e.ChosenPhoto);
                //myImage.Source = bmp;
            }
示例#2
0
            protected void cameraTask_Completed(object sender, PhotoResult e)
            {
                rho.common.Hashtable<String, String> mapRes = new rho.common.Hashtable<String, String>();

                switch (e.TaskResult)
                {
                    case TaskResult.OK:
                        WriteableBitmap writeableBitmap = new WriteableBitmap(1600, 1200);
                        writeableBitmap.LoadJpeg(e.ChosenPhoto);

                        string imageFolder = "rho/apps";//CFilePath.join( rho_native_rhopath(), RHO_APPS_DIR);//"rho";
                        string datetime = DateTime.Now.ToString().Replace("/", "");
                        datetime = datetime.Replace(":", "");
                        string imageFileName = "Foto_" + datetime.Replace(" ", String.Empty) + ".jpg";
                        string filePath = "";
                        using (var isoFile = IsolatedStorageFile.GetUserStoreForApplication())
                        {

                            if (!isoFile.DirectoryExists(imageFolder))
                            {
                                isoFile.CreateDirectory(imageFolder);
                            }

                            filePath = System.IO.Path.Combine(imageFolder, imageFileName);
                            using (var stream = isoFile.CreateFile(filePath))
                            {
                                writeableBitmap.SaveJpeg(stream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 100);
                            }
                        }

                        mapRes["imageUri"] = "/"+imageFileName;//e.OriginalFileName;
                        mapRes["image_uri"] = "/"+imageFileName;//e.OriginalFileName;
                        mapRes["status"] = "ok";

                        break;
                    case TaskResult.None:
                        mapRes["message"] = "Error";
                        mapRes["status"] = "error";
                        break;
                    case TaskResult.Cancel:
                        mapRes["message"] = "User cancelled operation";
                        mapRes["status"] = "cancel";
                        break;
                    default:
                        break;
                }

                _oResult.set(mapRes);

                //Code to display the photo on the page in an image control named myImage.
                //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                //bmp.SetSource(e.ChosenPhoto);
                //myImage.Source = bmp;
            }